Usage:
#> Moniotr. Sh eth0 1
#! /Bin/bash
# Test network width
# The first parameter indicates the Real-Time refresh time after the NIC name. 1 indicates 1 second.
Function usage
{
Echo "Usage: $0"
Echo "e.g. $0 eth0 2"
Exit 65
}
If [$ #-lt 2]; then
Usage
Fi
Typeset in in_old dif_in
Typeset out out_old dif_out
Typeset Timer
Typeset ETH
Eth = $1
Timer = $2
in_old = $ (CAT/proc/NET/dev | grep $ ETH | sed-e "s /\(. *\)\:\(. * \)/\ 2/g "| awk '{print $1 }')
out_old = $ (CAT/proc/NET/dev | grep $ ETH | sed-e "s /\(. *\)\:\(. * \)/\ 2/g "| awk '{print $9 }')
while true
DO
sleep $ {timer}
In =$ (CAT/proc/NET/dev | grep $ ETH | sed-e" S /\(. *\)\:\(. * \)/\ 2/g "| awk '{print $1 }')
out = $ (CAT/proc/NET/dev | grep $ ETH | sed-e "s /\(. *\)\:\(. * \)/\ 2/g "| awk '{print $9}')
dif_in = $ (in-in_old)/timer ))
dif_out = $ (out-out_old)/timer)
echo "in: $ {dif_in} byte/s out: $ ($ {dif_out}/1024) kb/s: $ {dif_out} byte/s "
in_old =$ {In}
out_old =$ {out}
done
exit 0