CPU 报警, 系统为 centos7.2, 用于其他系统需要改位置变量.
- #!/bin/bash
- if [-e /detection_script]
- then
- mkdir -p /detection_script/
- else
- mkdir -p /detection_script/
- fi
- IP=
ip a | grep inet | grep -v inet6 | grep -v 127 | sed 's/^[ \t]*//g' | cut -d ' ' -f2
- AA=
- /usr/bin/uptime | awk -F'[\t. ]' '{print $(NF-1)}'
- if [ $AA -ge 5 ]
- then
echo "dev: 当前 $IP 地址 cpu 已达到理论峰值 5%
15 分钟值为: $AA"| mail -s"$Ip":CPU 异常 amunlinux@163.com
fi
/bin/mv cpuload_new.sh /detection_script/
来源: http://www.bubuko.com/infodetail-2565423.html