磁盘监控报警-nagios

#!/bin/sh

#define alert devel of nagios
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKOWN=3
above=0

list=`df -h|grep -v "Filesystem"|grep -v "devfs"|awk '{print $6}'`

for disk_name in $list;do
        url=`df -h|grep $disk_name`
        size=`echo $url|awk -F\  '{print "size:" $2}'`;
        used=`echo $url|awk -F\  '{print "used:" $3}'`;
        avail=`echo $url|awk -F\  '{print "avail:" $4}'`;
        capacity=`echo $url|awk -F\  '{print $5}'`;
        mounted=`echo $url|awk -F\  '{print "mounted:" $6}'`;
 
        percent=`echo $capacity |sed 's/%//g'`
           #echo $percent
                #echo -e $size $used $avail "capacity:"$capacity $mounted
         if [ "$percent" -ge 70 ];then
                above=1
                echo "the disk $mounted space used above 70%"
                echo $size $used $avail "capacity:"$capacity $mounted
                exit $STATE_WARNING
         else
                above=0
         fi
done;

if [ "$above" -eq 0 ];then
         echo "the disk used of space normal"
         exit $STATE_OK
else
         echo "the disk used state unkonw"
         exit $STATE_CRITICAL
fi


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值