标签:shell脚本插件
#!/bin/bash
while true
do
RX=`ifconfig|awk ‘NR==7{print$2}‘ | cut -d ":" -f2`
TX=`ifconfig|awk ‘NR==7{print$6}‘ | cut -d ":" -f2`
ZX=`expr $RX + $TX`
sleep 60
# for i in `seq 120 -1 1`
# do
# echo -n -e "\b$i"
# sleep 1
# done
# echo -n -e "\b"
RX1=`ifconfig|awk ‘NR==7{print$2}‘ | cut -d ":" -f2`
TX1=`ifconfig|awk ‘NR==7{print$6}‘ | cut -d ":" -f2`
ZX1=`expr $RX1 + $TX1`
ZPX=`expr $ZX1 - $ZX`
# echo $ZPX
if [ $ZPX -ge 3145728 ];then
echo "eth0:每秒流量为:`echo"scale=2;$ZPX / 1048576" | bc` M/s";exit 2
elif [ $ZPX -ge 2359296 ];then
echo "eth0:每秒流量为:`echo"scale=2;$ZPX / 1048576" | bc` M/s";exit 1
else
echo "eth0:每秒流量为:`echo"scale=2;$ZPX / 1048576" | bc` M/s";exit 0
fi
# iptables -A INPUT -p tcp--dport 80 -s $IP -j REJECT
# fi
done
本文出自 “运维之道” 博客,请务必保留此出处http://lrtao2010.blog.51cto.com/10425744/1701935
标签:shell脚本插件
原文地址:http://lrtao2010.blog.51cto.com/10425744/1701935