shell脚本第三篇——监控主机的磁盘空间,当使用空间超过90%就通过发mail来发警告

#!/bin/bash
#monitor available disk space
IP=`ifconfig eth0 | grep "inet addr" | cut -f 2 -d ":" | cut -f 1 -d " "`
SPACE=` df -hP | awk '{print int($5)}'`
if [ $SPACE -ge 90 ]
then
  echo "$IP 服务器的磁盘空间使用率已经超过90%,请处理!"| mail -s "$IP 服务器硬盘告警" lili@163.com
fi