标签:表示 print pac pfile 监控 echo rom roo art
#!/bin/bash partition_list=(`df -h | awk ‘NF>3&&NR>1{sub(/%/,"",$(NF-1));print $NF,$(NF-1)}‘`) notification_email() { emailuser=‘sunzy@163.com‘ emailpasswd=‘*****‘ emailsmtp=‘smtp.163.com‘ sendto=‘7589457343@qq.com‘ title=‘Disk Space Alarm‘ /usr/sbin/sendmail -f $emailuser -t $sendto -s $emailsmtp -u $title -xu $emailuser -xp $emailpasswd } critical=80 crit_info="" for (( i=0;i<${#partition_list[@]};i+=2 )) do if [ "${partition_list[((i+1))]}" -lt "$critical" ];then echo "OK! ${partition_list[i]} used ${partition_list[((i+1))]}%" else if [ "${partition_list[((i+1))]}" -gt "$critical" ];then crit_info=$crit_info"Warning!!! ${partition_list[i]} used ${partition_list[((i+1))]}%\n" fi fi done if [ "$crit_info" != "" ];then echo -e $crit_info | notification_email fi
标签:表示 print pac pfile 监控 echo rom roo art
原文地址:http://www.cnblogs.com/sunziying/p/6390199.html