A simple script to send Monit alerts using AWS SNS.
By default, Monit only sends alert notifications via email. But we can also set a hook to execute a script. When executing the script, Monit sets a few environment variables about the alert.
This tiny script transforms those variables into a text message and pipes them to AWS SNS.
This script is inspired by Monit2Twilio and monit2telegram
- Edit monit2snsrc configuring region and topic ARN
chmod +x sendsns.sh
- Copy sendsns.sh to /usr/local/bin:
cp sendsns.sh /usr/local/bin
- Optionally copy config file to /etc:
cp monit2snsrc /etc/monit2snsrc
After installing the script:
sendsns.sh -m "message to send to topic ARN" -c monit2snsrc
If the config file is copied to /etc/monit2snsrc:
sendsns.sh -m "message to send to topic ARN"