Last active
August 29, 2015 14:13
-
-
Save shvelo/bcc819288b909c809cb7 to your computer and use it in GitHub Desktop.
Network interface usage in kb/s in format down,up every 3 seconds. usage: ./netuse.sh <interface>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
delay=3 | |
while true; do | |
mon_total_down_old=$(cat /proc/net/dev | grep $1 | awk '{print $2}') | |
mon_total_up_old=$(cat /proc/net/dev | grep $1 | awk '{print $10}') | |
sleep 1 | |
mon_total_down=$(cat /proc/net/dev | grep $1 | awk '{print $2}') | |
mon_total_up=$(cat /proc/net/dev | grep $1 | awk '{print $10}') | |
mon_speed_down=$(echo | awk -v mon_total_old=$mon_total_down_old -v mon_total=$mon_total_down '{printf "%d", (mon_total - mon_total_old) / 1000}') | |
mon_speed_up=$(echo | awk -v mon_total_old=$mon_total_up_old -v mon_total=$mon_total_up '{printf "%d", (mon_total - mon_total_old) / 1000}') | |
echo $mon_speed_down,$mon_speed_up | |
sleep $delay | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment