#
# 检查进程情况,参数为进程的CPU占比阀值、系统的进程总数阀值、僵尸进程阀值
#
count1=`ps -ef | wc -l`
if [ $2 -le $count1 ]
then
echo "进程数超过正常值: $count1 "
fi
count2=`ps -ef | grep defunc | grep -v grep | wc -l`
if [ $3 -le $count2 ]
then
echo "僵尸进程数超过正常值: $count2 "
fi
rm $TMPDIR/monprocess > /dev/null 2>&1
ps -e -opcpu,pid,args | grep -v "CPU" | awk '{
if ( $1 > limit )
{
printf "进程占CPU高:%s - %s - %s\n", $1,$2,$3
system("> $TMPDIR/monprocess")
}
}' limit=$1
if [ -f $TMPDIR/monprocess -o $count1 -ge $2 -o $count2 -ge $3 ]
then
exit 1
else
echo "进程无异常"
exit 0
fi
阅读(1227) | 评论(0) | 转发(0) |