Page 1 of 1

Email Notification Not Working.

Posted: Mon Sep 04, 2017 7:22 am
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

Re: Email Notification Not Working.

Posted: Tue Sep 05, 2017 8:32 am
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

Re: Email Notification Not Working.

Posted: Tue Sep 05, 2017 12:37 pm
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.

Re: Email Notification Not Working.

Posted: Tue Sep 05, 2017 1:41 pm
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