Monit is a monitoring software that provides rich functions for processes, files, directories, and devices. It is used on UNIX platforms. It can automatically fix stopped programs and is suitable for the Special Envoy to handle software errors caused by multiple reasons. Monit runs on the application layer and is easy to install. trilogy #. /configure # Make # make install copy the configuration file # cp monitrc/etc/monitrc next we will modify this configuration file Set Daemon 120 # poll at 2-minute intervals // check once every 2 minutes
Set logfile/home/monit/log/monit. Log // the log file of monit
Set alert zhouwei@chinabank.com.cn with reminder on 1 cycle // send an alert email to the specified mailbox when an error occurs
# Set MailServer mail.tildeslash.com, mail. Foo. Bar port 10025, localhost with Tim
Eout 15 seconds
Set MailServer 10.10.9.109 // set the mail server set httpd port 2812 and use address 10.10.8.2 // set the port and IP address on the HTTP monitoring page
Allow localhost # allow localhost to connect // allow local access
Allow 10.10.8.0/24 // allow access from this IP address segment
Allow admin: nishiwode # Allow basic auth // user name and password for authentication # All system // average load. memory usage, CPU usage
Check System 10.10.8.2
If loadavg (1 min)> 4 then alert
If loadavg (5 min)> 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 22 protocol SSH then restart
If 5 restarts within 5 cycles then timeout // monitor the 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
// Monitor HTTP Services // monitor custom services
Check process web_lb with pidfile/data/V20/Server/web_lb/httpd. PID
Start program = "/data/V20/bin/lb. Sh" // start the script
Stop program = "/data/V20/bin/lb_stop.sh" // stop the 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.shrhel can be started using the following method:
# Vi/etc/inittab
Add:
MO: 2345: respawn:/usr/local/bin/monit-ic/etc/monitrc
Now start monit:
# Init-Q or # telinit-Q
You can verify that monit is started from/var/log/message log file:
# Tail-F/var/log/message
If it is started properly, the following output is displayed:
Nov 21 04:39:21 server monit [2, 8759]: Starting monit daemon
Nov 21 04:39:21 server monit [2, 8759]: monit started