Wednesday, 23 January 2013

Install Monit & MMonit on RHEL/Cent OS From Source


#yum install pam-devel
#yum install openssl-devel

@Get and install Monit@
#cd /usr/local/src
#tar -zxvf monit-5.5.tar.gz
#cd monit-5.5
#./configure (If this fails, fix as necessary, then re-unpack the tar and try again)
#make install

@Setup monitrc@

#cp monitrc /etc/
#vim /etc/monitrc  # At the end of monitrc add or uncomment: include /etc/monit.d/*
#mkdir /etc/monit.d

Create the service files (this will repeat for every service you monitor)
vim /etc/monit.d/apache

#Now Inside the apache file:
check process httpd with pidfile /var/run/httpd/
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host port 80 protocol http
 and request "/index.html"
then restart
if 5 restarts within 5 cycles then timeout

@To see more services, chec out this

@Now setup the init.d file@
#cp contrib/rc.monit /etc/init.d/monit
#chmod 755 /etc/init.d/monit

You may need to fix the line inside the above file thats pointing at /usr/bin/monit to /usr/local/bin/monit.
After this is in place you should have the service monit restart command available.

To start Monit at boot, edit vim /etc/rc.d/rc.local and add in the next line

Go ahead and run the above line in the console to see if monit works.
If so, a call to service httpd stop should cause monit to restart apache.

Monit should be all setup. You can check with service monit status or ps aux | grep monit.

Another cool feature of monit is the web interface. Go to http://localhost:2812/ and
enter the username and password form your monitrc file, it should look something like this, feel free to change it:

set httpd port 2812
  allow hauk:password

@Main Files@

/etc/monitrc - Monit's control file

/etc/monit.d/* - all services Monit will track

/etc/init.d/monit - service control file

/usr/local/src/monit-5.5 - source code


Edit below settings based on our requirements

vim /etc/monitrc

set alert (to get alert email)

Lastly I changed the email format to be a little more user friendly for support and the other users. While I’ve grown fond of the simple/to the point alert system monit has by default, it’s easy to format the message so they’re a bit more specific, and easier to categorize. In the top, global section of monitrc, we add something like:

set mail-format {
     subject: [ $SERVICE ] $EVENT - $DATE
     message: This is an $ACTION: $DESCRIPTION [$SERVICE], tested remotely from $HOST }

To add remote host( http service in monit

check host  with address
  if failed port 80 proto http then alert

For multiple alert
check host with address
if failed url and content == "look out honey"
timeout 30 seconds for 1 cycles then alert
alert { connection, timeout }
alert { connection, timeout }
alert { connection, timeout }

For Adding Process list refer the below:

Install MMonit:

Check out the

No comments:

Post a Comment