Page 1 of 1

Using System Macros in Alert Messages

Posted: Thu Aug 03, 2017 6:36 am
by fuchstiger
Hello!
Is it possible to use the general system macros like $HOSTNAME$ in alert messages?
Or can I use only the general notification variables?

Re: Using System Macros in Alert Messages

Posted: Thu Aug 03, 2017 8:44 am
by mcapra
Here's a big old list of all the Nagios macros and the contexts in which you can use a given macro:
https://assets.nagios.com/downloads/nag ... olist.html

You might find the "Service Notifications" and "Host Notifications" columns particularly useful in this case. $HOSTNAME$ appears to be usable in pretty much every context.

Re: Using System Macros in Alert Messages

Posted: Thu Aug 03, 2017 4:09 pm
by lmiltchev
@fuchstiger, mcapra is correct. Let us know if you have any more questions.

Re: Using System Macros in Alert Messages

Posted: Fri Aug 04, 2017 12:43 am
by fuchstiger
Yep, I know this list. We have used it for years with Nagios Core.
But now I configure these mails in Nagios XI and the macros are empty.
I have made a template in notification management for a service alert. In the end of this message I used the following:

Notification Type: $NOTIFICATIONTYPE$
Service: $SERVICEDESC$
Host: $HOSTALIAS$
Address: $HOSTADDRESS$
State: $SERVICESTATE$
Date/Time: $LONGDATETIME$
Additional Info: $SERVICEOUTPUT$

But all of these macros are empty if I get an email with this template.

Re: Using System Macros in Alert Messages

Posted: Fri Aug 04, 2017 10:36 am
by scottwilkerson
Actually I believe this is the document you are looking for, when using XI

https://assets.nagios.com/downloads/nag ... iables.pdf

Re: Using System Macros in Alert Messages

Posted: Fri Aug 04, 2017 11:23 am
by fuchstiger
So if I understand this document there is no possibility to use the system macros variables in the notification management. Right? Only variables in lowercase with the percent sign.

Re: Using System Macros in Alert Messages

Posted: Fri Aug 04, 2017 12:32 pm
by scottwilkerson
fuchstiger wrote:So if I understand this document there is no possibility to use the system macros variables in the notification management. Right? Only variables in lowercase with the percent sign.
Page 8 & 9 of that document shows how you can map additional macros

Re: Using System Macros in Alert Messages

Posted: Mon Aug 07, 2017 12:52 am
by fuchstiger
Sorry but this is not a solution for me. I want to use the global system macros like "$HOSTADDRESS$" or "$SERVICEOUTPUT$".
If I have to add these variables for many hosts I can use the regular ones for the notifications instead.

Re: Using System Macros in Alert Messages

Posted: Mon Aug 07, 2017 9:23 am
by scottwilkerson
On page 8 & 9 it shows you how you can add any of the nagios macros and create the required %var% that is required.