Mattermost alerting for monit
The snippet can be accessed without any authentication.
Authored by
Erick Hitter
Called via monit's exec
function:
if not exists then exec "/etc/monit/mattermost.sh danger" else if succeeded then exec "/etc/monit/mattermost.sh good"
Either named colors, or hex codes, are accepted as the first argument.
#!/bin/sh
COLOR=${1:-default}
/usr/bin/curl \
-X POST \
-s \
--data-urlencode "payload={ \
\"channel\": \"#alerts\", \
\"username\": \"Monit\", \
\"attachments\": [ { \
\"fallback\": \"$MONIT_HOST: $MONIT_SERVICE - $MONIT_DESCRIPTION\", \
\"pretext\": \"**$MONIT_HOST** @ $MONIT_DATE\", \
\"text\": \"**$MONIT_SERVICE** - $MONIT_DESCRIPTION\", \
\"color\": \"$COLOR\" \
} ],\
\"icon_url\": \"https://mattermost/static/emoji/1f47b.png\" \
}" \
https://mattermost/hooks/boo
Please register or sign in to comment