====== リアルタイムでトラフィックを見る ======
- bps
while : ; do _T1=$( /sbin/tc -s qdisc | fgrep -m 1 Sent | cut -d" " -f 3); \
sleep 1; _T2=$( /sbin/tc -s qdisc | fgrep -m 1 Sent | cut -d" " -f 3); \
echo "$(expr \( $_T2 - $_T1 \) \* 8 ) bps"; done
- kbps
while : ; do _T1=$( /sbin/tc -s qdisc | fgrep -m 1 Sent | cut -d" " -f 3); \
sleep 1; _T2=$( /sbin/tc -s qdisc | fgrep -m 1 Sent | cut -d" " -f 3); \
echo "$(expr \( \( $_T2 - $_T1 \) \* 8 \) \/ 1024 ) kbps"; done
===== KVM VMの場合 =====
どのbridgeを利用しているのか確認
# virsh dumpxml test_01|grep vnet
bridgeを指定して実行
i=vnet1
while : ; do _T1=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $1}'); \
sleep 1; _T2=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $1}'); \
echo "$(expr \( $_T2 - $_T1 \) \* 8 ) bps"; done
===== 受信(Receive) =====
i=eth0
while : ; do _R1=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $1}'); \
sleep 1; _R2=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $1}'); \
echo Receive "$(expr \( \( $_R2 - $_R1 \) \* 8 \) \/ 1024 ) kbps"; done
===== 送信(Transmit) =====
i=eth0
while : ; do _T1=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $9}'); \
sleep 1; _T2=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $9}'); \
echo Transmit "$(expr \( \( $_T2 - $_T1 \) \* 8 \) \/ 1024 ) kbps"; done
===== 受信と送信を両方同時に出力 =====
i=eth0
while :
do
_R1=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $1}'); \
_T1=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $9}'); \
sleep 1; \
_R2=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $1}'); \
_T2=$( grep $i: /proc/net/dev | cut -d: -f 2|awk '{print $9}'); \
echo -n `date "+[%Y%m%d %H%M%S]"`" "; \
echo -n Receive "$(expr \( \( \( $_R2 - $_R1 \) \* 8 \) \/ 1024 \) \/ 1024 ) Mbps |";\
echo Transmit "$(expr \( \( \( $_T2 - $_T1 \) \* 8 \) \/ 1024 \) \/ 1024 ) Mbps";\
done
{{tag>network}}