Skip to content

Instantly share code, notes, and snippets.

@dev01d
Created May 25, 2020 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dev01d/7d499b952879142023688480f923e8d8 to your computer and use it in GitHub Desktop.
Save dev01d/7d499b952879142023688480f923e8d8 to your computer and use it in GitHub Desktop.
Slack RAID notification
#!/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