#####
# @author : chase or 诺瓦
# 带宽
in_old=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $1 }' )
out_old=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $9 }' )
sleep ${timer}
inv=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $1 }' )
out=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $9 }' )
dif_in=$(((in-in_old)/timer))
dif_out=$(((out-out_old)/timer))
echo "Time: $DATA_V ==>IN: ${dif_in} Byte/s OUT: ${dif_out} Byte/s">>"$DIR_PATH/networkl.log"
#####
# @author : chase or 诺瓦
# 磁盘
# 可以一周或一天检查一次
# df -h |grep / |uniq|sort|tr -s " "|cut -d " " -f 4-6
#
# df |grep / |uniq|sort|tr -s " "|awk -F '%' '{print $1}'|cut -d " " -f 5|sort -n | tail -n 1
#
# 记录磁盘
echo " ">>"$DIR_PATH/fdiskl.log"
echo "Time: $DATA_V ==> fdisk Space ===================================">>"$DIR_PATH/fdiskl.log"
echo "`df -h |grep / |uniq|sort|tr -s " "|cut -d " " -f 4-6`">>"$DIR_PATH/fdiskl.log"
# 磁盘到了一定的空间 发邮件给我 百分比 90% 通知我
typeset diskfile
diskfile=`df |grep / |uniq|sort|tr -s " "|awk -F '%' '{print $1}'|cut -d " " -f 5|sort -n | tail -n 1`
if [ "$diskfile" -ge "90" ]; then
echo "Time: $DATA_V ==>fdisk $diskfile % ===================================">>"$DIR_PATH/fdisk_full.log"
echo "Time: $DATA_V , server name : $HOSTNAMEL ==> fdisk : $diskfile % ">>$MESSAGE
mail -s "$MAIL_TITLE fdisk" "$MAIL_TO" < $MESSAGE
rm -rf $MESSAGE
fi
#####
# @author : chase or 诺瓦
# 内存 己用百分比
#
typeset mpercent
mpercent=`free -m |grep /cache |tr -s " " | awk -F '/cache' '{print $2}' |awk -F ' ' '{agvt=$2/($2+$3)*100; print agvt}' | awk -F '.' '{print $1}'`
echo "Time: $DATA_V ==>memory $mpercent %">>"$DIR_PATH/memory.log"
if [ "$mpercent" -ge "95" ]; then ## 95% 发邮件
echo "Time: $DATA_V ==>memory $mpercent %">>"$DIR_PATH/memory_warning.log"
echo "Time: $DATA_V , server name : $HOSTNAMEL ==> memory : $mpercent %">>$MESSAGE
mail -s "$MAIL_TITLE memory" "$MAIL_TO" < $MESSAGE
rm -rf $MESSAGE
fi