Created
October 21, 2011 19:47
-
-
Save urcadox/1304754 to your computer and use it in GitHub Desktop.
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/sh | |
# netstat.sh | |
# AddiKT1ve <the.addikt1ve@gmail.com> | |
# Mwyann <http://mwyann.info> | |
# Variables | |
ETHIFACE=eth0 | |
WLANIFACE=wlan0 | |
TMPDIR=. | |
# Functions | |
function rx_bytes { # download | |
RXETHERNET=`cat /sys/class/net/$ETHIFACE/statistics/rx_bytes` | |
RXWIRELESS=`cat /sys/class/net/$WLANIFACE/statistics/rx_bytes` | |
echo $(($RXETHERNET+$RXWIRELESS)) | |
} | |
function tx_bytes { # upload | |
TXETHERNET=`cat /sys/class/net/$ETHIFACE/statistics/tx_bytes` | |
TXWIRELESS=`cat /sys/class/net/$WLANIFACE/statistics/tx_bytes` | |
echo $(($TXETHERNET+$TXWIRELESS)) | |
} | |
# Download | |
LASTRXBYTES=`cat $TMPDIR/last_rxbytes` | |
# Upload | |
LASTTXBYTES=`cat $TMPDIR/last_txbytes` | |
# Download | |
RXBYTES=`rx_bytes` | |
RXRESULT=$((($RXBYTES-LASTRXBYTES)/1000)) | |
echo $RXBYTES > $TMPDIR/last_rxbytes | |
# Upload | |
TXBYTES=`tx_bytes` | |
TXRESULT=$((($TXBYTES-LASTTXBYTES)/1000)) | |
echo $TXBYTES > $TMPDIR/last_txbytes | |
echo "↓ $RXRESULT Ko/s | $TXRESULT Ko/s ↑" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment