Solved

Nagios Email Notifications! HELP!

Posted on 2010-11-12
18
1,944 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

How to set-up an On Demand, IPSec, Site to SIte, VPN from a Draytek Vigor Router to a Cyberoam UTM Appliance. A concise guide to the settings required on both devices
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 how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Suggested Courses

636 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