Created
March 31, 2020 20:28
-
-
Save D4R4/a56828cca2a9b360ec7b20ec64c1e162 to your computer and use it in GitHub Desktop.
Observium script to send alarm push notifications to Pushover API
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 | |
# | |
# | |
OBS_PATH="https://xxxxxxxxx.xxx" | |
OBS_USER=xxxxxxxxxxx | |
OBS_PASS=xxxxxxxxxxxx | |
OBS_DEVICE_NO=5 | |
OBS_GRAPH_NAME=device_la | |
ALERT_TEXT="Load Average above 45" | |
PUSHOVER_TOKEN=zzzzzzzzzzzzzzzzzzzzzzzzzzzzz | |
PUSHOVER_USER=zzzzzzzzzzzzzzzzzzz | |
PUSHOVER_MESSAGE="$OBSERVIUM_ALERT_STATE - $OBSERVIUM_DEVICE_HOSTNAME $ALERT_TEXT" | |
EDATE=`date +%s` | |
SDATE=`expr $EDATE - 21600` # 6 hours | |
TMP_IMG="/tmp/${USER}_push.png" | |
wget -O $TMP_IMG --no-check-certificate --auth-no-challenge --user=$OBS_USER --password=$OBS_PASS "${OBS_PATH}/graph.php?type=$OBS_GRAPH_NAME&device=$OBS_DEVICE_NO&to=$EDATE&from=$SDATE&height=300&width=1152" | |
curl -s \ | |
--form-string "token=$PUSHOVER_TOKEN" \ | |
--form-string "user=$PUSHOVER_USER" \ | |
--form-string "message=$PUSHOVER_MESSAGE" \ | |
-F "attachment=@$TMP_IMG" \ | |
https://api.pushover.net/1/messages.json | |
rm -f $TMP_IMG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment