Apache和Lighttpd监控插件 |
| 发表者:分类:Devops2012-10-12 18:41:02 阅读[2408] |
Apache和Lighttpd监控插件
Monit是一款功能非常丰富的进程、文件、目录和设备的监测软件,用于Unix平台。它可以自动修复那些已经停止运作的程序,
特使适合处理那些由于多种原因导致的软件错误。# wget http://www.tildeslash.com/monit/dist/monit-4.8.2.tar.gz
# tar -zcvf monit-4.8.2.tar.gz
# cd monit-4.8.2
# ./configure
# make
# make install
# cp monitrc /etc/monitrc
By default monit is located at /usr/local/bin/monit
centos /etc/monitrc
Debian /etc/monit/monitrc
# vi /etc/monitrc
set daemon 120 set logfile syslog facility log_daemon
set mailserver mail.cyberciti.biz set mail-format { from: alert@nixcraft.in
subject: $SERVICE $EVENT at $DATE
message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
}
check process lighttpd with pidfile /var/run/lighttpd.pid
group lighttpd
start program = "/etc/init.d/lighttpd start"
stop program = "/etc/init.d/lighttpd stop"
if failed host 75.126.43.232 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeoutcheck process mysqld with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeoutcheck 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
Replace IP address 127.0.0.1 with your actual IP address. If you are using Debian just start monit:# /etc/init.d/monit start
If you are using Red Hat Enterprise Linux , start monit from /etc/inittab file:
Open /etc/inittab file:# vi /etc/inittab
Append following line:mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
Now start monit:# inittab -q
You can verify that monit is started from /var/log/message log file:# tail -f /var/log/message Output:
Nov 21 04:39:21 server monit[8759]: Starting monit daemon
Nov 21 04:39:21 server monit[8759]: Monit startedIf lighttpd died, you will see something as follows in log file:
Nov 21 04:45:13 server monit[8759]: 'lighttpd' process is not running
Nov 21 04:45:13 server monit[8759]: 'lighttpd' trying to restart
Nov 21 04:45:13 server monit[8759]: 'lighttpd' start: /etc/init.d/lighttpdYou may use monit to monitor daemon processes or similar programs running on localhost or started from /etc/init.d/ location such as
=> Apache Web Server
=> SSH Server
=> Postfix/Sendmail MTA
=> MySQL etc
转载请标明出处【Apache和Lighttpd监控插件】。
《www.micoder.cc》
虚拟化云计算,系统运维,安全技术服务.
| Tags: | [阅读全文...] |
最新评论