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