去发现生活中的美好,记录生活中的点点滴滴

Linux Shell 脚本监控磁盘空间

linux admin 659℃

监控磁盘使用率超过98的服务器:

#!/bin/sh

ip=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|head -1|tr -d "addr:"?`
echo $ip
df -Ph | grep -vE '^Filesystem|tmpfs' | awk '{ print $5,$1 }' | while read output;
do
  echo -e  "$output\n"
  used=$(echo $output | awk '{print $1}' | sed s/%//g)
  partition=$(echo $output | awk '{print $2}')
  if [ $used -ge 98 ]; then
  putmsg="The partition $partition ($ip) on $(hostname) has used $used% at $(date)"
  echo $putmsg
  #发送通知...
  fi
done

转载请注明:永盟博客 » Linux Shell 脚本监控磁盘空间

喜欢 (5)

Warning: count(): Parameter must be an array or an object that implements Countable in E:\www\blog\wp-includes\class-wp-comment-query.php on line 405