script help needed
Posted: Thu May 13, 2021 11:48 am
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"
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"