[root@web1 tools]# cat fetion-alarm
#!/bin/bash
sendfetion ()
{
echo "mail-PC alarm" >> /usr/src/install/error-fetion
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=15011119,13511111 --file-gb=/usr/src/install/error-fetion --msg-type=1
}
memory_unused=`free -m | grep Mem: | awk '{print $4}'`
if [ $memory_unused -lt 900 ];then
echo "mail-PC alarm:" > /usr/src/install/error-fetion
echo `free -m | grep "Mem:"` >> /usr/src/install/error-fetion
date >> /usr/src/install/error-fetion-number
send_fetion_number=`cat /usr/src/install/error-fetion-number | wc -l`
if [ $send_fetion_number -eq 1 ];then
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=150111111,135111110 --file-gb=/usr/local/src/install/error-fetion --msg-type=1
elif [ $send_fetion_number -eq 12 ];then
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=1500000,1351111 --file-gb=/usr/local/src/install/error-fetion --msg-type=1
rm -f /usr/src/install/error-fetion-number
else
echo "please dispose of the problem"
fi
fi
hard_disk_used_space=`df -h | grep /$ | awk '{print $4}' | sed 's/%//'`
if [ $hard_disk_used_space -gt 5 ];then
df -h | grep /$ > /usr/src/install/error-fetion
sendfetion
fi
cup_used=`ps aux | awk '{print $3}' |awk 'BEGIN{sum=0}{sum+=$1}END{print sum}'`
cup_used_judge=`echo "$cup_used > 5" | bc`
if [ $cup_used_judge -eq 1 ];then
echo "mail-PC alarm:" > /usr/src/install/error-fetion
echo CPU%:`ps aux | awk '{print $3}' |awk 'BEGIN{sum=0}{sum+=$1}END{print sum}'`% >> /usr/src/install/error-fetion
echo mpstat: `mpstat | grep PM` >> /usr/src/install/error-fetion
echo uptime: `uptime` >> /usr/src/install/error-fetion
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=1500000,1351111 --file-gb=/usr/src/install/error-fetion --msg-type=1
fi
postfix_status=`service postfix status | grep "running" | wc -c`
if [ $postfix_status -lt 10 ];then
echo "mail-PC alarm:" > /usr/src/install/error-fetion
echo "service postfix is stopped" >> /usr/src/install/error-fetion
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=1500000,1351111 --file-gb=/usr/src/install/error-fetion --msg-type=1
fi
openvpn_status=`ps axu | grep "/sbin/openvpn" | grep -v "grep /sbin/openvpn" | awk '{print $2}'`
if [ -z $openvpn_status ];then
echo "mail-PC alarm:" > /usr/src/install/error-fetion
echo "openvpn is stopped" >> /usr/src/install/error-fetion
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=1500000,1351111 --file-gb=/usr/src/install/error-fetion --msg-type=1
fi
apache_status=`service httpd status | grep "running" | wc -c`
if [ $apache_status -lt 10 ];then
echo "mail-PC alarm:" > /usr/src/install/error-fetion
echo "service httpd is stopped" >> /usr/src/install/error-fetion
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=1500000,1351111 --file-gb=/usr/src/install/error-fetion --msg-type=1
fi
mysql_status=`service mysqld status | grep "running" | wc -c`
if [ $mysql_status -lt 10 ];then
echo "mail-PC alarm:" > /usr/src/install/error-fetion
echo "service mysqld is stopped" >> /usr/src/install/error-fetion
/usr/src/install/fetion --sid=926712761 --pwd=aaaaaa@ --to=1500000,1351111 --file-gb=/usr/src/install/error-fetion --msg-type=1
fi