Ok, so we want to add a custom notification variable to our alerts. We can do it and it works great. This variable is to let our Service Desk know if a host in Windows or Linux to help tickets get assigned to proper queues. Our Windows hosts is a much lower number, so adding the custom variable to those ~140 hosts is what we'll do first and maybe not ever set it on the linux hosts. My issue is, if we set it up it works great, but for hosts we don't set the custom variable on, where we put it in the notification messages there is a "$"
Is there a way to suppress the $ when a variable is empty, is that a bug or is that intended?
Custom notification variables
Custom notification variables
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: Custom notification variables
I am not sure if this "qualifies" as a bug. It is not intended for sure...Is there a way to suppress the $ when a variable is empty, is that a bug or is that intended?
I would like to point out that you will see the text in the notification anyway:
Text: Value //when defined
Text: $ // when is not defined
There could be a way to modify the notification handler command with a bash "one liner", which will verify if the macro is set or not. For example:
if set - display the value
if not - display nothing or display something like "not set".
I haven't tested this but I am curious to see if this is going to work. Seeing one extra "$" in the notifications is not a big deal anyway, but if you are like me, I am sure you are annoyed by it.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Custom notification variables
Umm...ok, I'll give it to you that unintended doesn't always = bug, lol.lmiltchev wrote:I am not sure if this "qualifies" as a bug. It is not intended for sure...
I'm very interested in this modification to notification command using to test if it is filled in. You more or less mean like a wrapper script, right? I think that'd be totally doable. I'm going to play around with it also!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: Custom notification variables
Gonna swat this off our dashboard for now. Unintended behavior Bug us again after the weekend.
Former Nagios employee
Re: Custom notification variables
HAHAHA...sorry for putting back on the dashboard, but I got ittmcdonald wrote:Gonna swat this off our dashboard for now. Unintended behavior Bug us again after the weekend.
Notification command is now this:
Code: Select all
/usr/local/nagios/libexec/not_wrapper_service.sh service "$CONTACTNAME$" "$CONTACTEMAIL$" $NOTIFICATIONTYPE$ "$NOTIFICATIONISESCALATED$" "$NOTIFICATIONAUTHOR$" "$NOTIFICATIONCOMMENT$" "$HOSTNAME$" "$HOSTADDRESS$" "$HOSTALIAS$" "$HOSTDISPLAYNAME$" "$SERVICEDESC$" $HOSTSTATE$ $HOSTSTATEID$ $SERVICESTATE$ $SERVICESTATEID$ $LASTSERVICESTATE$ $LASTSERVICESTATEID$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $MAXSERVICEATTEMPTS$ $SERVICEEVENTID$ $SERVICEPROBLEMID$ "$SERVICEOUTPUT$" "$LONGSERVICEOUTPUT$" "$LONGDATETIME$" "$_HOSTPROD$" "$_HOSTOSTYPE$"Code: Select all
#!/bin/bash
#
# XI Notification handler Wrapper to populate unset custom variables
#
#/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --prod="$_HOSTPROD$" --ostype="$_HOSTOSTYPE$"
#
if [ "${28}" == "$" ]; then
os="--ostype=\"Not defined\""
else
os="--ostype=\"${28}\""
fi
command="/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=\"$1\" --contact=\"$2\" --contactemail=\"$3\" --type=$4 --escalated=\"$5\" --author=\"$6\" --comments=\"$7\" --host=\"$8\" --hostaddress=\"$9\" --hostalias=\"${10}\" --hostdisplayname=\"${11}\" --service=\"${12}\" --hoststate=${13} --hoststateid=${14} --servicestate=${15} --servicestateid=${16} --lastservicestate=${17} --lastservicestateid=${18} --servicestatetype=${19} --currentattempt=${20} --maxattempts=${21} --serviceeventid=${22} --serviceproblemid=${23} --serviceoutput=\"${24}\" --longserviceoutput=\"${25}\" --datetime=\"${26}\" --prod=\"${27}\" $os"
eval $command
exit 0
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Re: Custom notification variables
*swat* Go away :)BanditBBS wrote:HAHAHA...sorry for putting back on the dashboard, but I got it :)
I'll lock this now
Former Nagios employee