有关磁盘空间的脚本
答
你可以使用awk
:
df | grep -v 'Use%' | awk '{if($5 > 50) print $1 " uses " $5 " of its total space"}'
输出示例:从你的服务器,这些服务器可以登录使用SSH密钥,没有密码的所有服务器的其余部分的一个
[[email protected]:~]> df | grep -v 'Use%' | awk '{if($5 > 50) print $1 " uses " $5 " of its total space"}'
/dev/md2 uses 73% of its total space
/dev/sdb4 uses 66% of its total space
+0
谢谢!它帮助我很多! – CompLike 2011-02-14 13:00:44
答
#!/bin/bash
_servers="[email protected] [email protected] [email protected]"
_out="/tmp/output.$$"
_email="[email protected]"
_sub="Disk Space Report $(date)"
_ssh=/usr/bin/ssh
_mail=/usr/bin/mail
>$_out
for s in $_servers
do
$_ssh $s df -H >>$_out
done
$_mail -s "${_sub}" $_email <$_out
运行此。设置一个cron,你就完成了。如果你想输出所有服务器,否则你也可以申请1台服务器。
“把它当作剧本”是什么意思?如何编程> 90%的计算? – 2011-02-10 15:41:36