Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.
How to check Monit configuration?
Check server status with the following command:
$ sudo monit status
At this point you should see the servers that Monit is monitoring and the machine statistics:
The Monit daemon 5.5.1 uptime: 1d 19h 35m Process 'mysql' status Running monitoring status Monitored pid 27154 parent pid 26893 uptime 1m children 0 memory kilobytes 38428 memory kilobytes total 38428 memory percent 0.2% memory percent total 0.2% cpu percent 0.0% cpu percent total 0.0% data collected Thu, 15 Aug 2013 13:39:06 Process 'apache' status Running monitoring status Monitored pid 27205 parent pid 1 uptime 1m children 8 memory kilobytes 13500 memory kilobytes total 86504 memory percent 0.0% memory percent total 0.5% cpu percent 0.0% cpu percent total 0.0% data collected Thu, 15 Aug 2013 13:39:06 System 'desktop' status Running monitoring status Monitored load average [0.14] [0.21] [0.22] cpu 0.9%us 0.7%sy 0.0%wa memory usage 7113496 kB [43.5%] swap usage 182008 kB [1.1%] data collected Thu, 15 Aug 2013 13:39:06
Monit also includes a small Web application to manage the servers. It only works from localhost by default but you can add other IP addresses in the /opt/bitnami/config/monit/bitnami.conf configuration file:
# Bitnami configuration file for Monit. set httpd port 2812 and use address localhost allow localhost include /opt/bitnami/config/monit/conf.d/*.conf
The Monit Server Manager can be accessed at http://SERVER-IP:2812 and looks like this:
How to configure my server with Monit?
You can find all Monit configuration files for the Bitnami servers in the /opt/bitnami/config/monit/conf.d folder. For example, the Apache Monit config file looks like this:
check process apache with pidfile "/opt/bitnami/apache2/logs/httpd.pid" start program = "/opt/bitnami/apache2/scripts/ctl.sh start" with timeout 90 seconds stop program = "/opt/bitnami/apache2/scripts/ctl.sh stop"
As you can see in the above example, it is only necessary to specify the PID file location and the commands to start/stop the server. You can find more configuration options at the Monit documentation.
Once you create your own config file for your server, add it to the same folder. To reinitialize Monit, run the following command:
$ sudo monit reload
How to disable Monit?
To disable a server, run the following command to disable it. For example, to disable the Apache server:
$ sudo monit unmonitor apache
You can also stop the Monit process with the following command:
$ sudo monit quit
How to enable Monit?
Recent versions of Bitnami stacks ship Monit configuration files for all servers. On cloud servers and virtual machines, Monit is already configured and enabled by default.