Skip to content

Instantly share code, notes, and snippets.

@kaka19ace
Created April 10, 2014 14:32
Show Gist options
  • Save kaka19ace/10388683 to your computer and use it in GitHub Desktop.
Save kaka19ace/10388683 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 一次向阿里云提交工单反映问题时,对方提供的测试脚本, 嘻嘻, 借用了,比我写的py脚本还方便
if [ -z "$1" ]; then
echo
echo usage: $0 network-interface
echo
echo e.g. $0 eth1
echo
exit
fi
IF=$1
while true
do
T1=`cat /sys/class/net/$1/statistics/tx_bytes`
IP1=`iptables -nvxL OUTPUT |grep "0.0.0.0" |awk '{print $2}'`
sleep 1
T2=`cat /sys/class/net/$1/statistics/tx_bytes`
IP2=`iptables -nvxL OUTPUT |grep "0.0.0.0" |awk '{print $2}'`
TBPS=`expr $T2 - $T1`
IPPS=`expr $IP2 - $IP1`
TKBPS=`expr $TBPS / 128`
IPKBPS=`expr $IPPS / 128`
echo "tx $TKBPS kb/s"
echo "txiptables $IPKBPS kb/s"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment