Nagios email notifications.

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.
spiderpig82
Posts: 22
Joined: Wed Aug 27, 2014 7:29 am

Re: Nagios email notifications.

Post by spiderpig82 »

:)

in command.cfg

#'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$ **" myemail@company -- -f from@email
}

#'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$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" my@email -- -f from@email
}

example from nagios.log


[1427144964] SERVICE NOTIFICATION: nagiosadmin;rk-websenselog01.local;Running S ervices;WARNING;notify-service-by-email;CRITICAL: pgsqlEIP: stopped (critical)
[1427146094] SERVICE NOTIFICATION: nagiosadmin;rk-terminal01.local;Running Serv ices;WARNING;notify-service-by-email;CRITICAL: TrustedInstaller: stopped (critical)
[1427147674] SERVICE NOTIFICATION: nagiosadmin;triton.local;Running Services;WA RNING;notify-service-by-email;CRITICAL: NSClient: stopped (critical)
[1427147954] SERVICE NOTIFICATION: nagiosadmin;triton.local;Reverse Lookup;CRIT ICAL;notify-service-by-email;DNS CRITICAL - expected triton.local. but got nsfs t.local.,triton.local.
[1427148564] SERVICE NOTIFICATION: nagiosadmin;rk-websenselog01.local;Running S ervices;WARNING;notify-service-by-email;CRITICAL: pgsqlEIP: stopped (critical)
[1427149694] SERVICE NOTIFICATION: nagiosadmin;rk-terminal01.local;Running Serv ices;WARNING;notify-service-by-email;CRITICAL: TrustedInstaller: stopped (critical)
[1427151274] SERVICE NOTIFICATION: nagiosadmin;triton.local;Running Services;WA RNING;notify-service-by-email;CRITICAL: NSClient: stopped (critical)
[1427151554] SERVICE NOTIFICATION: nagiosadmin;triton.local;Reverse Lookup;CRIT ICAL;notify-service-by-email;DNS CRITICAL - expected triton.local. but got nsfs t.local.,triton.local.
spiderpig82
Posts: 22
Joined: Wed Aug 27, 2014 7:29 am

Re: Nagios email notifications.

Post by spiderpig82 »

i replaced the 'notify-host-by-email' command definition and notify-service-by-email' command definition in command.cfg, and then suddenl it worked :) it was some bug in the syntax.

but now i have another issue, -- -f from@email doesent work.

any ideas why?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios email notifications.

Post by jdalrymple »

Potentially Exchange is rewriting the from - I know Exchange isn't a big fan of letting you masquerade the *real* from, in this case [email protected]. You did say you're relaying through Exchange correct?
Locked