Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1982
  • Last Modified:

Nagios Email Notifications! HELP!

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
healthfoundation
Asked:
healthfoundation
  • 8
  • 6
  • 2
  • +1
1 Solution
 
woolmilkporcCommented:
Seems that either /usr/bin/printf or /bin/mail do not exist.

Did you check this?

wmp
0
 
healthfoundationAuthor Commented:
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
 
woolmilkporcCommented:
Does mail work from command line?

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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
healthfoundationAuthor Commented:
How do i send an email from the command line?
0
 
Deepak KosarajuCommented:
# 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
 
Sanga CollinsSystems AdminCommented:
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
 
Deepak KosarajuCommented:
I don't think mailx comes a default package!
0
 
Sanga CollinsSystems AdminCommented:
it can be installed ... and i know it works for me :)
0
 
healthfoundationAuthor Commented:
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
 
healthfoundationAuthor Commented:
sangamc can you provide any help troubleshooting this?
0
 
healthfoundationAuthor Commented:
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
 
Sanga CollinsSystems AdminCommented:
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
 
healthfoundationAuthor Commented:
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
 
Sanga CollinsSystems AdminCommented:
Are you using your exchange server to relay the messages?
0
 
healthfoundationAuthor Commented:
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
 
Sanga CollinsSystems AdminCommented:
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
 
healthfoundationAuthor Commented:
Yessssssssssssssssss! Top man. Done, should of really know that.  Thanks! Top Points!
0
 
Sanga CollinsSystems AdminCommented:
Glad to be of service
0

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

  • 8
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now