您的位置:首页 > 运维架构 > Shell

Shell脚本监控Linux系统硬盘各分区使用率

2017-07-04 16:23 351 查看
Shell脚本如下:

#/bin/bash
#environment variable
source /etc/profile
#disk space
for d in `df -P | grep /dev | awk '{print $5}' | sed 's/%//g'`
do
if [ $d -gt 90 ];
then
msg="TIME:$(date +%F_%T)
HOSTNAME:$(hostname)
IPADDR:$(ifconfig |awk 'NR==2{print $2}')
MSG:硬盘使用过高!"
echo $msg
df -h > /test/tt.txt
/test/pymail.py $msg
fi
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息