Last active
October 20, 2017 03:32
-
-
Save hoangdh/13b7799d12377fea6891283852e7dec9 to your computer and use it in GitHub Desktop.
OMD_SMS-Notify for check_mk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SMS Notify | |
####### | |
# | |
# Register free account: http://nexmo.com/ | |
# | |
######## | |
KEY="XXXXXXXX" | |
SECRET="XXXXXXXXXXXXXXX" | |
if [ "$NOTIFY_WHAT" == "SERVICE" ] | |
then | |
INFO=$(echo -e "HOST: $NOTIFY_HOSTNAME - $NOTIFY_WHAT: $NOTIFY_SERVICEDESC - $NOTIFY_SERVICEOUTPUT At: $NOTIFY_SHORTDATETIME") | |
else | |
INFO=$(echo -e "$NOTIFY_HOSTNAME - $NOTIFY_WHAT: $NOTIFY_HOSTSTATE At: $NOTIFY_SHORTDATETIME") | |
fi | |
curl -X POST https://rest.nexmo.com/sms/json \ | |
-d api_key=$KEY \ | |
-d api_secret=$SECRET \ | |
-d to=$NOTIFY_CONTACTPAGER \ | |
-d from="NEXMO" \ | |
-d text="$INFO" | |
echo $INFO >> /var/log/omd_notify_sms.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Các biến:
$NOTIFY_WHAT: Loại. Có 2 loại là HOST và SERVICE
$NOTIFY_HOSTNAME: Tên của Host
$NOTIFY_HOSTSTATE: Trạng thái của Host. (UP/DOWN)
$NOTIFY_SHORTDATETIME: Thời gian phát hiện ra lỗi
$NOTIFY_SERVICEDESC: Tên dịch vụ
$NOTIFY_SERVICEOUTPUT: Trạng thái của dịch vụ, thông tin sau khi check
$NOTIFY_CONTACTPAGER: Số điện thoại của người nhận