#!/bin/sh
NUM=`uptime | awk -F ',' '{print $4}' | awk -F ' ' '{print $3}'` echo $NUM >/tmp/num.log num=`tail -n1 /tmp/num.log | awk -F '.' '{print $1}'` n1=`ps -ef|grep httpd | grep -v grep| wc -l ` n2=`netstat -nat|grep -i "80" | grep -v grep | wc -l` n3=`netstat -na | grep ESTABLISHED | wc -l` log="/tmp/log"if [ $num -gt 10 ]
then echo "start at `date +%D" "%T` , load_num=$NUM,http_80=$n1,ESTABLISHED=$n2" >> $log mysql -p3333 -e 'show processlist;' >> $log /qeedoodb/sendEmail-v1.55/sendEmail -f -t test1 -s s.test.com -xu -xp 123 -u CPU负载异常 -m load_num=$NUM,http_80=$n1,ESTABLISHED=$n2 fi