Complete Guide to Installing and Configuring Monit for Effective Monitoring
Monit can be effortlessly installed through apt-get:
$ sudo apt-get install monit
After installation, programs and processes can be added to the configuration file:
$ sudo nano /etc/monit/monitrc
Start Monit using the
monit command to keep it running in the background:
To view Monit’s details, use the command
The Monit daemon 5.3.2 uptime: 1h 25m
Monit is easily configurable out of the box. Default settings include checking services every 2 minutes and storing logs in “/var/log/monit.log”. These settings can be modified at the beginning of the configuration file using the
set daemon and
set logfile lines.
Monit features its own web server running on port 2812. To configure the web interface, uncomment the section beginning with
set httpd port 2812. Add your server’s IP or domain name, allow connections, and create a Monit user and password.
set httpd port 2812
use address 220.127.116.119
After configuring, reload Monit for the changes to take effect:
$ monit reload
Access the web interface at http://18.104.22.1689:2812. A dialog box will appear in the browser.
General Monit Scripts
check process sidekiq_thepact_staging0 with pidfile "/home/deployer/www/staging/shared/tmp/pids/sidekiq.pid"
check process postgres with pidfile /var/run/postgresql/9.5-main.pid
check process puma with pidfile /var/www/myapp/production/shared/tmp/pids/puma.pid
Using the Scripts
By default, Monit does not load conf-scripts in conf-available. To execute them, link the scripts in conf-enabled instead of duplicating them.
$ sudo ln /etc/monit/conf-available/puma /etc/monit/conf-enabled/puma