邮件监控存储卷空间的脚本:
说明:
1、显示存储名、ip、卷名、total空间、free空间、1天用空间、已用百分比
2、对卷名字符数的统计(echo aa1 | wc -m)
3、对卷名部分的排除,只保留数值部分(/usr/lib64/nagios/plugins/check-netapp-ng2.pl -H 10.0.0.16 -C public -T DISKUSED -v /vol/$eNas/ -w 80 -c 90 | awk -F[:" "]+ '{print $5}' | tr -d ';' | cut -b "$Wcc-$Wf")
4、KB转换为GB(echo $Tootal | awk '{$1/=1024*1024;printf "%.0fGB\n",$1})
#!/bin/bash
Date=`date +%Y%m%d`
Date2=`date +%Y%m%d -d "7 days ago"`
Date3=`date +%Y%m%d -d "1 days ago"`
Nas_all="10.0.0.16 10.0.18 10.0.1.11"
eNas1="aa1 aa2 aa3"
eNas2="bb1 bb2 bb3"
#echo "nas1(10.0.0.16) each volume usage" > /log/vol/$Date.log
echo " " > /log/vol/$Date.log
for eNas in $eNas1
do
Wc=`echo /vol/$eNas/ | wc -m`
Wcc=$(($Wc + 1))
Avg=`/usr/lib64/nagios/plugins/check-netapp-ng.pl -H 10.0.0.16 -C public -T DISKUSED -v /vol/$eNas/ -w 80 -c 90 | awk -F[:" "]+ '{print $7}' | cut -b 6-8 | tr -d ';'`
Free=`/usr/lib64/nagios/plugins/check-netapp-ng2.pl -H 10.0.0.16 -C public -T DISKUSED -v /vol/$eNas/ -w 80 -c 90 | awk -F[:" "]+ '{print $5}' | tr -d ';'`
Wf=`echo $Free | wc -m`
Frree=`/usr/lib64/nagios/plugins/check-netapp-ng2.pl -H 10.0.0.16 -C public -T DISKUSED -v /vol/$eNas/ -w 80 -c 90 | awk -F[:" "]+ '{print $5}' | tr -d ';' | cut -b "$Wcc-$Wf"`
Freee=`echo $Frree | awk '{$1/=1024*1024;printf "%.0fGB\n",$1}'`
Total=`/usr/lib64/nagios/plugins/check-netapp-ng3.pl -H 10.0.0.16 -C public -T DISKUSED -v /vol/$eNas/ -w 80 -c 90 | awk -F[:" "]+ '{print $5}' | tr -d ';'`
Wt=`echo $Total | wc -m`
Tootal=`/usr/lib64/nagios/plugins/check-netapp-ng3.pl -H 10.0.0.16 -C public -T DISKUSED -v /vol/$eNas/ -w 80 -c 90 | awk -F[:" "]+ '{print $5}' | tr -d ';' | cut -b "$Wcc-$Wt"`
Totall=`echo $Tootal | awk '{$1/=1024*1024;printf "%.0fGB\n",$1}'`
Dfree=`echo $Freee | tr -d 'GB'`
Yfree=`cat /log/vol/$Date3.log | grep 10.0.0.16 | grep $eNas | head -n 1 | awk -F[:" "]+ '{print $6}' | tr -d 'GB'`
Ufree=$(($Yfree - $Dfree))
echo "nas1(10.0.0.16) $eNas Total: $Totall Free: $Freee Day_use: $Ufree"GB" $Avg" >> /log/vol/$Date.log
done
echo " " >> /log/vol/$Date.log
echo " " >> /log/vol/$Date.log
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。