Not all Standard Macros working in Email Notifications

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
justassi
Posts: 4
Joined: Wed Dec 19, 2018 4:55 pm

Not all Standard Macros working in Email Notifications

Post 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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Not all Standard Macros working in Email Notifications

Post 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:

Code: Select all

%notes%
%notesurl%
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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
justassi
Posts: 4
Joined: Wed Dec 19, 2018 4:55 pm

Re: Not all Standard Macros working in Email Notifications

Post 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
You do not have the required permissions to view the files attached to this post.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Not all Standard Macros working in Email Notifications

Post 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.
Former Nagios employee
https://www.mcapra.com/
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Not all Standard Macros working in Email Notifications

Post 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
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
justassi
Posts: 4
Joined: Wed Dec 19, 2018 4:55 pm

Re: Not all Standard Macros working in Email Notifications

Post 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?
You do not have the required permissions to view the files attached to this post.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Not all Standard Macros working in Email Notifications

Post 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".
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
justassi
Posts: 4
Joined: Wed Dec 19, 2018 4:55 pm

Re: Not all Standard Macros working in Email Notifications

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Not all Standard Macros working in Email Notifications

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked