#!/bin/bash
# This script is to check disk useing
# Author : Yuan
# Date : 2014-7-23
# Warning value : 85
# Critical value : 90
# Email=brisc.yuan@gmail.com
MSG=$0.$$
df | awk 'BEGAIN{StATUS=0}NR>1{mount[$6]=$5}
END{for(M in mount)
if(mount[M]>85)
{
printf("Disk Useing %s\n",mount[M]>90?"Critical":"Warning");
printf("Partion: %s\nUseing : %s\n",M,mount[M]);
STATUS=89;
}
exit STATUS;
}' > $MSG
[ $? -eq 89 ] && cat $MSG
rm -rf $MSG
测试:修改warning:60
# ./check_disk.sh
Disk Useing Warning
Partion: /home/ubuntu
Useing : 76%
测试:修改Critical:70
# ./check_disk.sh
Disk Useing Critical
Partion: /home/ubuntu
Useing : 76%
转载于:https://blog.51cto.com/brisc/1528443