Original works, allow reprint, please be sure to use hyperlinks in the form of the original source of the article, author information and this statement. Otherwise, the legal liability will be investigated. http://coolerfeng.blog.51cto.com/133059/50126 Monit is a highly functional monitoring software for processes, files, directories, and devices for UNIX platforms. It automatically fixes programs that have ceased to operate, and envoys are suitable for handling software errors that can be caused by a variety of reasons. Monit running on the application layerInstallation is simple, trilogy #./configure#make#make install copy config file # cp monitrc/etc/monitrc Next we modify this configuration file based on the actual situation set Daemon # Poll at 2-min Ute intervals//Check every 2 minutes
Set Logfile/home/monit/log/monit.log//monit log file
Set Alert[email protected]With reminder on 1 cycle//1 times the error occurred when sending an alarm message to the specified mailbox
#set mailserver mail.tildeslash.com, mail.foo.bar Port 10025, localhost with Tim
Eout seconds
Set MailServer 10.10.9.109//Setup mail server Set httpd port 2812 and use address 10.10.8.2//Set HTTP Monitoring page port and IP
Allow localhost # enable localhost to connect//allows native access
Allow 10.10.8.0/24//allows this IP segment access
Allow Admin:nishiwode # allow Basic Auth//authenticated user name and password # all system Average load. Memory usage, CPU usage
Check System 10.10.8.2
If Loadavg (1min) > 4 then alert
If Loadavg (5min) > 2 then alert
If memory usage > 75% then alert
If CPU usage (user) > 70% then alert
If CPU usage (System) > 30% then alert
If CPU usage (wait) > 20% then alert# all disk//disk space usage
Check device data with Path/dev/sda2
If space usage > 90% then alert
If inode usage > 85% then alertcheck device home with Path/dev/sda3
If space usage > 85% then alert
If inode usage > 85% then alert
# all rsync#10.10.8.2
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 protocol ssh then restart
If 5 restarts within 5 cycles then timeout//monitoring SSH Service
Check process httpd with Pidfile/var/run/httpd.pid
Group Apache
Start program = "/ETC/INIT.D/HTTPD start"
Stop program = "/ETC/INIT.D/HTTPD Stop"
If failed host 127.0.0.1 Port 80
Protocol HTTP then restart
If 5 restarts within 5 cycles then timeout
Monitoring HTTP Services
Monitoring Custom Services
Check process web_lb with Pidfile/data/v20/server/web_lb/httpd.pid
Start program = "/data/v20/bin/lb.sh"//Startup script
Stop program = "/data/v20/bin/lb_stop.sh"//Stop Script
If failed host 10.10.8.2 Port 16101 Proto HTTP then restart
If failed host 10.10.8.2 Port 16101 proto HTTP for 5 times within 5 cycles t
Hen exec "/data/v20/bin/lb_pay.sh"
If failed host 10.10.8.2 port 16102 type Tcpssl Proto HTTP then restart
If failed host 10.10.8.2 port 16102 type Tcpssl proto HTTP for 5 times Withi
N 5 Cycles then exec "/data/v20/bin/lb_pay.sh
Rhel can start Monit in the following ways
# Vi/etc/inittab
Add to:
Mo:2345:respawn:/usr/local/bin/monit-ic/etc/monitrcnow Start Monit:
# init-q or # Telinit-q
You can verify this monit is started from/var/log/message log file:
# tail-f/var/log/message
If normal startup can see the following output:
Nov 04:39:21 Server monit[8759]: starting Monit daemon
Nov 04:39:21 Server monit[8759]: Monit started
Finally, you can test it to see if there is any effect that will satisfy you.
This article is from the "Wind Blowing Cloud" blog, please be sure to keep this source http://coolerfeng.blog.51cto.com/133059/50126
Monit Monitor and restart the service automatically