Skip to content

Instantly share code, notes, and snippets.

@Hyunho
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hyunho/8090c1996c9298f2e697 to your computer and use it in GitHub Desktop.
Save Hyunho/8090c1996c9298f2e697 to your computer and use it in GitHub Desktop.
print network bandwidth in bit format at linux
#!/bin/sh
rx1=`grep eth0 /proc/net/dev | awk '{print $1}' | sed 's/.*://'`
tx1=`grep eth0 /proc/net/dev | awk '{print $9}'`
sleep 3
rx2=`grep eth0 /proc/net/dev | awk '{print $1}' | sed 's/.*://'`
tx2=`grep eth0 /proc/net/dev | awk '{print $9}'`
rx3=$(((rx2-rx1)/3*8/1024/1024))
tx3=$(((tx2-tx1)/3*8/1024/1024))
echo "`date '+%k:%M:%S'` : $rx3 / $tx3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment