{"id":6544,"date":"2017-03-12T21:33:28","date_gmt":"2017-03-12T13:33:28","guid":{"rendered":"http:\/\/rmohan.com\/?p=6544"},"modified":"2017-03-12T21:33:28","modified_gmt":"2017-03-12T13:33:28","slug":"monitsms","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6544","title":{"rendered":"MonitSMS"},"content":{"rendered":"<p>Create a new file named <strong>MonitSMS.sh<\/strong> in your <strong>\/root<\/strong> directory (or wherever you prefer \u2013 i use root because I manage many different type of OS) and paste the following code:<\/p>\n<div class=\"EnlighterJSWrapper enlighterEnlighterJSWrapper\">\n<ul class=\"enlighterEnlighterJS EnlighterJS\">\n<li class=\" odd\"><span class=\"co1\">#!\/bin\/sh<\/span><\/li>\n<li class=\" even\"><span class=\"\">\/usr\/bin\/curl \\<\/span><\/li>\n<li class=\" odd\"><span class=\"\">-X POST http:\/\/textbelt.com\/text \\<\/span><\/li>\n<li class=\" even\"><span class=\"\">-d number=1111111111 \\<\/span><\/li>\n<li class=\" odd\"><span class=\"\">-d <\/span><span class=\"st0\">&#8220;message=[$MONIT_HOST] $MONIT_SERVICE &#8211; $MONIT_DESCRIPTION&#8221;<\/span><\/li>\n<\/ul>\n<\/div>\n<p>Change <span class=\"enlighterEnlighterJS EnlighterJS\"><span class=\"nu0\">1111111111<\/span><\/span>\u00a0 to your cell\/mobile phone number. Give it 777 permissions.<\/p>\n<div class=\"EnlighterJSWrapper enlighterEnlighterJSWrapper\">\n<ul class=\"enlighterEnlighterJS EnlighterJS\">\n<li class=\" odd\"><span class=\"\">chmod <\/span><span class=\"nu0\">777<\/span><span class=\"\"> \/root\/MonitSMS.sh<\/span><\/li>\n<\/ul>\n<\/div>\n<p>Run it once if you like, you should at that point receive a SMS message to your phone.<\/p>\n<h2>Integration with Monit<\/h2>\n<p>I believe it\u2019s 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.<\/p>\n<div class=\"EnlighterJSWrapper enlighterEnlighterJSWrapper\">\n<ul class=\"enlighterEnlighterJS EnlighterJS\">\n<li class=\" odd\"><span class=\"kw1\">if<\/span><span class=\"\"> 5 restarts within 5 cycles <\/span><span class=\"kw1\">then<\/span><span class=\"\"> exec <\/span><span class=\"st0\">&#8220;\/root\/MonitSMS.sh&#8221;<\/span><\/li>\n<\/ul>\n<\/div>\n<h3>\u00a0A full Monit example of monitoring a process\u2026<\/h3>\n<div class=\"EnlighterJSWrapper enlighterEnlighterJSWrapper\">\n<ul class=\"enlighterEnlighterJS EnlighterJS\">\n<li class=\" odd\"><span class=\"\">check process NGINX with pidfile \/var\/run\/nginx.pid<\/span><\/li>\n<li class=\" even\"><span class=\"\">group nginx<\/span><\/li>\n<li class=\" odd\"><span class=\"\">start program = <\/span><span class=\"st0\">&#8220;\/sbin\/service nginx restart&#8221;<\/span><\/li>\n<li class=\" even\"><span class=\"\">stop program = <\/span><span class=\"st0\">&#8220;\/sbin\/service nginx stop&#8221;<\/span><\/li>\n<li class=\" odd\"><span class=\"\">if failed host blog.ss88.uk port <\/span><span class=\"nu0\">443<\/span><span class=\"\"> type TCPSSL for <\/span><span class=\"nu0\">3<\/span><span class=\"\"> cycles then restart<\/span><\/li>\n<li class=\" even\"><span class=\"\">if <\/span><span class=\"nu0\">5<\/span><span class=\"\"> restarts within <\/span><span class=\"nu0\">5<\/span><span class=\"\"> cycles then exec <\/span><span class=\"st0\">&#8220;\/root\/MonitSMS.sh&#8221;<\/span><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Create a new file named MonitSMS.sh in your \/root directory (or wherever you prefer \u2013 i use root because I manage many different type of OS) and paste the following code:<\/p>\n<p> #!\/bin\/sh \/usr\/bin\/curl \\ -X POST http:\/\/textbelt.com\/text \\ -d number=1111111111 \\ -d &#8220;message=[$MONIT_HOST] $MONIT_SERVICE &#8211; $MONIT_DESCRIPTION&#8221; <\/p>\n<p>Change 1111111111 to your cell\/mobile phone number. Give it [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6544"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6544"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6544\/revisions"}],"predecessor-version":[{"id":6545,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6544\/revisions\/6545"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}