首页 > 代码库 > 抓取存储quota超过80%的users
抓取存储quota超过80%的users
抓取存储quota超过80%的AD域users
注:
1、ASPERADATA为存储卷名,MING为域名
2、通过对MING进行替换(替为空),再删除“\”,剩下就是除域名后的具体名字(完整域名如:MING\zhi.yang)
#!/bin/bash
Date=`date +%Y%m%d`
Date2=`date +%Y%m%d -d "7 days ago"`
Dir=/tools/aspera
/bin/rm -rf $Dir/users_use.txt
/bin/rm -rf $Dir/used.txt
/bin/rm -rf $Dir/warn_$Date2.txt
/usr/bin/touch $Dir/users_use.txt
/usr/bin/touch $Dir/used.txt
/usr/bin/touch $Dir/warn_$Date.txt
ssh 10.0.0.40 "quota report -x" | grep ASPERADATA > $Dir/aspera.txt
/bin/cat $Dir/aspera.txt | awk -F[:" "]+ ‘{print $2}‘ | grep MING > $Dir/users2.txt
sed -i ‘s/MING/ /g‘ $Dir/users2.txt
tr -d ‘ \‘ $Dir/users.txt
/bin/cat $Dir/users2.txt | tr -d ‘\‘ > $Dir/users.txt
for i in `cat $Dir/users.txt`
do
Used=`cat $Dir/aspera.txt | grep $i | awk -F[:" "]+ ‘{print $5}‘`
Total=`cat $Dir/aspera.txt | grep $i | awk -F[:" "]+ ‘{print $6}‘`
/bin/echo $i,$Used,$Total >> $Dir/users_use.txt
/bin/echo $Used >> $Dir/used.txt
done
for ii in `cat $Dir/used.txt`
do
if [ $ii -gt 83880000 ] && [ $ii -lt 104857600 ];then
/bin/cat $Dir/users_use.txt | grep $ii >> $Dir/warn_$Date.txt
fi
if [ $ii -gt 167770000 ] && [ $ii -lt 209715200 ];then
/bin/cat $Dir/users_use.txt | grep $ii >> $Dir/warn_$Date.txt
fi
done
/usr/bin/scp -r $Dir/warn_$Date.txt root@10.0.0.17:/log/aspera/
本文出自 “linux” 博客,请务必保留此出处http://yangzhiming.blog.51cto.com/4849999/1891656
抓取存储quota超过80%的users