Email Notifications not working
Email Notifications not working
Hello,
Email notifications are not working in nagios core during the host status change. I am using nagios core 4.0.8 with sendmail configured on Centos 6.6
1)Through command line I am able to send mails through root user but from nagios user I am unable to send.
2)In /var/log/messages I can see Host and Service Alerts.
3)In nagios.log I can see Host and Service Alerts.
appreciate if any one can guide me.
Email notifications are not working in nagios core during the host status change. I am using nagios core 4.0.8 with sendmail configured on Centos 6.6
1)Through command line I am able to send mails through root user but from nagios user I am unable to send.
2)In /var/log/messages I can see Host and Service Alerts.
3)In nagios.log I can see Host and Service Alerts.
appreciate if any one can guide me.
Re: Email Notifications not working
Try to send an email for the nagios user and then post the errors.
Also, check the maillog for any other hints:
Also, check the maillog for any other hints:
Code: Select all
tail -25 /var/log/maillogFormer Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
- mgaribaldi
- Posts: 26
- Joined: Thu Nov 06, 2014 1:58 pm
Re: Email Notifications not working
Have notifications worked before?
Doing what abrist suggested will help us see what is going on. Looking at the maillog and your nagios.log will give us more clues.
In nagios.log, do you see the host change to a HARD state with an email notification log following?
You also might want to check if any email is getting stuck in your spam filter or junk folder in your inbox.
Try sending to multiple email accounts also (yahoo, gmail, etc).
Let us know! Thank you.
Doing what abrist suggested will help us see what is going on. Looking at the maillog and your nagios.log will give us more clues.
In nagios.log, do you see the host change to a HARD state with an email notification log following?
You also might want to check if any email is getting stuck in your spam filter or junk folder in your inbox.
Try sending to multiple email accounts also (yahoo, gmail, etc).
Let us know! Thank you.
"We all float down here...."
-Pennywise
-Pennywise
Re: Email Notifications not working
This a fresh installation
1)Nagios.log
[root@localhost var]# tail -f nagios.log
[1421856242] SERVICE ALERT: google;PING;CRITICAL;SOFT;1;PING CRITICAL - Packet loss = 100%
[1421856270] HOST ALERT: google;DOWN;SOFT;1;PING CRITICAL - Packet loss = 100%
[1421856302] SERVICE ALERT: google;PING;CRITICAL;SOFT;2;PING CRITICAL - Packet loss = 100%
[1421856332] wproc: Core Worker 8288: job 4 (pid=8401) timed out. Killing it
[1421856332] wproc: CHECK job 4 from worker Core Worker 8288 timed out after 30.01s
[1421856332] wproc: host=google; service=(null);
[1421856332] wproc: early_timeout=1; exited_ok=0; wait_status=0; error_code=62;
[1421856332] Warning: Check of host 'google' timed out after 30.01 seconds
[1421856332] HOST ALERT: google;DOWN;SOFT;2;(Host check timed out after 30.01 seconds)
[1421856332] wproc: Core Worker 8288: job 4 (pid=8401): Dormant child reaped
[1421856362] SERVICE ALERT: google;PING;CRITICAL;SOFT;3;PING CRITICAL - Packet loss = 100%
[1421856392] HOST ALERT: google;DOWN;SOFT;3;PING CRITICAL - Packet loss = 100%
[1421856422] SERVICE ALERT: google;PING;CRITICAL;HARD;4;PING CRITICAL - Packet loss = 100%
[1421856452] HOST ALERT: google;DOWN;SOFT;4;PING CRITICAL - Packet loss = 100%
[1421856542] HOST ALERT: google;DOWN;SOFT;5;PING CRITICAL - Packet loss = 100%
[1421856632] HOST ALERT: google;DOWN;SOFT;6;PING CRITICAL - Packet loss = 100%
[1421856722] HOST ALERT: google;DOWN;SOFT;7;PING CRITICAL - Packet loss = 100%
[1421856752] HOST ALERT: google;DOWN;SOFT;8;PING CRITICAL - Packet loss = 100%
[1421856842] HOST ALERT: google;DOWN;SOFT;9;PING CRITICAL - Packet loss = 100%
[1421856932] HOST ALERT: google;DOWN;HARD;10;PING CRITICAL - Packet loss = 100%
2)Maillog
Its empty nothing been captured
When I send mail from nagios user to gmail account the log from maillog is as follows:
[root@localhost log]# tail -f maillog
Jan 21 19:10:22 localhost sendmail[8459]: t0LG92KN008459: from=nagios, size=219, class=0, nrcpts=1, msgid=<[email protected]>, relay=nagios@localhost
Jan 21 19:10:22 localhost sendmail[8459]: t0LG92KN008459: to=[email protected], delay=00:01:20, mailer=esmtp, pri=30219, dsn=4.4.3, stat=queued
1)Nagios.log
[root@localhost var]# tail -f nagios.log
[1421856242] SERVICE ALERT: google;PING;CRITICAL;SOFT;1;PING CRITICAL - Packet loss = 100%
[1421856270] HOST ALERT: google;DOWN;SOFT;1;PING CRITICAL - Packet loss = 100%
[1421856302] SERVICE ALERT: google;PING;CRITICAL;SOFT;2;PING CRITICAL - Packet loss = 100%
[1421856332] wproc: Core Worker 8288: job 4 (pid=8401) timed out. Killing it
[1421856332] wproc: CHECK job 4 from worker Core Worker 8288 timed out after 30.01s
[1421856332] wproc: host=google; service=(null);
[1421856332] wproc: early_timeout=1; exited_ok=0; wait_status=0; error_code=62;
[1421856332] Warning: Check of host 'google' timed out after 30.01 seconds
[1421856332] HOST ALERT: google;DOWN;SOFT;2;(Host check timed out after 30.01 seconds)
[1421856332] wproc: Core Worker 8288: job 4 (pid=8401): Dormant child reaped
[1421856362] SERVICE ALERT: google;PING;CRITICAL;SOFT;3;PING CRITICAL - Packet loss = 100%
[1421856392] HOST ALERT: google;DOWN;SOFT;3;PING CRITICAL - Packet loss = 100%
[1421856422] SERVICE ALERT: google;PING;CRITICAL;HARD;4;PING CRITICAL - Packet loss = 100%
[1421856452] HOST ALERT: google;DOWN;SOFT;4;PING CRITICAL - Packet loss = 100%
[1421856542] HOST ALERT: google;DOWN;SOFT;5;PING CRITICAL - Packet loss = 100%
[1421856632] HOST ALERT: google;DOWN;SOFT;6;PING CRITICAL - Packet loss = 100%
[1421856722] HOST ALERT: google;DOWN;SOFT;7;PING CRITICAL - Packet loss = 100%
[1421856752] HOST ALERT: google;DOWN;SOFT;8;PING CRITICAL - Packet loss = 100%
[1421856842] HOST ALERT: google;DOWN;SOFT;9;PING CRITICAL - Packet loss = 100%
[1421856932] HOST ALERT: google;DOWN;HARD;10;PING CRITICAL - Packet loss = 100%
2)Maillog
Its empty nothing been captured
When I send mail from nagios user to gmail account the log from maillog is as follows:
[root@localhost log]# tail -f maillog
Jan 21 19:10:22 localhost sendmail[8459]: t0LG92KN008459: from=nagios, size=219, class=0, nrcpts=1, msgid=<[email protected]>, relay=nagios@localhost
Jan 21 19:10:22 localhost sendmail[8459]: t0LG92KN008459: to=[email protected], delay=00:01:20, mailer=esmtp, pri=30219, dsn=4.4.3, stat=queued
Re: Email Notifications not working
Problem: Nagios mail notification not working
Configuration: nagios core 4.0.8, Centos 6.6, Sendmail(MTA)
Step1:Followed installation documentation from site and installed fresh setup. Did not receive any errors during installation.
Step2:Gave my mail address in contacts.cfg file so i receive notifications.
Step3:Added a windows host successfully with default windows.cfg and also the status is shown up in web interface.
Step4: I disconnection network for windows machine and also could see host and service alerts in nagios.log and web interface also the host status is down but did not receive any notifications to my mail account upon checking found there is not any trace of mail in maillog.
Note: Hostname is localhost
My side troubleshooting:
1)Tried to send mail from terminal using root user to my mail account and I received mail and also can see maillog writting logs.
2)Now, Tried sending mail using nagios user and no sign in maillog and also did not receive mail to my mail id.
3)Changed /bin/mail to /usr/sbin/sendmail in command.cfg for host and service notification and still no luck.
Want to know two things here how can we cross check if notification are generated by nagios and second how can we cross check if these notifications are triggered as mail.
Configuration: nagios core 4.0.8, Centos 6.6, Sendmail(MTA)
Step1:Followed installation documentation from site and installed fresh setup. Did not receive any errors during installation.
Step2:Gave my mail address in contacts.cfg file so i receive notifications.
Step3:Added a windows host successfully with default windows.cfg and also the status is shown up in web interface.
Step4: I disconnection network for windows machine and also could see host and service alerts in nagios.log and web interface also the host status is down but did not receive any notifications to my mail account upon checking found there is not any trace of mail in maillog.
Note: Hostname is localhost
My side troubleshooting:
1)Tried to send mail from terminal using root user to my mail account and I received mail and also can see maillog writting logs.
2)Now, Tried sending mail using nagios user and no sign in maillog and also did not receive mail to my mail id.
3)Changed /bin/mail to /usr/sbin/sendmail in command.cfg for host and service notification and still no luck.
Want to know two things here how can we cross check if notification are generated by nagios and second how can we cross check if these notifications are triggered as mail.
- mgaribaldi
- Posts: 26
- Joined: Thu Nov 06, 2014 1:58 pm
Re: Email Notifications not working
Thank you for the answers.
and then use the same mail commands as you did when you were root?
Can you provide relevant host, service, contacts and command config files?
Thank you.
Did you do a2) Now, Tried sending mail using nagios user and no sign in maillog and also did not receive mail to my mail id.
Code: Select all
su - nagiosCan you provide relevant host, service, contacts and command config files?
Thank you.
"We all float down here...."
-Pennywise
-Pennywise
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Email Notifications not working
Thank you for the help @mgaribaldi, OP, let us know what you've got, thanks!
Re: Email Notifications not working
1)When sending mail as nagios user
A)How mail is sent
[root@localhost ~]# su nagios
[nagios@localhost root]$ mail [email protected]
Subject: test
.
EOT
Null message body; hope that's ok
[nagios@localhost root]$
B)Maillog content
[root@localhost log]# tail -f maillog
Jan 22 08:45:16 localhost sendmail[14914]: t0M5huO3014914: from=nagios, size=226, class=0, nrcpts=1, msgid=<[email protected]>, relay=nagios@localhost
Jan 22 08:45:16 localhost sendmail[14914]: t0M5huO3014914: to=[email protected], delay=00:01:20, mailer=esmtp, pri=30226, dsn=4.4.3, stat=queued
Jan 22 08:53:52 localhost sendmail[14987]: t0M5rpLd014987: from=<[email protected]>, size=486, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jan 22 08:53:52 localhost sm-msp-queue[14980]: t0M5huO3014914: to=[email protected], ctladdr=nagios (501/501), delay=00:09:56, xdelay=00:00:01, mailer=relay, pri=120226, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t0M5rpLd014987 Message accepted for delivery)
Jan 22 08:53:59 localhost sendmail[14989]: t0M5rpLd014987: to=<[email protected]>, ctladdr=<[email protected]> (501/501), delay=00:00:07, xdelay=00:00:07, mailer=esmtp, pri=120486, relay=mail.company.com. [186.22.32.22], dsn=5.1.1, stat=User unknown
Jan 22 08:53:59 localhost sendmail[14989]: t0M5rpLd014987: t0M5rxLd014989: DSN: User unknown
Jan 22 08:53:59 localhost sendmail[14989]: t0M5rxLd014989: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31710, dsn=2.0.0, stat=Sent
2)When sending mail as root user
A)How mail is sent
[root@localhost ~]# mail [email protected]
Subject: test
.
EOT
Null message body; hope that's ok
B)Maillog content
[root@localhost ~]#
[root@localhost log]# tail -f maillog
Jan 22 09:21:02 localhost sendmail[15206]: t0M6L1Bn015206: from=root, size=226, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Jan 22 09:21:02 localhost sendmail[15208]: t0M6L2i4015208: from=<[email protected]>, size=489, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jan 22 09:21:02 localhost sendmail[15206]: t0M6L1Bn015206: to=[email protected], ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30226, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t0M6L2i4015208 Message accepted for delivery)
Jan 22 09:21:04 localhost sendmail[15210]: t0M6L2i4015208: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=120489, relay=mail.company.com. [186.22.32.22], dsn=2.0.0, stat=Sent (OK id=1YEB7i-0008KX-Nb)
Note:
1)Here I received mail sent by root user and did not receive mail sent by nagios user.
2)I replaced my original mail ID with [email protected] and smtp as mail.company.com and also mail server IP in the above for security reasons.
Please find attachments for configuration files, Servers.cfg is the host file
A)How mail is sent
[root@localhost ~]# su nagios
[nagios@localhost root]$ mail [email protected]
Subject: test
.
EOT
Null message body; hope that's ok
[nagios@localhost root]$
B)Maillog content
[root@localhost log]# tail -f maillog
Jan 22 08:45:16 localhost sendmail[14914]: t0M5huO3014914: from=nagios, size=226, class=0, nrcpts=1, msgid=<[email protected]>, relay=nagios@localhost
Jan 22 08:45:16 localhost sendmail[14914]: t0M5huO3014914: to=[email protected], delay=00:01:20, mailer=esmtp, pri=30226, dsn=4.4.3, stat=queued
Jan 22 08:53:52 localhost sendmail[14987]: t0M5rpLd014987: from=<[email protected]>, size=486, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jan 22 08:53:52 localhost sm-msp-queue[14980]: t0M5huO3014914: to=[email protected], ctladdr=nagios (501/501), delay=00:09:56, xdelay=00:00:01, mailer=relay, pri=120226, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t0M5rpLd014987 Message accepted for delivery)
Jan 22 08:53:59 localhost sendmail[14989]: t0M5rpLd014987: to=<[email protected]>, ctladdr=<[email protected]> (501/501), delay=00:00:07, xdelay=00:00:07, mailer=esmtp, pri=120486, relay=mail.company.com. [186.22.32.22], dsn=5.1.1, stat=User unknown
Jan 22 08:53:59 localhost sendmail[14989]: t0M5rpLd014987: t0M5rxLd014989: DSN: User unknown
Jan 22 08:53:59 localhost sendmail[14989]: t0M5rxLd014989: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31710, dsn=2.0.0, stat=Sent
2)When sending mail as root user
A)How mail is sent
[root@localhost ~]# mail [email protected]
Subject: test
.
EOT
Null message body; hope that's ok
B)Maillog content
[root@localhost ~]#
[root@localhost log]# tail -f maillog
Jan 22 09:21:02 localhost sendmail[15206]: t0M6L1Bn015206: from=root, size=226, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Jan 22 09:21:02 localhost sendmail[15208]: t0M6L2i4015208: from=<[email protected]>, size=489, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jan 22 09:21:02 localhost sendmail[15206]: t0M6L1Bn015206: to=[email protected], ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30226, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t0M6L2i4015208 Message accepted for delivery)
Jan 22 09:21:04 localhost sendmail[15210]: t0M6L2i4015208: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=120489, relay=mail.company.com. [186.22.32.22], dsn=2.0.0, stat=Sent (OK id=1YEB7i-0008KX-Nb)
Note:
1)Here I received mail sent by root user and did not receive mail sent by nagios user.
2)I replaced my original mail ID with [email protected] and smtp as mail.company.com and also mail server IP in the above for security reasons.
Please find attachments for configuration files, Servers.cfg is the host file
- Attachments
-
contacts.cfg- (2.09 KiB) Downloaded 1233 times
-
nagios.cfg- (43.53 KiB) Downloaded 1021 times
-
commands.cfg- (7.52 KiB) Downloaded 1142 times
Re: Email Notifications not working
Here are my missing configuration files in the attachments
- Attachments
-
templates.cfg- (10.37 KiB) Downloaded 953 times
-
servers.cfg- host file
- (3.89 KiB) Downloaded 939 times
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Email Notifications not working
your notification commands are missing a / before "usr/sbin/sendmail", however based on above, I'd change:
to
Code: Select all
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | usr/sbin/sendmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | usr/sbin/sendmail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}Code: Select all
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}