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, Sendmailand 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.
Installing Moint for CentOS / Redhat / Fedora
-----------------------------------------------------------
yum install epel*
yum install monit
/etc/init.d/monit start
chkconfig monit on
# We can see logs from tail -f /var/log/monit
## Config file
vi /etc/monit.conf
** Can change those default settings
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'
----------- to
set httpd port 2812 and
use address 203.190.X.X # only accept connection from server 203.190.X.X
allow 203.190.X.0/21 # allow IP-Network to connect to the server and
allow admin:tayab321 # require user 'admin' with password 'tayab321'
http://203.190.x.x:2812/
username: admin
password: tayab321
##########
Adding other services to Monit
-------------------------------------
# Adding HTTP service to Monitor
check process httpd with pidfile /var/run/httpd/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 203.190.X.X port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout
# Adding MySQL service to Monitor
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group mysql
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 203.190.10.90 port 3306 then restart
if 5 restarts within 5 cycles then timeout
# Adding MAIL POSTFIX service to Monitor
check process postfix with pidfile /var/spool/postfix/pid/master.pid
start program = "/etc/init.d/postfix start"
stop program = "/etc/init.d/postfix stop"
if cpu > 60% 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 203.190.x.x port 25 type tcp protocol smtp
with timeout 15 seconds
then alert
if 3 restarts within 5 cycles then timeout
start program = "/etc/init.d/postfix start"
stop program = "/etc/init.d/postfix stop"
if cpu > 60% 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 203.190.x.x port 25 type tcp protocol smtp
with timeout 15 seconds
then alert
if 3 restarts within 5 cycles then timeout
# Adding SSH service to Monitor
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 203.190.X.X port 7707 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
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 203.190.X.X port 7707 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
## To check monit syntax error in config file :: monit -t
####### Enjoy this #tayab@tayabkhan.com###################################
####### Enjoy this #tayab@tayabkhan.com###################################
No comments:
Post a Comment