Linux流量监控工具iftop和nload浅析

时间:2025-11-04 23:42:34来源:极客码头作者:IT科技
Linux流量监控工具iftop和nload浅析
复制#!/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"  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.
相关内容