#!/bin/bash
DATE=$(date +%F" "%H:%M)
#只支持centos6
IP=$(ifconfig eth0 | awk -F '[ :]+' '/inet addr/{print $4}')
MAIL="13102133719@126.com"
if ! which vmstat &>/dev/null; then
        echo "vmstat command no found, Please install procps package."
fi
US=$(vmstat | awk 'NR==3{print $13}')
SY=$(vmstat | awk 'NR==3{print $14}')
IDLE=$(vmstat | awk 'NR==3{print $15}')
WAIT=$(vmstat | awk 'NR==3{print $16}')
USE=$(($US+$SY))
if [ $USE -ge 50 ]; then
        echo "
        Date: $DATE
        Host: $IP
        Problem: CPU utilization $USE
        " | mail -s "CPU Monitor" $MAIL
fi

 

相关文章:

  • 2021-09-29
  • 2021-09-10
  • 2022-01-22
  • 2021-06-03
  • 2021-04-17
猜你喜欢
  • 2021-12-03
  • 2021-08-12
  • 2022-12-23
  • 2021-08-20
  • 2021-07-24
  • 2021-12-09
  • 2021-10-29
相关资源
相似解决方案