Monit Installation


Monit
Monit is a free open source and very useful tool that automatically monitors and manages server process, files, directories, checksums, permissions, filesystems and services like Apache, Nginx, MySQL, FTP, SSH, Sendmail and so on in a UNIX/Linux based systems and provides an excellent and helpful monitoring functionality to system administrators.

Features
Monit is a free open source and very useful tool that automatically monitors and manages server process, files, directories, checksums, permissions, filesystems and services like Apache, Nginx, MySQL, FTP, SSH, Sendmail and so on in a UNIX/Linux based systems and provides an excellent and helpful monitoring functionality to system administrators.

The monit has user friendly web interface where you can directly view the system status and setup up processes using native HTTP(S) web server or via the command line interface. This means you must have web server like Apache or Nginx installed on your system to access and view monit web interface.

Monit has a ability to start a process if it is not running, restart a process if not responding and stop a process if uses high resources. Additionally you can also use Monit to Monitor files, directories and filesystems for changes, checksum changes, file size changes or timestamp changes. With Monit you can able to monitor remote hosts TCP/IP port, server protocols and ping. Monit keeps its own log file and alerts about any critical error conditions and recovery status.

Installation of Monit
Updating System
sudo apt-get update

Install Monit From Terminal
sudo apt-get install monit

Configuring Monit Conf File
echo “set httpd port 2812 and
use address localhost  # only accept connection from localhost
allow localhost        # allow localhost to connect to the server and
allow admin:monit      # require user ‘admin’ with password ‘monit’
allow @monit           # allow users of group ‘monit’ to connect (rw)
allow @users readonly  # allow users of group ‘users’ to connect readonly” >> /etc/monit/monitrc

Re-Starting Monit Service
sudo service monit restart

Installation is Completed & Please Check in Web Interface
Please Check http://IP-Address:2812

Login Credentials
Username
admin
Password
monit

snapshot1

System Status

system status

How To Add Monit Services
In Ubuntu & Debian we have to add services in /etc/monit/monitrc
In CentOS & Fedora we have to add services in /etc/monit.conf

Apache2 Service
check process apache with pidfile /run/apache2.pid
start program = “/etc/init.d/apache2 start” with timeout 60 seconds
stop program  = “/etc/init.d/apache2 stop”
    
Mysql Service
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
start program = “/etc/init.d/mysql start”
stop program = “/etc/init.d/mysql stop”

Nginx Service
check process nginx with pidfile /var/run/nginx.pid
start program = “/etc/init.d/nginx start”
stop program = “/etc/init.d/nginx stop”

Sshd Service
check process sshd with pidfile /var/run/sshd.pid
start program “/etc/init.d/sshd start”
stop program “/etc/init.d/sshd stop”
if failed host 127.0.0.1 port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout

Checking Syntax
monit -t

Checking Log Errors
tail -f /var/log/monit.log

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s