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.
Nagios XI macro vs variables questions
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios XI macro vs variables questions
You can only use the macros here in the columns Host/Service Notifications for custom notifications:
https://assets.nagios.com/downloads/nag ... olist.html
https://assets.nagios.com/downloads/nag ... olist.html
Re: Nagios XI macro vs variables questions
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$"
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$"
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios XI macro vs variables questions
%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.
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
That answers my question exactly! Thanks!
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios XI macro vs variables questions
Great. Locking thread.dflick wrote:That answers my question exactly! Thanks!