监控磁盘使用率超过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 脚本监控磁盘空间