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!
Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITICAL1
- MonitorGuy
- Posts: 46
- Joined: Wed May 20, 2020 8:22 am
Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITICAL1
<<MonitorGuy>>
Re: Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITIC
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.txtAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
- MonitorGuy
- Posts: 46
- Joined: Wed May 20, 2020 8:22 am
Re: Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITIC
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!
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!
<<MonitorGuy>>
Re: Acknowledged alert $NOTIFICATIONCOMMENT$ output = CRITIC
Glad to help!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.