#!/bin/sh
#check disk
df -k | grep -vE "none|devfs" |awk '{if(NR>=2)print int()}'>/tmp/_disk.tmp
for _DISK in `cat /tmp/_disk.tmp`
do
if [ "$_DISK" -ge "90" ]
then
df -k >/tmp/mail.tmp
else
exit;
fi
done
#check %cpu
#cpu负荷超过90%,不知是不是指%cpu,如果是
top -b -d 1 -n 1 | grep -v 'top -d 1 -n 1'|awk 'NR >=8 && NR <=20 {print }'>/tmp/_top.tmp
for _TOP in `cat /tmp/_top.tmp`
do
if [ "$_TOP" -ge "90" ]
then
top -b -d 1 -n 1 | grep -v 'top -d 1 -n 1'|awk 'NR >=8 && NR <=20 {print #!/bin/sh
#check disk
df -k | grep -vE "none|devfs" |awk '{if(NR>=2)print int()}'>/tmp/_disk.tmp
for _DISK in `cat /tmp/_disk.tmp`
do
if [ "$_DISK" -ge "90" ]
then
df -k >/tmp/mail.tmp
else
exit;
fi
done
#check %cpu
#cpu负荷超过90%,不知是不是指%cpu,如果是
top -b -d 1 -n 1 | grep -v 'top -d 1 -n 1'|awk 'NR >=8 && NR <=20 {print }'>/tmp/_top.tmp
for _TOP in `cat /tmp/_top.tmp`
do
if [ "$_TOP" -ge "90" ]
then
top -b -d 1 -n 1 | grep -v 'top -d 1 -n 1'|awk 'NR >=8 && NR <=20 {print }'>>/tmp/mail.tmp
else
exit;
fi
done
FILE=`ls -l /tmp/mail.tmp | awk '{print }'`
if [ $FILE -ge "30" ]
then
mail -s xxx xxx@xxx.com else
exit;
fi
}'>>/tmp/mail.tmp
else
exit;
fi
done
FILE=`ls -l /tmp/mail.tmp | awk '{print }'`
if [ $FILE -ge "30" ]
then
mail -s xxx xxx@xxx.com else
exit;
fi
阅读(557) | 评论(0) | 转发(0) |