A simple script to send Monit alerts to you via SMS with Twilio.
Monit only sends alert notifications via email out of the box, but also provides 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 Twilio's twilio-sms bash script for delivery.
Put your Twilio credentials in twiliorc and upload it to the user's home directory (probably
root, since Monit runs as
Then, wire up any Monit alerts that you'd like:
check file nginx.pid with path /var/run/nginx.pid if changed timestamp then exec "/usr/local/bin/monit2twilio" as uid root and gid root
There's also an Ansible playbook if you're so inclined.