Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ifbw(){(
- delay=5
- if='eth0'
- capture='/tmp/net-dev-eth0.txt'
- netdev='/proc/net/dev'
- curr_rx=
- curr_tx=
- last_rx=
- last_tx=
- capture(){
- cat $netdev | fgrep $if':' | cut -c8- | awk '{print $1 " " $9}' > $capture
- curr_rx=$( cut -d' ' -f1 /tmp/net-dev-eth0.txt )
- curr_tx=$( cut -d' ' -f1 /tmp/net-dev-eth0.txt )
- if [ "--show" = "$1" ]; then
- clear 2>/dev/null
- echo '['$( date '+%Y-%m-%d %H:%M:%S' )']' $if':' \
- rx: $( echo 'scale=1;' '(' $curr_rx - $last_rx ')' '*' 8 / 1024 / $delay | bc -l ) Kbps \
- tx: $( echo 'scale=1;' '(' $curr_tx - $last_tx ')' '*' 8 / 1024 / $delay | bc -l ) Kbps
- fi
- last_rx=$curr_rx
- last_tx=$curr_tx
- }
- capture
- sleep $delay
- capture --show
- while [ "--loop" = "$1" ] ; do
- sleep $delay
- capture --show
- done
- )}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement