Many of you already know about a famous project nagios (http://nagios.org) to provide IT infrastructure monitoring. However, there are other tools (at small scale or not very well known) as well. On a linux-based systems such as Ubuntu, process monitoring automation is very simple with the use of Monit project (http://mmonit.com/monit/). It can help you monitor your processes, services, files and provide a very simple web-interface to see the status of the monitored objects.
Installation
Monit supports multiple operating systems Linux, Mac OS, and BSD. You can install from source, or git repository. On Ubuntu, it is also available in standard ubuntu repository. Using apt-get, it can be installed on Ubuntu.sudo apt-get install monit
Once it is installed, it can be configured to monitor programs/services. For this, edit its configuration file located on '/etc/monit/monitrc' and add your programs.
HTTP interface
Monit comes with its own HTTP interface with its own server. To configure it, add the following section in /etc/monit/monitrc file if not present or uncomment these lines.
set httpd port 2812 use address 12.34.56.789 # only accept connection from localhost allow localhost # allow localhost to connect to the server and allow admin:monit # require user 'admin' with password 'monit'
This feature has to be enabled because its CLI also access the background process via HTTP. The limitation with this configuration is that monit can not be accessed from outside. All requests coming from outside are denied. However, it can be avoided if 'allow localhost' is commented or use some other IP range you want to connect from. Connecting from outside will require you to enter the configured user and password. Once configurations are written, it can be reloaded in monit with the following command.
monit reload
After the successful web login, you should see the following interface.
Example: Monitor Apache2
A very simple configuration to monitor your apache2 service, you need to edit the /etc/monit/monitrc file
check process apache with pidfile /var/run/apache2/apache2.pid
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
if cpu > 70% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if failed host localhost port 80 protocol http for 5 cycles
then restart
More information about configurations can be found here http://mmonit.com/monit/documentation/monit.html
Monit helps in providing monitoring capabilities for a single instance (machine). In order to acquire and collect a collective view of multiple monit instances, M/Monit project can be used (will be discuss in later post).
Other project for the same purpose is GOD (http://godrb.com/) etc. Another project that is based on Cassandra (a NoSQL database) is Munin (http://munin-monitoring.org/) that provides charting capabilities as well. it generates multiple charts such as load on CPU, memory consumption etc.