LED color based on bandwidth usage

I wrote a small program to set the color of the lan0/wan LEDs based on the bandwidth usage. 0% usage = green, 50% usage = yellow, 100% usage = red. I’m using the wan LED to show the download usage and the lan0 LED to show the upload usage.

The wifi leds change from green/yellow/red based off of all traffic (not just your traffic) on that channel.

The code for it is here: GitHub - ddrown/omnia-led-colors: Set the LEDs on the Turris Omnia based on the bandwidth/wifi usage

To install it:

opkg update
opkg install git
git clone git://github.com/ddrown/omnia-led-colors.git
cd omnia-led-colors
./install
# Check the settings in /etc/config/omnia-led-colors

And a video of it in action:

To uninstall the older version:

/etc/init.d/iface-colors stop
/etc/init.d/iface-colors disable
rm /etc/init.d/iface-colors /root/iface-colors

30 Likes

edit-link to youtube-video? Can you replace with correct one? :slight_smile:

2 Likes

Nicely done! Great job! :+1:

Thank you for the great work. Looks neat :slight_smile:
However, I had to change a small thing to ensure the wan_interface is correctly matched (had the problem that there is an interface named ifb4eth1 on my turris which also matches when wan_interface is set to eth1).

27c27
<     local pat = wan_interface..":%s*(%d+)%s+(%d+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+(%d+)%s+(%d+)%s+"
---
>     local pat = "^%s+"..wan_interface..":%s*(%d+)%s+(%d+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+(%d+)%s+(%d+)%s+"
1 Like

Good point, thank you. I’ve updated the code with your change.

I have a couple of “ideas”.

Idea 1: I was wondering, is it also possible to use the LEDS to indicate that the channel interference is too much?

So for example, you are on a certain wifi channel being 2.4 GHz or 5 GHz, after a while you see it is just too noisy, so it is better to change channels. This is a typical situation that many times occurs, but you don’t really check it.

Scan networks, if the networks which are on the same channel are more then x then show color y on LED x.

Idea 2: Does the Omnia already indicate when there is no WAN-connection at all? So if there is no internet connection that it gives you a certain color? So for example put a sort of “ping www.google.com” and if the outcome is oke, give LED x color y if the outcome is 0 then give color z.

Idea 3: I will probably put the auto update on “ask me for installation”. Have a LED blink certain color when a update is pending. Because usually even with us geeks, we do not look on our router very often after a while. So a LED-indication would be nice.

This is for these idea for now, if i come up with more ideas, i’ll share them with you guys.

Additional Idea’s

Idea 4: When somebody is trying to use different passwords to try to connect to your wifi-network. Then after so many attempts which have resulted in to a failure…give color x…or maybe even let ALL the LED blink red or something/send email to you as warning :stuck_out_tongue: ). I am not sure if this is possible, because you have to count the attempts and log this behavior.

Idea 5: If somebody …anybody is connected to the wifi, give LED x color y.

Idea 6: If protocol x (http/ftp/p2p/voip/etc.) is taking the most bandwith, give color x. So you will see by LED color which protocol is really being dominant

Idea 7: If somebody is connected through VPN/FTP/SAMBA/HTTP/SSH/etc. on the Omnia, give LED x color y.

Additional…additional idea’s.

Idea 8: If somebody connects to wifi, let all LED’s blink color x 3 times.

Idea 9: If a new mac address is being recognized, give for few seconds LED x color y.

Well you know what… i quit!!.. THere are just toooo many ideas. You guys come up with the rest XD.

1 Like

I like the idea of wifi channel activity. The ath9k driver (Omnia’s 2ghz radio) gives stats on this as part of the survey dump output.

There are a few stats out of survey dump, but the main one for this is “busy”. Busy is the total time spent in rx, tx, and receiving other (possibly non-wifi) signals. This counts both packets sent to your AP and packets being sent to other APs on the same or nearby channel.

Downside is, the ath10k (Omnia’s 5ghz radio) does not (yet) support the survey counters.

I’ve updated the iface-colors script to include this.

Well, i guess we don’t have to worry for that in the near future. Most routers are using by default only the 2.4 GHz. Also, people still do have clients that are still 2.4 GHz only (802.11b + G + N), although 802.11b is almost completely vanished.

The 5 GHz has also MUCH more channels available then 2.4 GHz, so the chance of inteference or even a channel being to noise…will not be a issue for at least the coming 3-5 years I THINK!! :P.

EDIT: Well logically speaking, i think even in a apartment building, if all the people would use a 5 GHz, then you would still not have that much interference. Because 5 GHz does not go that far, so the interference from the neighbor is almost minimal and because of so many channels, we can kind of exclude the whole issue of a channel being to crowded. Maybe in a VERY VERY big city with MANY MANY skyscrapers close to each other or so.

Would it be possible to measure the bandwidth for each interface and display it for each interface by particular led? (for up and down directions, it would be best to count usage for each direction and use the higher value) :slight_smile:
This is more like theoretical question (I don’t know lua and I didn’t check it more deeply, so I’m not sure how difficult it will be (to write it and to count it by the router).

@horada - yes, that’s very close to what the wan_led function is doing. You could do something similar to measure wifi speeds and set the color that way.

@Big_boss - agreed, 2GHz is much more crowded than 5GHz for the reasons you list. I see some activity by the ath10k developers working on survey support, so it might be added in a later kernel. When looking for alternative ways to get this data, I see the file /sys/kernel/debug/ieee80211/phy0/ath10k/fw_stats might be useful.

The question is, when Omnia team will include that kernel in Turris-OS. Their previous kernel was 3.18 (heard from other people), the current kernel is 4.4. Those both kernels are LTS. So i guess the Omnia Team updates from one LTS to another LTS kernel. Then is the question when do the developers add the survey support in to the kernel. So it COULD take at least 6 - 12 months. 4.4 is still from back in jan-2016. There is a chance that MAYBE 4.9 will be the next LTS. If it becomes indeed the LTS version and the developers haven’t added in to that kernel, then we have to wait for at least 6 months to 1 year.

Ok, I got the ath10k stats working. I switched from using a gist to a full git repo as the program is getting big. I switched the name as well and edited my first post with the updated info.

One oddity about the ath10k stats is that every time the cycle counter rolls over (every ~24 seconds), all counters get divided by two. This leads to a slight over-estimation because you can’t be sure about when the other counters rolled over, but it shouldn’t be visible in the LED color. The other choice is to just throw away the counters every time they roll over, which wouldn’t be that bad at 1/24 (4%).

The ath10k LED is showing the same thing as the ath9k: % of channel busy time (including other people sharing your channel). I’ve verified this works by setting up another 5GHz AP on the same channel and seeing the LED color change while I transfer data to the other AP :slight_smile:

1 Like

Nice!!

Could you maybe add a small README or so, that explains what kind of different functionality it does. Bandwidth + % of interference channel. Also a bit more/newbish comment lines adding to it. So for people who aren’t that familiar with the programming can also read/understand it.

For now, we know exactly what it does, but we have to keep in mind that over maybe 1 years most of us gonna forget what has been changed/added and what was this project about LEDs all about.

If it is too much work, then never mind off course. It is just a suggestion.

Great script! Thank you!

I switched the leds to some unused leds like lan3 and lan4 (nothing conntected to these ports). However, I noticed that the leds do not get auto enabled when your script starts. I had to manually enable them using the webinterface.

// seems like the settings survives a restart

I tried to install this option, unfortunately I got errors:
    root@turris:~# opkg install git
    Unknown package ‘git’.
    Collected errors:
    * opkg_install_cmd: Cannot install package git.
    root@turris:~# git clone git://github.com/ddrown/omnia-led-colors.git
    -ash: git: not found
    root@turris:~#

As far as I’m novice as to openWRT, could you please advice?

@Big_boss: a readme is a good idea

@cr0: LuCI’s System > LED Configuration lets you change what the LEDs blink for. This program just sets the color not the brightness (or on/off)

@jada4p: Ah, I forgot a step: opkg update I’ll update the install instructions

TIA
One more LED color idea :wink: change POWER LED color depending on load…

2 Likes

Ok, I added a readme and created a new video to show off the WiFi usage LEDs

@jada4p: for load, are you thinking CPU load?

1 Like

After seeing the video, i came to a “adjusted” idea.

In this case you use 1 LED. However, when somebody has put more functionality in LED-indications, then it becomes confused which LED is really burning, especially if you have used the wallmount a distance from you.

How about this.

When nothing is happening, as usual one green LED is showing. When load gets to 50% from right or left the current LED is showing ORANGE + the LED besides it is showing ORANGE. When the load gets to 100%, those early two LED’s are showing RED and also the third one beside the second one is showing RED.

So you will be seeing up to 3 LED’s based on the load.

What do you think about this? Please do give me your perspective, maybe i am missing something and it is a bad idea.