{"id":109,"date":"2011-03-02T17:08:48","date_gmt":"2011-03-02T11:38:48","guid":{"rendered":"http:\/\/atuljha.com\/blog\/?p=109"},"modified":"2011-03-02T17:10:43","modified_gmt":"2011-03-02T11:40:43","slug":"setting-up-monit-on-ubuntu-is-easier-than-making-coffee","status":"publish","type":"post","link":"https:\/\/atuljha.com\/blog\/2011\/03\/02\/setting-up-monit-on-ubuntu-is-easier-than-making-coffee\/","title":{"rendered":"Setting up Monit (On Ubuntu)  .."},"content":{"rendered":"<p>Apart from playing with the Source Code Open Source Software has given us.<\/p>\n<p>Installing Monit :&#8211;<\/p>\n<p>&nbsp;<\/p>\n<p>sudo apt-get install monit<\/p>\n<p>This command will install Monit on Ubuntu.<\/p>\n<p>In order to Start the Monit we need to edit file\u00a0 &#8220;\/etc\/default\/monit&#8221; and set the\u00a0 &#8220;startup= 1&#8221;<\/p>\n<p>This will start the Monit, but we need to do the real work inside the &#8220;\/etc\/monit\/monirc&#8221;\u00a0 file, and mention what all services we want to be monitored.<\/p>\n<p>I have simply added a script for monitoring my Nginx Server<\/p>\n<p>check process nginx with pidfile \/var\/run\/nginx.pid<br \/>\nstart program = &#8220;\/etc\/init.d\/nginx start&#8221;<br \/>\nstop program\u00a0 = &#8220;\/etc\/init.d\/nginx stop&#8221;<br \/>\ngroup www-data<\/p>\n<p>But before that we need to enable few other services as well like:&#8211;<\/p>\n<p>set daemon\u00a0 20\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # check services at 2-minute intervals<\/p>\n<p>set logfile syslog facility log_daemon\u00a0\u00a0\u00a0 #for log analysis<\/p>\n<p>set httpd port 2812 and<br \/>\nuse address localhost\u00a0 # only accept connection from localhost<br \/>\nallow localhost\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # allow localhost to connect to the server and<br \/>\nallow admin:monit\u00a0\u00a0\u00a0\u00a0\u00a0 # require user &#8216;admin&#8217; with password &#8216;monit&#8217;<br \/>\n#\u00a0\u00a0\u00a0\u00a0 allow @monit\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # allow users of group &#8216;monit&#8217; to connect (rw)<br \/>\n#\u00a0\u00a0\u00a0\u00a0 allow @users readonly\u00a0 # allow users of group &#8216;users&#8217; to connect readonly<\/p>\n<p>&nbsp;<\/p>\n<p>Once am done with this i will restart monit and see the status on localhost:2812 , we will see the status saying nginx is running.<\/p>\n<p>let kill or stop Nginx and see the same url, you will see a message saying Nginx is stopped.<\/p>\n<p>&nbsp;<\/p>\n<p>As we have asked the monit to check and restart the service at 2 minutes, you will see the process up and running again.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apart from playing with the Source Code Open Source Software has given us. Installing Monit :&#8211; &nbsp; sudo apt-get install monit This command will install Monit on Ubuntu. In order to Start the Monit we need to edit file\u00a0 &#8220;\/etc\/default\/monit&#8221; and set the\u00a0 &#8220;startup= 1&#8221; This will start the Monit, but we need to do &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/atuljha.com\/blog\/2011\/03\/02\/setting-up-monit-on-ubuntu-is-easier-than-making-coffee\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting up Monit (On Ubuntu)  ..&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"_links":{"self":[{"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/posts\/109"}],"collection":[{"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":3,"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions\/111"}],"wp:attachment":[{"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atuljha.com\/blog\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}