Monit is a light weight open source utility which can be used for monitoring & maintenance of a wide variety of system attributes. We can use monit to check for resource utilization, service status, inode count, existence of scripts & even file/directory permissions. We can configure monit to restart services if they are not found to be in a running state.
We can also setup centralized monitoring using Nmonit. In this setup the server on which we install nmonit would be the centralized management host from where we can manage other hosts on which monit is installed under a 'single pane of glass' view.
Installation & setup:
Monit is available in the epel repository as well as a source. I downloaded the source from the official website & it essentially consisted of the monit binary along with the monit configuration file monitrc.
The setup was fairly straightforward. I copied the monit binary to /etc/init.d & monitrc file to /etc. I commented out the 'use address' & 'allow' directives so that the monit GUI interface is accessible from other hosts within the same network.
To start the monit service just type 'monit'.
Once started the monit GUI interface will be accessible on
http://<IP address>:2812
Once started we can view the status of the attributes monitored by monit by running the command monit status. Monit polls the attributes every 5 seconds & the status of the monitored resources is refreshed.
Configuration:
The monit configuration file monitrc has a lot of sample configurations that we can use. A lot of configuration examples & other information can be found on the Monit wiki here.
Here are a few attributes I configured in the monitrc file for monit to keep an eye on:
[root@centops ~]# tail -15 /etc/monitrc
#
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 port 22 protocol ssh then restart
check process jobber with pidfile /var/run/jobber.pid
start program "/etc/init.d/jobber start"
stop program "/etc/init.d/jobber stop"
check directory check_dir with path /check_dir
if failed permission 755 then alert
if failed uid 0 then alert
if failed gid 0 then alert
[root@centops ~]#
Demo:
Off course the article would be incomplete if there isn't a demo in the end. So, from the attributes we configured to be monitored lets pick the directory.
Here is the status of /check_dir directory:
Now If I play around with the permissions & change them to something other tahn 755 monit we notice this the next time it does polls the attribute & will throw an alert like we see in the screen below:
We can also setup centralized monitoring using Nmonit. In this setup the server on which we install nmonit would be the centralized management host from where we can manage other hosts on which monit is installed under a 'single pane of glass' view.
Installation & setup:
Monit is available in the epel repository as well as a source. I downloaded the source from the official website & it essentially consisted of the monit binary along with the monit configuration file monitrc.
The setup was fairly straightforward. I copied the monit binary to /etc/init.d & monitrc file to /etc. I commented out the 'use address' & 'allow' directives so that the monit GUI interface is accessible from other hosts within the same network.
To start the monit service just type 'monit'.
Once started the monit GUI interface will be accessible on
http://<IP address>:2812
Once started we can view the status of the attributes monitored by monit by running the command monit status. Monit polls the attributes every 5 seconds & the status of the monitored resources is refreshed.
Configuration:
The monit configuration file monitrc has a lot of sample configurations that we can use. A lot of configuration examples & other information can be found on the Monit wiki here.
Here are a few attributes I configured in the monitrc file for monit to keep an eye on:
[root@centops ~]# tail -15 /etc/monitrc
#
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 port 22 protocol ssh then restart
check process jobber with pidfile /var/run/jobber.pid
start program "/etc/init.d/jobber start"
stop program "/etc/init.d/jobber stop"
check directory check_dir with path /check_dir
if failed permission 755 then alert
if failed uid 0 then alert
if failed gid 0 then alert
[root@centops ~]#
In the above example, monit will monitor the status of sshd & jobber services & the ownership/permissions of directory /check_dir.
Here's a view of the GUI:
Demo:
Off course the article would be incomplete if there isn't a demo in the end. So, from the attributes we configured to be monitored lets pick the directory.
Here is the status of /check_dir directory:
Now If I play around with the permissions & change them to something other tahn 755 monit we notice this the next time it does polls the attribute & will throw an alert like we see in the screen below:
No comments:
Post a Comment