监控磁盘空间小脚本

监控磁盘空间使用情况,通过飞信机器人报警。

#!/bin/bash
#Used for reporting the disk space usage of the moedb163 servers by the means of fetion.
#Written on 20100825.
#Author: sunyankui.
percent=70
host=`hostname`
num=($(df -h|grep ^/|sed 's/%//g'|awk -v p=$percent '{if($5>p) print $5}'))
#echo ${num[0]}
#echo ${num[1]}
#echo `df -h|grep ^/|sed 's/%//g'|awk -v p=$percent '{if($5>p)print $1,"is mount",$NF,"is used",$5}'`
if [[ ${num[0]} -gt $percent ]];then
df -h|grep ^/|sed 's/%//g'|awk -v p=$percent '{if($5>p)print $1,"is mount",$NF,"is used",$5}'> disk.txt
/usr/local/fetion/fetion --mobile=15810423267 --pwd=xxxxxxxx --to=15810423267 --msg-utf8="$host`cat disk.txt`" --debug
fi

你可能感兴趣的:(脚本,职场,休闲,空间,磁盘)