Page 1 of 1

Can User Macros be used to add info to Notifications

Posted: Thu Mar 20, 2014 1:03 pm
by dianeghir
Hi

I have an application that sends several passive checks using send_nrdp.sh. I would like to be able to send additional data to Nagios that can be added to the notifications (SHAs, etc) using User Defined Macros. I'm not sure if User Macros were developed to do this and I can't find any documentation on how to pass data to Nagios. Can someone please point me in the right direction?

thanks

diane

Re: Can User Macros be used to add info to Notifications

Posted: Thu Mar 20, 2014 4:22 pm
by lmiltchev
There is a section on using custom notifications macros in Nagios XI here:

http://assets.nagios.com/downloads/nagi ... iables.pdf

Is this what you were looking for?

Re: Can User Macros be used to add info to Notifications

Posted: Thu Mar 20, 2014 4:51 pm
by dianeghir
This helps, but I can't figure out how to pass the USER value from the client. I am currently using:

send_nrdp.sh -u http://192.168.1.1/nrdp -t "test_token" -H myhost -s watchdog -S 0 -o "OK: Watchdog is running."

I want to pass the SHA for this app as a USER macro. I tried something like using -u1 SHA but that doesn't work. Can I embed the SHA in the output string and pick it out with $USER1$?

Re: Can User Macros be used to add info to Notifications

Posted: Thu Mar 20, 2014 5:01 pm
by slansing
You could assign it to $USER2$ and so on, don't change $USER1$ as it is already used by many commands in XI to denote '/usr/local/nagios/libexec/'.

Then you would directly add $USER2$ or whatever you are using, to the command string in your nagios check.

Re: Can User Macros be used to add info to Notifications

Posted: Fri Mar 21, 2014 8:42 am
by dianeghir
I don't want to use User Macros in the COMMAND STRING, I want to use them in the RESPONSE STRING so I can include them as part of the notification.

For example I want to send a message like this to Nagios:
send_nrdp.sh -u http://192.168.1.1/nrdp -t "test_token" -H myhost -s watchdog -S 0 -o "OK: Watchdog is running. $USER2$= 893df632e84e8954dce05d8c9eb9d21ae883fb9f"

And format the notification like this:
***** Nagios Service Alert *****

Attempts before Notification: %currentattempt%

Report for %host%::%service%
Received from address: %hostaddress%
Report Status Level: %servicestate%
Date: %datetime%
SHA1: %USER2%
Report Information:
%serviceoutput%
%longserviceoutput%

Respond: %responseurl%
Nagios URL: %xiserverurl%

Re: Can User Macros be used to add info to Notifications

Posted: Fri Mar 21, 2014 12:49 pm
by sreinhardt
You would need to modify the notification command, nagios will not expand a macro within a macro. In this case you are looking to expand something like $SERVICEDESCRIPTION$ that would have an additional macro within it. Unfortunately that is not possible. If you wished to have this information available for all notifications, you could just add it to the generic notification commands. If you only wanted for a few items, I would suggest adding it to custom macros for those hosts or services, and modifying the generic notification commands to include these. In the event that the macro is not available, such as a host\service that you do not wish to send that data, I believe it should replace it with a space or nothing, at the very worst you would see the custom macro label.

Re: Can User Macros be used to add info to Notifications

Posted: Mon Mar 24, 2014 12:33 pm
by dianeghir
Thanks Spencer. I'll try this.

diane

Re: Can User Macros be used to add info to Notifications

Posted: Mon Mar 24, 2014 1:22 pm
by scottwilkerson
Let us know if you need further assistance