Create a new file named MonitSMS.sh in your /root directory (or wherever you prefer – i use root because I manage many different type of OS) and paste the following code:
- #!/bin/sh
- /usr/bin/curl \
- -X POST http://textbelt.com/text \
- -d number=1111111111 \
- -d “message=[$MONIT_HOST] $MONIT_SERVICE – $MONIT_DESCRIPTION”
Change 1111111111 to your cell/mobile phone number. Give it 777 permissions.
- chmod 777 /root/MonitSMS.sh
Run it once if you like, you should at that point receive a SMS message to your phone.
Integration with Monit
I believe it’s best to use it when your Monit configuration does a timeout and Monit no longer monitors the process. All you need to do next is attach the following code to any/all processes.
- if 5 restarts within 5 cycles then exec “/root/MonitSMS.sh”
A full Monit example of monitoring a process…
- check process NGINX with pidfile /var/run/nginx.pid
- group nginx
- start program = “/sbin/service nginx restart”
- stop program = “/sbin/service nginx stop”
- if failed host blog.ss88.uk port 443 type TCPSSL for 3 cycles then restart
- if 5 restarts within 5 cycles then exec “/root/MonitSMS.sh”
Recent Comments