Page 1 of 1

Nagios XI macro vs variables questions

Posted: Sat Aug 18, 2018 10:22 pm
by dfmco
I am using AWS to send alerts. I am passing standard macros in the alerts ($HOSTNAME$, $HOSTSTATE$). I would like to add the %alertsummary% but wanted to make sure that the notification variable would be appropriate in the command. Here is the command line. It is a custom command.

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /home/nagios/.local/bin/aws sns publish --topic-arn REDACTED:CAECD_CRIT --subject "Onshore IT CAECD Host Alert $HOSTNAME$ is $HOSTSTATE$" --message "$NOTIFICATIONTYPE$ CAECD Host Alert: $HOSTNAME$ is $HOSTSTATE$ Date/Time: $LONGDATETIME$ Duration: $HOSTDURATION$ Info: $HOSTOUTPUT$"

Can I use %alertsummary% and any other notification variables in this command? Before I go too far down the rabbit hole, I wanted to make sure I was not doing something that would not work.

Re: Nagios XI macro vs variables questions

Posted: Mon Aug 20, 2018 10:04 am
by scottwilkerson
You can only use the macros here in the columns Host/Service Notifications for custom notifications:
https://assets.nagios.com/downloads/nag ... olist.html

Re: Nagios XI macro vs variables questions

Posted: Mon Aug 20, 2018 11:15 am
by dflick
I think that maybe we have a miscommunication. I am looking at the other way around. I wanted to know if VARIABLES like %alertsummary% would be available to a custom command.

Currently the Macros are working as intended but I would like to add variables to those commands (as well as macros that are already functioning).

Specifically, would this command work (see where I added "Alert Summary is %alertsummary%")?

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /home/nagios/.local/bin/aws sns publish --topic-arn REDACTED:CAECD_CRIT --subject "Onshore IT CAECD Host Alert $HOSTNAME$ is $HOSTSTATE$" --message "$NOTIFICATIONTYPE$ CAECD Host Alert: $HOSTNAME$ is $HOSTSTATE$ Alert Summary is %alertsummary% Date/Time: $LONGDATETIME$ Duration: $HOSTDURATION$ Info: $HOSTOUTPUT$"

Re: Nagios XI macro vs variables questions

Posted: Mon Aug 20, 2018 12:40 pm
by scottwilkerson
%alertsummary% cannot be used as it is a special macro added just to the XI notification handler

None of the %xxxxx% can be used directly on a custom command, just the $xxxx$ in the link I previously referenced.

Re: Nagios XI macro vs variables questions

Posted: Mon Aug 20, 2018 1:46 pm
by dflick
That answers my question exactly! Thanks!

Re: Nagios XI macro vs variables questions

Posted: Mon Aug 20, 2018 2:18 pm
by scottwilkerson
dflick wrote:That answers my question exactly! Thanks!
Great. Locking thread.