Created
May 14, 2024 21:12
-
-
Save jagland/9f4d9c2de915e2a6934f7accbbba2a4c to your computer and use it in GitHub Desktop.
monit-slack-busybox.sh
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/ash | |
# Alternative script for use with busybox (OpenWRT etc..), which uses wget rather than curl | |
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 | |
wget -q -O /dev/null --post-data "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