Page 2 of 2

Re: Nagios email notifications.

Posted: Mon Mar 23, 2015 6:09 pm
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.

Re: Nagios email notifications.

Posted: Tue Mar 24, 2015 5:38 am
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?

Re: Nagios email notifications.

Posted: Tue Mar 24, 2015 9:46 am
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?