Page 1 of 1

Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITICAL1

Posted: Wed Feb 03, 2021 12:08 pm
by MonitorGuy
We have a custom script to manage service notifications (i.e. only send epage when host is in "Prod" and severity is "Critical") and a few other requirements.

Command line:

$USER1$/notify-service.sh "$SERVICESTATE$" "$LASTSERVICESTATE$" "$NOTIFICATIONTYPE$" "$SERVICEDESC$" "$HOSTALIAS$" "$HOSTNAME$" "$HOSTADDRESS$" "$SERVICEOUTPUT$" "$CONTACTEMAIL$" "$CONTACTPAGER$" "$NOTIFICATIONCOMMENT$"

Issue: Output of $NOTIFICATIONCOMMENT$ = CRITICAL1 when alerts are ACKNOWLEDGED

Example:

***** Nagios XI - Prod *****

Notification Type: ACKNOWLEDGEMENT

Service: MSSQL Memory Usage - Test \State: CRITICAL
Host: hostname \Device: Windows_SQL_VIP_Prod
Info: (Service check timed out after 60.01 seconds)

Date/Time: Wed Feb 3 11:43:33 EST 2021

Comment: CRITICAL1

From what I've found, the older *ACKCOMMENT macro/variables are depreciated?

Looking for the output from what gets entered as reason/comment for alert acknowledgement to include in the email notifications.

Do I have the correct macro/variable for this purpose?

What am I missing?

Thanks!

Re: Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITIC

Posted: Thu Feb 04, 2021 3:34 pm
by cdienger
Arguments 10 and above used in the script must use {} around the number. I used this as a test and it worked:

Code: Select all

echo "service state: $1" >> /usr/local/nagios/libexec/test.txt
echo "lastservicestate: $2" >> /usr/local/nagios/libexec/test.txt
echo "notificationtype: $3" >> /usr/local/nagios/libexec/test.txt
echo "servicedesc: $4" >> /usr/local/nagios/libexec/test.txt
echo "hostalias: $5" >> /usr/local/nagios/libexec/test.txt
echo "hostname: $6" >> /usr/local/nagios/libexec/test.txt
echo "hostaddress: $7" >> /usr/local/nagios/libexec/test.txt
echo "serviceoutput: $8" >> /usr/local/nagios/libexec/test.txt
echo "contactemail: $9" >> /usr/local/nagios/libexec/test.txt
echo "contactpager: ${10}" >> /usr/local/nagios/libexec/test.txt
echo "notificationcomment: ${11}" >> /usr/local/nagios/libexec/test.txt

Re: Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITIC

Posted: Thu Feb 04, 2021 4:46 pm
by MonitorGuy
Awesome, thanks!

Adding brackets to the additional variable number did the trick! ${11}

Example:

***** Nagios XI - Prod *****

Notification Type: ACKNOWLEDGEMENT

Service: MSSQL Memory Usage - Test \State: CRITICAL
Host: server.domain \Device: Windows_SQL_VIP_Prod
Info: (Service check timed out after 60.01 seconds)

Date/Time: Thu Feb 4 16:34:06 EST 2021

Comment: Problem has been acknowledged

-----

I always thought the brackets were needed because of special chars in the incoming data, good to know...

Keep on monitoring!

Re: Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITIC

Posted: Fri Feb 05, 2021 11:00 am
by cdienger
Glad to help!