#!/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://blog.51cto.com/amunlinux/2104356