上一篇: 监视端口是否正常的shell
监视磁盘使用情况Shell
[ 2009/04/20 16:27 | by selboo ]
monitordisk.sh如下
#!/bin/bash
#Updated:2008-03-03 PM By:leif(liangliwen@163.com)
EMAIL=/usr/local/bin/email
/bin/df -h >/tmp/df.txt
USE=`df -H | grep -o [0-9]*% | grep -o ‘[0-9]\+’`
for i in $USE
do
if (( $i > 95 ))
then
$EAMIL -s “WARNING Low disk space for $i” liangliwen@163.com break
fi
if (( $i > 90 ))
then
$EMAIL -s “Low disk space for $i” liangliwen@163.com fi
done
/bin/rm -f /tmp/df.txt
实现目的,任何一个分区使用到90%就发送一个邮件给指定的收件人,到95%就在邮件主题出警告(warning),说明发送邮件程序EMAIL,是从http://www.cleancode.org/projects/email 下载安装,比较灵活.
把这个shell根据需要放在crontab 实现定时检查磁盘情况
最后编辑: selboo 编辑于2009/04/20 16:28