# cat traffic.sh
#! /bin/bash
# we need to monitor streams of LTS channels
typeset in in_old dif_in dif_in1 dif_out1
typeset out out_old dif_out
in_old=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $1 }' )
out_old=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $9 }')
while true
do
sleep 1
in=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $1 }')
out=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $9 }')
dif_in=$((in-in_old))
dif_in1=$((dif_in * 8 / 1024 / 1024 ))
dif_out=$((out-out_old))
echo " IN: ${dif_in} bytes OUT: ${dif_out} bytes "
dif_out1=$((dif_out * 8 / 1024 / 1024 ))
echo " IN: ${dif_in1} mbps OUT: ${dif_out1} mbps"
in_old=${in}
out_old=${out}
done
linux 流量实时监控脚本
原创
©著作权归作者所有:来自51CTO博客作者penghjfy的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:Awk 显示连续多列
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
linux实时流量监控
在类Unix系统中可以使用top查看系统资源、进程、内存占用等
yacc 解决方法 安装方法 -
linux流量监控脚本
流量监控脚本
linux 流量 监控 -
Linux网卡流量监控脚本
语法: bash netmon.sh 网卡名称 [可选参数]我这台云服务最高带宽是2M 所以测试最高也不会超过2MB/s。作用: 实时监控网卡 进/出 流量。
linux bash 运维 可选参数 实时监控