本文共 1164 字,大约阅读时间需要 3 分钟。
#!/bin/bash row=`df -hP|wc -l` status=0 for i in `seq 2 $row` do spare=`df -hP|sed -n "$i"p|awk '{print $4}'` use_percentage=`df -hP|sed -n "$i"p|sed -n "s/\%//"p|awk '{print $5}'` spare_percentage=`expr 100 - $use_percentage` partition_name=`df -hP|sed -n "$i"p|awk '{print $6}'` if [ "$spare_percentage" -lt "3" ];then echo -n "$partition_name CRITICAL ${spare_percentage}% $spare " status[$i]=2 elif [ "$spare_percentage" -lt "5" ];then echo -n "$partition_name WARNING! ${spare_percentage}% $spare " status[$i]=1 else echo -n "$partition_name OK ${spare_percentage}% $spare " status[$i]=0 fi done zhuangtai=0 for j in `seq 2 $row` do if [ "${status[$j]}" -gt "$zhuangtai" ];then zhuangtai=${status[$j]} else echo fi done exit
转载于:https://blog.51cto.com/liuxiaolan/1617910