Email Notification Not Working.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rameshonline81
Posts: 3
Joined: Mon Apr 17, 2017 1:33 am

Email Notification Not Working.

Post by rameshonline81 »

Hello Everyone,

We have installed Nagios Core 4.2.0 and for some reason our emails notifications are not working. It was working until 3 days ago however post migration ( now that everything is in production) email notification are not working.
We are using mutt in order to send emails.
If I try to run this command

Code: Select all

echo " Test" | /usr/bin/mutt -s "test" myemailaddress
I am able to receive email this way.
However email sent from Nagios are not coming in.

Contact.cfg

Code: Select all


define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user
        email                           myemailaddress   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }
Output of /var/log/messages

Code: Select all

Sep  4 17:42:27 sdlmonitor2 nagios: SERVICE NOTIFICATION: nagiosadmin;18.11;Logged-In Users;WARNING;notify-service-by-email;USERS WARNING - 8 users currently logged in
Sep  4 17:43:27 sdlmonitor2 nagios: Warning: Return code of 127 for check of service 'HTTP' on host 'localhost' was out of bounds. Make sure the plugin you're trying to run actually exists.
Sep  4 17:45:57 sdlmonitor2 nagios: SERVICE NOTIFICATION: nagiosadmin;148.12;check_RELIANCE;CRITICAL;notify-service-by-email;CHECK_NRPE: Socket timeout after 10 seconds.
Sep  4 17:47:27 sdlmonitor2 nagios: SERVICE NOTIFICATION: nagiosadmin;18.11;Logged-In Users;WARNING;notify-service-by-email;USERS WARNING - 8 users currently logged in
Sep  4 17:48:27 sdlmonitor2 nagios: Warning: Return code of 127 for check of service 'HTTP' on host 'localhost' was out of bounds. Make sure the plugin you're trying to run actually exists.
/var/log/maillog is empty.

Any help would be much appreciated.

Thanks

Ramesh Kumar
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Email Notification Not Working.

Post by scottwilkerson »

We would need to see the generic-contact template configuration, and if it hasn't been changed form the defaults the commands for
notify-host-by-email
notify-service-by-email

These are likely what need to be changed to use the /usr/bin/mutt command

Then nagios restarted
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
DiegoAnjos
Posts: 49
Joined: Thu Feb 14, 2013 9:32 am

Re: Email Notification Not Working.

Post by DiegoAnjos »

Check if the path on commands.cfg is correct:

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/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

As far as I know, this path can vary depending on which distribution you are using.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Email Notification Not Working.

Post by scottwilkerson »

DiegoAnjos wrote:Check if the path on commands.cfg is correct:

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/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

As far as I know, this path can vary depending on which distribution you are using.
Right I think the OP wants to replace /usr/bin/mailx -s with /usr/bin/mutt -s
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked