Skip to content

Instantly share code, notes, and snippets.

@K0rell
Last active April 19, 2024 15:20
Show Gist options
  • Save K0rell/1d5e09b5688b9473fe8b37685e435fdb to your computer and use it in GitHub Desktop.
Save K0rell/1d5e09b5688b9473fe8b37685e435fdb to your computer and use it in GitHub Desktop.
Zabbix SMS Alert with OVH SMS API
#!/bin/bash
# Requirement wget
# Create new script in nano /usr/lib/zabbix/alertscripts/media-sms-ovh.sh
# chmod +x media-sms-ovh.sh
# OVH SMS API
# Login into your ovh account create SMS user
ACCOUNT=MyOvhSmsAccountName(sms-xxxxxxxxx-x)
LOGIN=MyOvhSmsUserApiLogin
PASSWORD=MyOvhSmsUserApiPassword
FROM=MyOvhSenderName
# ZABBIX Administration > Media types > Create media type
# Name = SMS OVH
# Type = Script
# Script name = media-sms-ovh.sh
# Script parameters (one per line with {}) = {ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}
# Administration > User > Media > Add
TO=$1 # {ALERT.SENDTO}
MESSAGE="$2%0d%0a$3" # {ALERT.SUBJECT} \r\n {ALERT.MESSAGE}
SMS_URL="https://www.ovh.com/cgi-bin/sms/http2sms.cgi?&account=${ACCOUNT}&login=${LOGIN}&password=${PASSWORD}&noStop=1&from=${FROM}&to=${TO}&message=${MESSAGE}"
wget "$SMS_URL" --https-only --quiet
# Exit status 0 returned because command executed successfully.
echo $?
@K0rell
Copy link
Author

K0rell commented May 26, 2020

CURL Version :

#Carrinage return tips
MESSAGE="${2}"$'\r\n'"${3}" 

curl \
    --data-urlencode "account=${ACCOUNT}" \
    --data-urlencode "login=${LOGIN}" \
    --data-urlencode "password=${PASSWORD}" \
    --data-urlencode "noStop=1" \
    --data-urlencode "from=${FROM}" \
    --data-urlencode "to=${TO}" \
    --data-urlencode "message=${MESSAGE}" \
    --silent \
    --show-error \
    --get \
    https://www.ovh.com/cgi-bin/sms/http2sms.cgi > /dev/null

# For debugging remove > /dev/null and uncomment
# exit 1;

# Exit status 0 returned because command executed successfully.
echo $?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment