1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
openmptcprouter-feeds/luci-app-ouad/root/usr/sbin/netspeed
Ycarus (Yannick Chabanois) fc86fbafa0 Oled: fix on bandwidth
2023-10-20 17:01:45 +02:00

20 lines
512 B
Bash
Executable file

#!/bin/ash
IF=$1
if [ -z "$IF" ]; then
IF=`ls -1 /sys/class/net/ | head -1`
fi
RXPREV=-1
TXPREV=-1
echo "Listening $IF..."
while [ 1 == 1 ] ; do
RX=`cat /sys/class/net/${IF}/statistics/rx_bytes`
TX=`cat /sys/class/net/${IF}/statistics/tx_bytes`
if [ $RXPREV -ne -1 ] ; then
let BWRX=$RX-$RXPREV
let BWTX=$TX-$TXPREV
echo "$((BWRX*8)) $(($BWTX*8))">/tmp/netspeed
fi
RXPREV=$RX
TXPREV=$TX
sleep 1
done