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.
Asked
Active
Viewed 6,748 times
2 Answers
5
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.

quanta
- 51,413
- 19
- 159
- 217
-
Why put the URL in the service definition instead of the command definition? Seems like that's putting the same code in each service needlessly and the result is extra maintenance. Will I be shooting myself in the foot to just put it in the command definition? – flickerfly Apr 17 '17 at 15:56
2
You'd need to add a link to your alert script similar to what's below.
For services: http://your-nagios-server.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=$NAGIOS_HOSTNAME&service=$NAGIOS_SERVICEDESC
For hosts: http://your-nagios-server.example.com/nagios/cgi-bin/cmd.cgi?cmd_typ=33&host=$NAGIOS_HOSTNAME
What exactly needs to be done depends on your alert script's logic. Keep in mind that the Nagios UI uses frames and these links will only show the Acknowledgement form page without the Nagios navigation bar on the left.

JakePaulus
- 2,347
- 16
- 17