标签:shell
邮件监控存储卷空间的脚本:
说明:
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
本文出自 “linux” 博客,请务必保留此出处http://yangzhiming.blog.51cto.com/4849999/1902124
标签:shell
原文地址:http://yangzhiming.blog.51cto.com/4849999/1902124