在网上看到这个单机流量的脚本,挺不错的。
复制代码 代码如下:
#!/bin/sh
usage(){
echo “Usage: $0 [-i INTERFACE] [-s INTERVAL] [-c COUNT]”
echo
echo “-i INTERFACE”
echo “ The interface to monitor, default is eth0.”
echo “-s INTERVAL”
echo “ The time to wait in seconds between measurements, default is 3 seconds.”
echo “-c COUNT”
echo “ The number of times to measure, default is 10 times.”
exit 3
}
readargs(){
while [ "$#" -gt 0 ] ; do
case “$1″ in
-i)
if [ "$2" ] ; then
interface=”$2″
shift ; shift
else
echo “Missing a value for $1.”
echo
shift
usage
fi
;;
-s)
if [ "$2" ] ; then
sleep=”$2″
shift ; shift
else
echo “Missing a value for $1.”
echo
shift
usage
fi
;;
-c)
if [ "$2" ] ; then
counter=”$2″
shift ; shift
else
echo “Missing a value for $1.”
echo
shift
usage
fi
;;
*)
echo “Unknown option $1.”
echo
shift
usage
;;
esac
done
}
checkargs(){
if [ ! "$interface" ] ; then
interface=”eth0″
fi
if [ ! "$sleep" ] ; then
sleep=”3″
fi
if [ ! "$counter" ] ; then
counter=”10″
fi
}
printrxbytes(){
/sbin/ifconfig “$interface” | grep “RX bytes” | cut -d: -f2 | awk ‘{ print $1 }'
}
printtxbytes(){
/sbin/ifconfig “$interface” | grep “TX bytes” | cut -d: -f3 | awk ‘{ print $1 }'
}
bytestohumanreadable(){
multiplier=”0″
number=”$1″
while [ "$number" -ge 1024 ] ; do
multiplier=$(($multiplier+1))
number=$(($number/1024))
done
case “$multiplier” in
1)
echo “$number Kb”
;;
2)
echo “$number Mb”
;;
3)
echo “$number Gb”
;;
4)
echo “$number Tb”
;;
*)
echo “$1 b”
;;
esac
}
printresults(){
while [ "$counter" -ge 0 ] ; do
counter=$(($counter – 1))
if [ "$rxbytes" ] ; then
oldrxbytes=”$rxbytes”
oldtxbytes=”$txbytes”
fi
rxbytes=$(printrxbytes)
txbytes=$(printtxbytes)
if [ "$oldrxbytes" -a "$rxbytes" -a "$oldtxbytes" -a "$txbytes" ] ; then
echo “$(/bin/date +%Y%m%d-%H%M%S) RXbytes = $(bytestohumanreadable $(($rxbytes – $oldrxbytes))) TXbytes = $(bytestohumanreadable $(($txbytes – $oldtxbytes)))”
else
echo “Monitoring $interface every $sleep seconds. (RXbyte total = $(bytestohumanreadable $rxbytes) TXbytes total = $(bytestohumanreadable $txbytes))”
fi
sleep “$sleep”
done
}
readargs “$@”
checkargs
printresults
测试如下:
每三秒的流量,总输出999行,可以输出到文件里,其中:前面为时间,Rx Packets 是接收数据包,即下载,Tx Packets 是发送数据包,即上传.
复制代码 代码如下:
[root@host]#sh t.sh -c 999 Monitoring eth0 every 3 seconds. (RXbyte total = 6 Tb TXbytes total = 5 Tb)
20101105-201539 RXbytes = 126 Kb TXbytes = 658 Kb
20101105-201542 RXbytes = 87 Kb TXbytes = 487 Kb
20101105-201545 RXbytes = 159 Kb TXbytes = 668 Kb
20101105-201548 RXbytes = 107 Kb TXbytes = 725 Kb
20101105-201551 RXbytes = 110 Kb TXbytes = 704 Kb
20101105-201554 RXbytes = 90 Kb TXbytes = 726 Kb
20101105-201558 RXbytes = 100 Kb TXbytes = 850 Kb
20101105-201601 RXbytes = 102 Kb TXbytes = 703 Kb
20101105-201604 RXbytes = 168 Kb TXbytes = 693 Kb
20101105-201607 RXbytes = 105 Kb TXbytes = 730 Kb
20101105-201610 RXbytes = 133 Kb TXbytes = 711 Kb
20101105-201613 RXbytes = 431 Kb TXbytes = 703 Kb
20101105-201616 RXbytes = 84 Kb TXbytes = 527 Kb
20101105-201619 RXbytes = 239 Kb TXbytes = 825 Kb
20101105-201622 RXbytes = 117 Kb TXbytes = 801 Kb
20101105-201625 RXbytes = 99 Kb TXbytes = 913 Kb
20101105-201628 RXbytes = 89 Kb TXbytes = 322 Kb
20101105-201631 RXbytes = 63 Kb TXbytes = 73 Kb
20101105-201634 RXbytes = 84 Kb TXbytes = 191 Kb
20101105-201637 RXbytes = 174 Kb TXbytes = 481 Kb
20101105-201640 RXbytes = 120 Kb TXbytes = 383 Kb
20101105-201643 RXbytes = 94 Kb TXbytes = 496 Kb
20101105-201646 RXbytes = 108 Kb TXbytes = 340 Kb
20101105-201649 RXbytes = 91 Kb TXbytes = 639 Kb
20101105-201652 RXbytes = 106 Kb TXbytes = 629 Kb
20101105-201655 RXbytes = 125 Kb TXbytes = 496 Kb
20101105-201658 RXbytes = 90 Kb TXbytes = 537 Kb
20101105-201701 RXbytes = 114 Kb TXbytes = 641 Kb
Shell脚本,单机流量统计
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]