Created
April 12, 2023 17:38
-
-
Save jagland/49471d0fd8b5acbed4f3956e0b5ee1a1 to your computer and use it in GitHub Desktop.
This file contains 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 | |
SLACK_WEBHOOK="https://hooks.slack.com/services/..." | |
SLACK_CHANNEL="#alerts" | |
SLACK_USERNAME="monit on $MONIT_HOST" | |
if [[ "$MONIT_DESCRIPTION" =~ .*"succeeded".* ]]; then | |
SLACK_ICON=":white_check_mark:" | |
SLACK_USERNAME="monit on $MONIT_HOST - service up" | |
elif [[ "$MONIT_DESCRIPTION" =~ .*"failed".* ]]; then | |
SLACK_ICON=":exclamation:" | |
SLACK_USERNAME="monit on $MONIT_HOST - service down" | |
else | |
SLACK_ICON=":grey_exclamation:" | |
fi | |
curl -s -X POST --data-urlencode "payload={\"channel\": \"$SLACK_CHANNEL\", \"username\": \"$SLACK_USERNAME\", \"text\": \"*$MONIT_SERVICE* - $MONIT_DESCRIPTION\", \"icon_emoji\": \"$SLACK_ICON\"}" $SLACK_WEBHOOK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment