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
Can User Macros be used to add info to Notifications
Re: Can User Macros be used to add info to Notifications
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?
http://assets.nagios.com/downloads/nagi ... iables.pdf
Is this what you were looking for?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Can User Macros be used to add info to Notifications
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$?
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$?
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Can User Macros be used to add info to Notifications
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.
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
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%
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%
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Can User Macros be used to add info to Notifications
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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: Can User Macros be used to add info to Notifications
Thanks Spencer. I'll try this.
diane
diane
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Can User Macros be used to add info to Notifications
Let us know if you need further assistance