Adding a acknowledgement Link to Nagios Alert Emails

monitoringnagios

Has anyone ever added a link into the nagios alert messages that allows the receiver to just click the link to put the alert into the acknowledgement state. I've had a look around but cant see anything.

Best Answer

Add a notes_url into service definition:

notes_url           http://domain.com/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$SERVICEDESC$

And append the $SERVICENOTESURL$ macro to the end of alert message, in notify-service-by-email command, Eg:

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: $SERVICEOUTPUT$\n\nURL: $SERVICENOTESURL$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ 
    }

Do the same for host.