Created
May 25, 2020 08:32
-
-
Save dev01d/7d499b952879142023688480f923e8d8 to your computer and use it in GitHub Desktop.
Slack RAID notification
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 | |
#* Vars | |
CONTROLLER=*controller* | |
USERNAME=RAID | |
STATUS=`sudo tw_cli info "$CONTROLLER" | grep "RAID"` | |
OK=`echo "$STATUS" | grep "OK"` | |
HOOK_URL=https://hooks.slack.com/services/****/****/**** | |
# | |
function slackNotify() { | |
curl -X POST -H 'Content-type: application/json' --data '{"username": "'$USERNAME'", "attachments": [{"color": "'$COLOR'", "text": "```'"$MESSAGE"'```"}]}' "$HOOK_URL" | |
} | |
# | |
function status() { | |
if [ "$STATUS" != "$OK" ]; then | |
COLOR=danger | |
MESSAGE=`sudo tw_cli info "$CONTROLLER"` | |
slackNotify | |
fi | |
} | |
#* Main | |
status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment