How can i add a managed variable for the Recipient Value? would i have to add this into the command or script or both ?
i am wanting to attach this managed variable to the contact or host template as a manage free variable.
i want have a managed variable for the Recipient value, instead of "localit" i want the managed variable to insert the "localit"
currently i am using this script to able to have contact talk back to my sms application to send a text message. The recipient value is who the text message is going to.
can someone help me with this please?
current command: /usr/local/nagios/libexec/smsalert.sh "--PageGate Host Alert-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$"
current script:
#!/bin/bash
# set each part of the URL to send
UrlToCgi=$(printf "http://10.1.1.1/pgscripts/webgate.exe")
RecipientVar=$(printf "?USER=")
Recipient=$(printf "localit")
SenderVar=$(printf "&FRM=")
Sender=$(printf "Nagios")
MessageVar=$(printf "&MSG=")
# set message to all the text sent on the command line
Message=$@
# url encode message text
Message=$(php -r "echo urlencode(\"$Message\");")
# build the request URL
FullUrl=$UrlToCgi$RecipientVar$Recipient$SenderVar$Sender$MessageVar$Message
# send the request
wget -O- "$FullUrl"
script help needed
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: script help needed
Hi,
You are on the right track here. You can add this as a Free Variable to the object or template in the CCM, and then pass this into your script when it's called.
This is explained on page 16 of the following guide.
Introduction to Event Handlers
While this document covers Event Handlers, the same logic applies to notifications and plugins. The main difference is these scripts are executed under different conditions.
Free variables have different syntax, you'll need to add SERVICE or HOST in front of the variable when calling them.
A good way to test your script is to send passive check results to force different state types on a test object. You can do this from the Advanced Tab of the host or service status pages. Let us know if you need further assistance. If it's not working as expected, try to insert some log output in the script to verify the data is getting passed correctly.
Regards,
Benjamin
You are on the right track here. You can add this as a Free Variable to the object or template in the CCM, and then pass this into your script when it's called.
This is explained on page 16 of the following guide.
Introduction to Event Handlers
While this document covers Event Handlers, the same logic applies to notifications and plugins. The main difference is these scripts are executed under different conditions.
Free variables have different syntax, you'll need to add SERVICE or HOST in front of the variable when calling them.
https://assets.nagios.com/downloads/nag ... tvars.htmlIn order to prevent name collision among custom variables from different object types, Nagios prepends "_HOST", "_SERVICE", or "_CONTACT" to the beginning of custom host, service, or contact variables, respectively, in macro and environment variable names. The table below shows the corresponding macro and environment variable names for the custom variables that were defined in the example above.
A good way to test your script is to send passive check results to force different state types on a test object. You can do this from the Advanced Tab of the host or service status pages. Let us know if you need further assistance. If it's not working as expected, try to insert some log output in the script to verify the data is getting passed correctly.
Regards,
Benjamin
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: script help needed
Ticket received, we will continue support through the ticket ..... locking thread ..... Thank you!
https://support.nagios.com/tickets/scp/ ... p?id=14186
https://support.nagios.com/tickets/scp/ ... p?id=14186