shell CPU 使用率

shell CPU 使用率

  • CPU.sh
MAX=95
EMAIL=[email protected]

USE=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage ""}')
USE=`printf "%.0f\n" $USE`
if [[ $USE -gt $MAX ]]; then
   echo "Percent used: $USE" | mail -s "Running out of CPU power" $EMAIL
else
   echo "all is well !"
fi

执行:

$ bash CPU.sh
all is well !

更多阅读:

猜你喜欢

转载自blog.csdn.net/xixihahalelehehe/article/details/125176134