The steps here should allow the user to install monit and monitor Google home page in no more than 5 minutes. It is always gratifying to get things running while following simple steps. Dealing with environment issues is the most difficult and frustrating part when you are trying to prove your concept.
- Install monit:
sudo apt-get install monit
- Using sudo edit /etc/default/monit to setup automatic monit startup
#startup=1 START=yes
- Using sudo edit /etc/monit/monitrc as per the content below. Customize your web interface password, an IP allowed to connect via WEB (if you are a GUI guy), email addressee for alerts and mailserver. The rest of the settings should be OK for you. Note that the only check I am providing is checking Google availability just as a proof of concept. The web is full of samples to monitor anything in your servers
################################################################## # CUSTOM MONIT SETTINGS ################################################################## set mail-format { subject: [ $SERVICE ] $EVENT - $DATE message: Action: $ACTION, Description: $DESCRIPTION, Service: $SERVICE, Tested From Host: $HOST } # number of seconds between monit checks set daemon 60 # Location of the monit log file # /var/log/messages is just ok # set logfile /var/log/monit.log set logfile syslog facility log_daemon # Change to the email address you want alerts to be sent to set alert nestorurquizaappmon@nestorurquiza.com # Port that the monit status page can be viewed set httpd port 2812 # Allow localhost to connect allow localhost # The next line must be included to allow access from your computer # change the number to what your local ip is allow 0.0.0.0 # The next line assigns a username:password combination to login. # Please change the password to something random. allow admin:myAdminPassword # Set the mailserver to send notification email. set mailserver mail.nestorurquiza.com ################################################################# #REMOTE GOOGLE CHECKS ################################################################ check host google-test with address google.com if failed port 80 proto http then alert group server
- Start, stop, restart, force reload as needed
sudo /etc/init.d/monit start sudo /etc/init.d/monit stop sudo /etc/init.d/monit restart sudo /etc/init.d/monit force-reload
- See monit status, summary, unmonitor or monitor all as needed
sudo monit status sudo monit summary sudo monit monitor all sudo monit unmonitor all
- Get extra help. Learn how to start or stop processes. Master monit!
sudo monit -h
- If you prefer a GUI then get it with the below URL (Use the password you set)
http://monit.server.address:2812/
6 comments:
I've not use Monit. I used Nagios but the installation has been a pain. Specially in previous releases. They (Nagios) have gotten better, but I always heard from my sysadmin buddies that Monit is much better than Nagios. As always, nice post Nestor! Let me look into Monit to compare it to Nagios.
couple of tweaks for updating Monit:
make sure libpam-dev is installed
apt_get('libpam-dev')
and specify the prefix on configuration, with bin dir:
./configure --prefix=/usr/sbin --bindir=/usr/sbin --sysconfdir=/etc/monit/
1) monit is good for checking local processes and system state.
2) nagios is good for checking if the host dies or loses network connectivity.
I moved all the process checks I was performing with Nagios to monit. Nagios became a simple ping check.
@Paul we use monit to check if the host is down as well. Just have an external monitoring server (or cluster of them), preferably physical box, and check for protocol and port of your servers. You can check from ICMP to application layer logic. I have not found a use case where I needed to look for alternatives, monit had covered our needs so far.
@sghael: Thanks for the input. That indeed is needed otherwise you might end up with two monit instances one in /usr/sbin and the other below /usr/local/bin. Definitely we want to avoid that. In fact in Ubuntu the default install puts monit in /usr/bin so it makes sense to keep installing it there. I have updated the configure statement now and packaged everything in a POB recipe.
@Marcelo Thanks for your words. I have not used Nagios. Monit is really simple and reliable indeed.
Post a Comment