#!/bin/bash
echo -n "which nic?"
read eth
echo "the nic is "$eth
echo -n "how much seconds:"
read sec
echo "duration is "$sec" seconds, wait please..."
infirst=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://')
outfirst=$(awk '/'$eth'/{print $10 }' /proc/net/dev)
sumfirst=$(($infirst+$outfirst))
sleep $sec"s"
inend=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://')
outend=$(awk '/'$eth'/{print $10 }' /proc/net/dev)
sumend=$(($inend+$outend))
sum=$(($sumend-$sumfirst))
echo $sec" seconds total :"$sum"bytes"
aver=$(($sum/$sec))
echo "avrage :"$aver"bytes/sec"
计算Linux网卡流量的脚本
转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
查看linux网卡流量
watch -n 1 "ifconfig eth0 |grep byte"
网络 linux 职场 流量 休闲 -
Linux下查看网卡流量
在Linux下怎么看网络流量?在Windows下,我们可以很方便的通过360来查看网络流量,知道哪个进程占用的网络带宽比较多。那在Linux下怎么看流量呢,对于Web服务器来说这是很重要的。下面这边博客很仔细的介绍了Linux下看流量的方法:Linux 各种查看网卡流量的方法 http://
linux 服务器 Windows traffic interface General