May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

MonitSMS

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”

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>