posts - 6, comments - 0, trackbacks - 0, articles - 0

linux 服务器监控脚本

Posted on 2010-12-14 16:10 rainingcn 阅读(248) 评论(0)  编辑  收藏
有时需要在服务器上每隔一段时间运行一段命令,以监控服务器性能。可以用crontab来做。
但是秒级的需要自己写shell脚本。
比如监控apache:
#!/bin/sh
echo 
"==========1.httpd==2.total connection==3.wait connection====4.jboss connection"
rp
=1
while rp=1
do
echo 
"================="
date 
-d today +"%T"
#show apache thread count
ps -ef|grep httpd|wc -l
#show total clients
netstat 
-ant|grep 10.108.10.2|wc -l
#show time_wait or ESTABLISHED clients
netstat 
-ant|grep ffff|wc -l
#show jboss connection
netstat 
-ant|grep 10.108.7.7|wc -l
sleep 
1
done

运行脚本前莫忘 chmod +x filename

只有注册用户登录后才能发表评论。


网站导航: