New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
[SCRIPT] Bandwidth persistence for OpenWRT WIP
Just to share a code. OpenWRT does not save the WAN data, and it is useful for metered connections. This code will save it on a file, and will remember each boot.
Todo:
- GUI
- Delete old bandwidth
#!/bin/sh if [ -f /tmp/bw ]; then echo "Process already running, stats:" TX=$( cat /root/tx ) RX=$( cat /root/rx ) echo TX $(( $TX / 1048576 )) MB echo RX $(( $RX / 1048576 )) MB exit 1 fi touch /tmp/bw if [ -f /root/tx ]; then TX=$( cat /root/tx ) RX=$( cat /root/rx ) OLDBW=1 fi while : do TXX=$( ifconfig eth0 | grep bytes | cut -d \: -f 3 | cut -d \( -f 1 ) RXX=$( ifconfig eth0 | grep bytes | cut -d : -f 2 | cut -d \( -f 1 ) if [ $OLDBW ]; then TXX=$((TX + TXX)) RXX=$((RX + RXX)) fi #For debug purposes: #echo TX $(( $TXX / 1048576 )) MB #echo RX $(( $RXX / 1048576 )) MB echo $TXX > /root/tx echo $RXX > /root/rx sleep 10 done
Thanked by 1cassa