Solved

Nagios Email Notifications! HELP!

Posted on 2010-11-12
18
1,892 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
  • 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now