#!/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
