Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Nagios Email Notifications! HELP!

Posted on 2010-11-12
18
Medium Priority
?
1,959 Views
Last Modified: 2013-11-30
Hi,

I am running Nagios Core with VShell on Ubuntu 10.10. I have worked my way through the PostFix installation guide found here: https://help.ubuntu.com/community/Postfix and my contact.cfg file is setup with a email address that is hosted on our MS Exchange server. Am I missing something here because I am not receiving any notifications even when I try and force one through from Nagios.

I am a newbie when it comes to Linux so needs some step by step help is required. Your help will be greatly appreciated as this is the last thing I need to get working on my Nagios implementation.

Looking in the log I see this: (email address & have been changed for privacy)

Warning: Attempting to execute the command "/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: C:\ Drive Space\nHost: BES/WHD Server\nAddress: xxx.xxx.xx.xx\nState: WARNING\n\nDate/Time: Fri Nov 12 10:02:56 GMT 2010\n\nAdditional Info:\n\nc:\ - total: 33.88 Gb - used: 28.64 Gb (85%) - free 5.24 Gb (15%)\n" | /bin/mail -s "** PROBLEM Service Alert: BES/WHD Server/C:\ Drive Space is WARNING **" ict@health.org.uk" resulted in a return code of 127. Make sure the script or binary you are trying to execute actually exists...

[12-11-2010 10:02:56] SERVICE NOTIFICATION: nagiosadmin;THFARES;C:\ Drive Space;WARNING;notify-service-by-email;c:\ - total: 33.88 Gb - used: 28.64 Gb (85%) - free 5.24 Gb (15%)

Any help would be greatly appreciated!!!  Lots of points up for grabs!
Thanks!
0
Comment
Question by:healthfoundation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 2
  • +1
18 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34119961
Seems that either /usr/bin/printf or /bin/mail do not exist.

Did you check this?

wmp
0
 

Author Comment

by:healthfoundation
ID: 34120038
I have now changed the /bin/mail to /usr/bin/mail.

I get don't seem to get any error in the nagios log now but emails still aren't coming through, any suggestions?

This is what I see in Nagios logs:

[12-11-2010 13:09:59] SERVICE NOTIFICATION: nagiosadmin;SERVERNAME;C:\ Drive Space;CRITICAL;notify-service-by-email;c:\ - total: 33.88 Gb - used: 30.77 Gb (91%) - free 3.11 Gb (9%)
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34120386
Does mail work from command line?

Does the user nagiosadmin exist, can he receive emails sent from command line?

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:healthfoundation
ID: 34120488
How do i send an email from the command line?
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
ID: 34120568
# mail -s “Hello world” you@youremailid.com
some more help in the below link:
http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/

-> Check the contact definition for nagiosadmin user make sure he has valid email id
-> make sure your email (or) relay server is configured correctly
-> make sure your mail server service is up and running.
0
 
LVL 18

Expert Comment

by:Sanga Collins
ID: 34120571
instead of using the command 'mail' to send messages, try using 'mailx' instead


command_line      /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
0
 
LVL 14

Expert Comment

by:Deepak Kosaraju
ID: 34120580
I don't think mailx comes a default package!
0
 
LVL 18

Expert Comment

by:Sanga Collins
ID: 34120629
it can be installed ... and i know it works for me :)
0
 

Author Comment

by:healthfoundation
ID: 34120633
kosarajudeepak I tried your email and I didnt get any errors back in the command line, and I didnt get an email into my inbox...?

Ways I can trouble should this anyone?
0
 

Author Comment

by:healthfoundation
ID: 34120639
sangamc can you provide any help troubleshooting this?
0
 

Author Comment

by:healthfoundation
ID: 34120705
When sending the email I notice the mail service/executable pops up in the resource list and then disappears...  Not sure if thats right or wrong?  Could it be our exchange?
0
 
LVL 18

Expert Comment

by:Sanga Collins
ID: 34120813
a couple of things you can do. the first is open a new console window on the nagios server and navigate to the logs directory. this is usually /var/logs/. find the maillog file and use this command to start monitoring it

tail -f /var/log/maillog

then in another console window you are going to run the mail command to see if it actually sends mail out or generates error messages in the maillog.

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: TEST\nHost: TEST \nState: TEST\nAddress: TEST\nInfo: TEST\n\nDate/Time: TEST\n" | mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" sanga.collins@gmail.com


when i run this command, this is what i get in my gmail
From: root
to: me
      
show details 9:34 AM (8 minutes ago)
      
***** Nagios *****

Notification Type: TEST
Host: TEST
State: TEST
Address: TEST
Info: TEST

Date/Time: TEST


and in my maillog this is what i get.

Nov 12 09:34:35 cs sendmail[6325]: oACEYYfm006325: from=<root@cs.mgt06m.itm>, size=467, class=0, nrcpts=1, msgid=<201011121434.oACEYYio006324@cs.mgt06m.itm>, proto=ESMTP, daemon=MTA, relay=cs.mgt06m.itm [127.0.0.1]
Nov 12 09:34:35 cs sendmail[6324]: oACEYYio006324: to=sanga.collins@gmail.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30188, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (oACEYYfm006325 Message accepted for delivery)
Nov 12 09:34:36 cs sendmail[6327]: oACEYYfm006325: to=<sanga.collins@gmail.com>, ctladdr=<root@cs.mgt06m.itm> (0/0), delay=00:00:02, xdelay=00:00:01, mailer=esmtp, pri=120467, relay=gmail-smtp-in.l.google.com. [74.125.45.27], dsn=2.0.0, stat=Sent (OK 1289572976 h28si8008615yha.0)
0
 

Author Comment

by:healthfoundation
ID: 34121688
Right I've looked at my log and this is basically what I am getting:

root@THF0091:/var/log# tail -f /var/log/mail.log Nov 12 14:49:19 THF0091 postfix/smtp[5388]: 51A9B81C9F: to=<aname@hotmail.co.uk>, relay=none, delay=332, delays=332/0.03/0/0, dsn=4.4.1, status=deferred (connect to mx2.hotmail.com[65.54.188.94]:25: Connection refused)

Nov 12 14:49:19 THF0091 postfix/smtp[5386]: 5977881B6E: to=<aname@health.org.uk>, relay=none, delay=8860, delays=8860/0.03/0/0, dsn=4.4.1, status=deferred (connect to health.org.uk[xxx.xx.xx.x]:25: Connection refused)

The first statement is being refused by Hotmail.  Is that correct?
The second statement is looking up our email domain health.org.uk and finding our website IP address rather than our internal exchange server...

Next steps please experts???
0
 
LVL 18

Expert Comment

by:Sanga Collins
ID: 34121711
Are you using your exchange server to relay the messages?
0
 

Author Comment

by:healthfoundation
ID: 34121732
Err yes.  Sent straight from Nagios on Ubuntu to MS Exchnage 2007 on the same subnet then into my domain mailbox that is held on the Exchange 2007 server.
0
 
LVL 18

Accepted Solution

by:
Sanga Collins earned 2000 total points
ID: 34121801
In your exchange server please make sure the nagios server ip address is on the list of IP's that are allow relay permissions.

Also in your postfix config double check that the ip or hostname of the exchange server is indeed the correct setting configured for relay.

0
 

Author Comment

by:healthfoundation
ID: 34122224
Yessssssssssssssssss! Top man. Done, should of really know that.  Thanks! Top Points!
0
 
LVL 18

Expert Comment

by:Sanga Collins
ID: 34122246
Glad to be of service
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Is your computer hacked? learn how to detect and delete malware in your PC
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question