Skip to content

Instantly share code, notes, and snippets.

@fitz123
Forked from joemiller/netpps.sh
Last active February 24, 2017 16:33
Show Gist options
  • Save fitz123/c8d77bcd37cbac5b9015 to your computer and use it in GitHub Desktop.
Save fitz123/c8d77bcd37cbac5b9015 to your computer and use it in GitHub Desktop.
#!/bin/bash
sleep_time="${1:-1}"
while read int; do
let "rx_bytes0+=$(<${int}statistics/rx_bytes)"
let "tx_bytes0+=$(<${int}statistics/tx_bytes)"
done < <(ls -d /sys/class/net/*/)
sleep $sleep_time
while read int; do
let "rx_bytes1+=$(<${int}statistics/rx_bytes)"
let "tx_bytes1+=$(<${int}statistics/tx_bytes)"
done < <(ls -d /sys/class/net/*/)
let "rx_bps = ( rx_bytes1 - rx_bytes0 ) * 8 / ${sleep_time}"
let "tx_bps = ( tx_bytes1 - tx_bytes0 ) * 8 / ${sleep_time}"
echo rx_bps=$rx_bps
echo tx_bps=$tx_bps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment