Multicolour Network monitor
We recommend using the new driver free based scripts for LedBorg.
The new driver free examples can be found here, the installation can be found here.
The following is code to display Network bandwidth usage with the multicolour LedBorg
The code looks at the Rx and Tx bytes counter and takes the difference over time.
This gives the number of bytes per second which is displayed in colour ranges, evenly split between Zero and a HeadLimit.
The code:
First two non-coment lines of script set the interface (iface=) and maximum bytes (maxBytes=) for the levels
download as text file here
Save file as netusage.sh
To change permissions and execute:chmod +x netusage.sh
./netusage.sh
The range is from 0% (Blue) to 100% (Red)
#!/bin/bash # Choose which network interface to poll and bytes per second at which to represent 100% iface="eth0" maxBytes=100000 # Setup our levels list level=("002" "012" "022" "021" "020" "120" "220" "210" "200") # Work out how many levels we have (level list length) levels=${#level[@]} # Get some starting values and wait to gather data echo "000" > /dev/ledborg lastRx=`cat /sys/class/net/${iface}/statistics/rx_bytes` lastTx=`cat /sys/class/net/${iface}/statistics/tx_bytes` sleep 1 # Loop indefinitely while [ 1 ]; do # Read network statistics rx=`cat /sys/class/net/${iface}/statistics/rx_bytes` tx=`cat /sys/class/net/${iface}/statistics/tx_bytes` bytes=$((($rx - $lastRx) + ($tx - $lastTx))) # Save starting values lastTx=$tx lastRx=$rx # Work out utilisation level util=$((($bytes * $levels) / $maxBytes)) if [ $util -ge $levels ]; then util=$(($levels - 1)) fi # Set colour based on utilisation echo ${level[$util]} > /dev/ledborg # Wait for next gather sleep 1 done