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

前端之家收集整理的这篇文章主要介绍了Shell脚本监控Linux系统硬盘各分区使用率前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Shell脚本如下:

  1. #/bin/bash
  2. #environment variable
  3. source /etc/profile
  4. #disk space
  5. for d in `df -P | grep /dev | awk '{print $5}' | sed 's/%//g'`
  6. do
  7. if [ $d -gt 90 ];
  8. then
  9. msg="TIME:$(date +%F_%T)
  10. HOSTNAME:$(hostname)
  11. IPADDR:$(ifconfig |awk 'NR==2{print $2}')
  12. MSG:硬盘使用过高!"
  13. echo $msg
  14. df -h > /test/tt.txt
  15. /test/pymail.py $msg
  16. fi
  17. done

猜你在找的Bash相关文章