Skip to content

Instantly share code, notes, and snippets.

@schallis
Last active November 20, 2015 16:34
Show Gist options
  • Save schallis/8305205bbdfaddec4462 to your computer and use it in GitHub Desktop.
Save schallis/8305205bbdfaddec4462 to your computer and use it in GitHub Desktop.
post_to_slack() {
USERNAME="<username>"
CHANNEL="<channel>"
MESSAGE="$1"
PAYLOAD="payload={\"channel\": \"$CHANNEL\", \"username\": \"$USERNAME\", \"text\": \"$MESSAGE\"}"
SLACK_URL=<webhook_url>
curl -X POST --data-urlencode "$PAYLOAD" $SLACK_URL
}
response=`curl -s -o /dev/null -w "%{http_code}" https://zonza.tv/authentication/login/`
current=`date "+%F %T %Z"`
message="$current zonza.tv appears to be down [HTTP $response] #PrayForZONZA"
if [ $response != "200" ] && [ $response != "000" ]; then
echo $message; post_to_slack "$message";
fi
~
~
~
~
~
@schallis
Copy link
Author

Check for non-200 HTTP codes and post to Slack channel if website appears to be down.

Stick it in Cron with:

* * * * * /home/<user>/zonzastatus.sh

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