Page 1 of 1
Not all Standard Macros working in Email Notifications
Posted: Wed Dec 19, 2018 5:14 pm
by justassi
Not all Standard Macros not working in Email Notifications:
Service Alert Message that I have:
***** Nagios XI Alert *****
%alertsummary%
Notification Type: %type%
Service: %service%
Host: %host%
Address: %hostaddress%
State: %servicestate%
Info:
%serviceoutput%
Date/Time: %datetime%
Confluence Documentation/Resolution:
%servicenotesurl%
%servicenotes%
Unfortunately these are being passed as plaintext and not converted:
Confluence Documentation/Resolution:
%servicenotesurl%
%servicenotes%
I have both Notes URL and Notes filled up under the failing Service. What am I missing?
Re: Not all Standard Macros working in Email Notifications
Posted: Wed Dec 19, 2018 5:44 pm
by lmiltchev
Did you follow the steps, outlined in this document?
https://assets.nagios.com/downloads/nag ... iables.pdf
These macros work fine for me. In my notification handler command I have:
Code: Select all
--notes="$SERVICENOTES$" --notesurl="$SERVICENOTESURL$"
In my notification messages, I have:
In the actual email, I get:
Code: Select all
This is a test note.
https://www.nagios.com
so the macros do resolve...
Can you show us your notification command?
Re: Not all Standard Macros working in Email Notifications
Posted: Wed Dec 19, 2018 8:34 pm
by justassi
Hello, lmiltchev
I'm not using custom macros - i want to use the default fields that are under Service -> Misc Settings -> Fields: Notes, Notes URL
Edit: The ones that you can see in my original notification are from here:
https://assets.nagios.com/downloads/nag ... olist.html
Re: Not all Standard Macros working in Email Notifications
Posted: Thu Dec 20, 2018 9:38 am
by mcapra
justassi wrote:Not all Standard Macros not working in Email Notifications
That's because not all of them are
included in the default Nagios XI notification handler.
Fortunately,
the documentation provided by
@lmiltchev solves this by augmenting that default notification handler with additional information. It's not only using custom macros; It's also using those same core macros you referenced and
passing them in to the default Nagios XI notification handler script, which will sub out the %var% values in the email template with the provided arguments in a generic fashion. In other words, those args are directly referenced when the templates %var% values are evaluated.
The documentation is not limited in scope to only custom variables/macros.
@lmiltchev's solution is the "cliff notes" version of that documentation for the specific thing you're attempting to do.
Re: Not all Standard Macros working in Email Notifications
Posted: Thu Dec 20, 2018 10:00 am
by lmiltchev
@mcapra, thanks for the clarification!
@justassi
I'm not using custom macros - i want to use the default fields that are under Service -> Misc Settings -> Fields: Notes, Notes URL
Neither am I. I was giving you an example with a similar setup. See below:
example01.PNG
Make sure the %var% names in your notifications messages
are the same as the ones in your notification command (as per our document).
Example:
example02.PNG
example03.PNG
Re: Not all Standard Macros working in Email Notifications
Posted: Tue Jan 22, 2019 5:17 pm
by justassi
Hello lmiltchev,
Thank you for your help.
When I add the suggested variables to the notification template:
Alert Notes: %notes%
Alert Documentation: %notesurl%
In my notification Service Alert Message I receive them exactly the same (as you see in the screenshot, not translated to the fields that are filled in the service configuration).
Am I forgetting to enable something?
Re: Not all Standard Macros working in Email Notifications
Posted: Tue Jan 22, 2019 5:49 pm
by npolovenko
@justassi, Did you append the following arguments to the end of the "xi_service_notification_handler" command?
--notes="$SERVICENOTES$" --notesurl="$SERVICENOTESURL$"
Did you restart the Core Configuration Manager afterward?
Lastly, please check what notification commands are used by the contact? If you open the contact in the CCM and go to the Alert Settings tab, you should see notification commands assigned under "Manage Host Notification Commands" and "Manage Service Notification Commands".
Re: Not all Standard Macros working in Email Notifications
Posted: Mon Feb 04, 2019 6:51 pm
by justassi
Thank you everyone for your help! It's working like a charm now after adding additional information to the "xi_service_notification_handler" command.
Re: Not all Standard Macros working in Email Notifications
Posted: Tue Feb 05, 2019 11:55 am
by scottwilkerson
justassi wrote:Thank you everyone for your help! It's working like a charm now after adding additional information to the "xi_service_notification_handler" command.
Excellent! Glad it is resolved!
Locking thread