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
# 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$.



Bio Info for Riaan