Skip to content

Instantly share code, notes, and snippets.

@mmstick
Last active August 29, 2015 14:06
Show Gist options
  • Save mmstick/d50598cd61b80dd1d28b to your computer and use it in GitHub Desktop.
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.
#!/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