Skip to content

Instantly share code, notes, and snippets.

@Sergi030
Created April 20, 2018 16:40
Show Gist options
  • Save Sergi030/c4a7425bbc12d1736d3cfd95e2901e9f to your computer and use it in GitHub Desktop.
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
#!/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