Last active
August 29, 2015 14:06
-
-
Save mmstick/d50598cd61b80dd1d28b to your computer and use it in GitHub Desktop.
Prints rx/tx statistics of all active networks in a human-readable format.
This file contains hidden or 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
#!/usr/bin/fish | |
for connection in /sys/class/net/* | |
switch '$connection' | |
case '*lo' | |
continue | |
case '*' | |
if test (cat $connection/operstate) = 'up' | |
set net (basename $connection) | |
set rx (math (cat $connection/statistics/rx_bytes) / 1048576) | |
set tx (math (cat $connection/statistics/tx_bytes) / 1048576) | |
echo "$net D: $rx MiB U: $tx MiB" | |
set -e net; set -e rx; set -e tx | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment