WEB开发网
开发学院服务器WEB服务器Apache 如何检测和重启Apache和Lighttpd 阅读

如何检测和重启Apache和Lighttpd

 2007-03-04 00:00:00 来源:WEB开发网   
核心提示: check process mysqld with pidfile /var/run/mysqld/mysqld.pidgroup databasestart program = "/etc/init.d/mysqld start"stop program = "/

check 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 timeout

Here is my sshd server configuration directives:

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

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/messageOutput:

Nov 21 04:39:21 server monit[8759]: Starting monit daemon
Nov 21 04:39:21 server monit[8759]: Monit started

If 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/lighttpd

You 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

Further readings
  • monit man page
  • monit official web site and documenation
  • 上一页  1 2 3 4 

    Tags:如何 检测 重启

    编辑录入:爽爽 [复制链接] [打 印]
    赞助商链接