Last active
November 3, 2024 19:13
-
-
Save stoyanovgeorge/96e991fe23c1f3a036942daedc0e1afe to your computer and use it in GitHub Desktop.
An one line command to get the average RX and TX speed of a particular interface (eth0) over $INT seconds in bytes per second. You need to divide by 128 to get it in Kbps or by 131072 (128*1024) for Mbps.
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 | |
INT=2; RXDIR=/sys/class/net/eth0/statistics/rx_bytes; TXDIR=/sys/class/net/eth0/statistics/tx_bytes; RXSTART=$(cat $RXDIR); TXSTART=$(cat $TXDIR); sleep $INT; RXEND=$(cat $RXDIR); TXEND=$(cat $TXDIR); RXBPS="$(((RXEND-RXSTART)/INT))"; TXBPS="$(((TXEND-TXSTART)/INT))"; echo "$RXBPS" "$TXBPS" |
Author
stoyanovgeorge
commented
Apr 15, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment