Page 1 of 1

Free Vars, macros, and inheritence

Posted: Fri May 14, 2021 8:43 am
by gwakem
Nagios XI 5.8.1
RHEL 7.7

Good morning! If I have a service template that is applied to a service, and the sevice template maps two free variables as such:
_kb $SERVICENOTESURL$
_alert_number $SERVICENOTIFICATIONNUMBER$

In the command I have appended --kbarticle="$_SERVICEKB$" --alertnumber="$_SERVICEALERT_NUMBER$"

The notes url field is populated within the specific service check. Are those macros able to be parsed via the free variables, and pulled in through the template to pick up the specific URL in the service and the notification number when sending an email alert? I was trying to use the free vars in the service template so I could simply populate the notes url field in the service check itself and have that URL end up in the emailed alert.

Currently with this setup, the alert is still coming across with the %kb% and %alertnumber% free vars in the emailed alert, like so:

Additional Info: WARNING - md5sum is not in list. Adding for you now.
Notifications sent: %alertnumber%
KB Article: %kbarticle%

Am I missing something, or is there a better way to handle this?

Re: Free Vars, macros, and inheritence

Posted: Mon May 17, 2021 6:34 am
by gwakem
It looks like this may have been missed Friday, any ideas?

Re: Free Vars, macros, and inheritence

Posted: Mon May 17, 2021 10:34 am
by lmiltchev
You don't need to use a template in this case. Simply append the following to the end of your notification command:

Code: Select all

--alertnumber="$SERVICENOTIFICATIONNUMBER$" --notesurl="$SERVICENOTESURL$"
Save and apply configuration. The notesurl will be "picked up" from each service if you have one added.

Also, make sure you have the following in the "Service Alert Message" field (Account > Notification Options > Notification Messages):

Code: Select all

Notifications sent: %alertnumber%
KB Article: %notesurl%
Click on "Update Settings".

You should see something like this in your emails (example):
Notifications sent: 0
KB Article: https://support.nagios.com/kb/
Let us know if this helped.

Re: Free Vars, macros, and inheritence

Posted: Tue May 18, 2021 10:36 am
by gwakem
This did it. Thanks for your assistance! Lock away.

Re: Free Vars, macros, and inheritence

Posted: Tue May 18, 2021 3:56 pm
by lmiltchev
I am glad I could help! :D