检查硬盘告警的脚本
2015-09-15 12:30
232 查看
改编自网络:
#!/bin/bash
mail=xxxx@xxx.com;
mailflag="true"
logfile=/root/check/checkdisk.log
#limit is 90
cat /dev/null > $logfile;
#count ,how many disks > 90%;
count=`df | grep -v mnt|grep -c -E \(9[1-9]\%\)\|\(100\%\)`;
if [ $count -gt 0 ];
then
echo "This is a alert for disk usage." >> $logfile
echo "host address:" >> $logfile
ifconfig |grep "inet addr" |grep -v "127.0.0.1" |awk '{print $2}'|awk -F ":" '{print $2}' >> $logfile
echo "disk info:" >> $logfile
df -h >> $logfile
if [ "$mailflag" == "true" ]; then mail -s "disk alert" $mail < $logfile;fi;
fi
注意:
邮件服务要正常,把sendmail装好。
发件地址如xxx.com要能ping到。
#!/bin/bash
mail=xxxx@xxx.com;
mailflag="true"
logfile=/root/check/checkdisk.log
#limit is 90
cat /dev/null > $logfile;
#count ,how many disks > 90%;
count=`df | grep -v mnt|grep -c -E \(9[1-9]\%\)\|\(100\%\)`;
if [ $count -gt 0 ];
then
echo "This is a alert for disk usage." >> $logfile
echo "host address:" >> $logfile
ifconfig |grep "inet addr" |grep -v "127.0.0.1" |awk '{print $2}'|awk -F ":" '{print $2}' >> $logfile
echo "disk info:" >> $logfile
df -h >> $logfile
if [ "$mailflag" == "true" ]; then mail -s "disk alert" $mail < $logfile;fi;
fi
注意:
邮件服务要正常,把sendmail装好。
发件地址如xxx.com要能ping到。
相关文章推荐
- 教练式辅导-GROW模型的分析与运用
- 完美激活Flash builder 4.7
- sql:[dbo].[smt_MES_RptProductDaily] 生产日报表
- ICE
- 个人面试题(oracle数据库开发)(一)
- LBP+DLBP+STLBP+VLBP
- 输入输出之File类
- 降维工具箱
- 2014年度辛星完全解读html部分
- IOS开发-CAlayer-锚点小结
- cocos2dx画扇形
- 红黑树
- 简单的数据库交互展示
- 概率分析和随机算法(2)——算法导论(6)
- ubuntu mysql 安装
- mongo 指令
- html base64 img 图片显示
- Attempting to badge the application icon but haven't received permission解决方案
- 错误码:2003 不能连接到mysql服务器
- MySQL语法大全