Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!

Nagios

Nagios Email Notifications with Comments

If you prefer more detail in the email notification of Nagios here is how to add those comments. For example someone acknowledging a service and you want to see the comment they added during acknowledgement.

# pwd
/usr/local/nagios/etc/objects
# more commands.cfg
[..]
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$\n\nACK Comment: $SERVICEACKCOMMENT$\n\nComment: $NOTIFICATIONCOMMENT$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

Note: I added $SERVICEACKCOMMENT$ and $NOTIFICATIONCOMMENT$ but I think in newer versions of Nagios $SERVICEACKCOMMENT$ is deprecated and you only need $NOTIFICATIONCOMMENT$.

Link: http://nagios.sourceforge.net/docs/3_0/macrolist.html

admin

Bio Info for Riaan