Created
April 20, 2018 16:40
-
-
Save Sergi030/c4a7425bbc12d1736d3cfd95e2901e9f to your computer and use it in GitHub Desktop.
Script to check bytes usage on a specific network card using system files
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 | |
if [ -z "$1" ]; then | |
echo | |
echo usage: $0 network-interface | |
echo | |
echo e.g. $0 eth0 | |
echo | |
echo shows packets-per-second | |
exit | |
fi | |
INICIO=$(cat /sys/class/net/$1/statistics/tx_bytes) | |
ANTERIOR=-1 | |
while true | |
do | |
MEH=$(cat /sys/class/net/$1/statistics/tx_bytes) | |
ACTUAL=$(($MEH - $INICIO)) | |
if [ $ACTUAL -ne $ANTERIOR ]; then | |
echo $ACTUAL | |
date | |
fi | |
ANTERIOR=$ACTUAL | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment