Shell脚本查看网卡实时流量
2018-10-12 14:10
931 查看
#!/bin/bash
while [ "1" ]
do
eth=$1
RXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}')
TXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}')
sleep 1
RXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}')
TXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}')
clear
echo -e "\t RX `date +%k:%M:%S` TX"
RX=$((${RXnext}-${RXpre}))
TX=$((${TXnext}-${TXpre}))
if [[ $RX -lt 1024 ]];then
RX="${RX}B/s"
elif [[ $RX -gt 1048576 ]];then
RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}')
else
RX=$(echo $RX | awk '{print $1/1024 "KB/s"}')
fi
if [[ $TX -lt 1024 ]];then
TX="${TX}B/s"
elif [[ $TX -gt 1048576 ]];then
TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}')
else
TX=$(echo $TX | awk '{print $1/1024 "KB/s"}')
fi
echo -e "$eth \t $RX $TX "
done
调用方式:
./traff.sh eth1
或
bash traff.sh eth1
可以实时显示网卡流量大小:
您可能感兴趣的文章:
相关文章推荐
- shell脚本助你在linux下实时查看单网卡流量
- Shell脚本查看网卡实时流量
- shell awk实现实时监控网卡流量脚本(常见应用二)
- shell脚本网络流量实时查看
- linux shell awk实现实时监控网卡流量脚本
- 查看Linux服务器网卡流量小脚本shell和Python各一例
- shell awk实现实时监控网卡流量脚本(常见应用二)
- 查看Linux服务器网卡流量小脚本shell
- shell脚本之获取网卡实时流量
- 查看Linux服务器网卡流量小脚本shell和Python各一例 推荐
- 实时查看系统流量的Shell脚本分享
- 实时查看linux网卡流量脚本
- 实时查看系统流量的Shell脚本分享
- Linux下网络流量监控工具大全,查看网卡的实时流量脚本
- shell脚本获取网卡的实时流量
- 查看网卡流量shell脚本工具:network_top.sh
- shell awk实现实时监控网卡流量脚本(常见应用二)
- 查看网卡流量shell脚本工具:network_top.sh
- 实时查看网络流量的shell脚本
- linux 查看网卡流量的shell脚本