啥也没写
分类: LINUX
2010-05-27 22:26:54
公司运营服务器的http、squid、snmp进程有时莫名其妙自己挂掉,光靠手动启动实在是太麻烦,用google搜索“process monitor”意外找到ps-watcher这个小工具,试验后觉得非常好用,可以监控指定的进程状态,进程挂掉后自动重新启动进程。
文档:
下载:
安装
# cd ps-watcher-1.06
# ./configure –prefix=/usr/local/ps-watcher
安装缺少的perl模块
Need package “Config::IniFiles”: Can’t locate Config/IniFiles.pm in @INC
# perl -MCPAN -e shell
Are you ready for manual configuration? [yes] no
cpan> i /IniFiles/
cpan> install Config::IniFiles
cpan> exit
# ./configure –prefix=/usr/local/ps-watch
# make
# make check
# make install
# /usr/local/ps-watcher/bin/ps-watcher –config /usr/local/ps-watcher/bin/config.ini –log /usr/local/ps-watcher/bin/ps-watcher.log
config.ini示例
监控httpd与squid进程
ps-watcher每300秒检查进行,当发现httpd进程消失时,重新执行它们。
# vi config.ini
[(/usr/local/apache2/bin/)?httpd]
occurs = none
action = /usr/local/apache2/bin/apachectl -k start
[(/usr/local/squid/sbin/)?squid]
occurs = none
action = /usr/local/squid/sbin/squid -Ds
显示进程数
# vi config.ini
[httpd]
action = echo “There are $count instances of httpd running”
# tail –f log
ps-watcher: Starting: $Id: ps-watcher.in.in,v 1.25 2003/07/10 11:50:21 rockyb Exp $
ps-watcher: There are 16 instances of httpd running
统计进程数
# vi config.ini
[httpd]
trigger = $count < 17
action = echo “There are $count instances of httpd running – less than 17″
# tail log
ps-watcher: Starting: $Id: ps-watcher.in.in,v 1.25 2003/07/10 11:50:21 rockyb Exp $
ps-watcher: There are 16 instances of httpd running – less than 17