1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Das Blinkenlights for Asus (and others)

Discussion in 'Tomato Firmware' started by rhester72, Sep 13, 2010.

  1. rhester72

    rhester72 Network Guru Member

    Years ago (literally!), I posted an Init script for Linksys WRT routers (with the white-and-orange LEDs) that provided a visual "load meter" to indicate approximate "busyness" via changing the color of the LEDs (escalating from white to white-orange to orange based on load).

    This was enormously helpful in troubleshooting and made for a fun way to see how things were percolating from across the room. =)

    Time moved on (as did I), and later generations of routers from other manufacturers sadly provided only a single power light to play with. Bother. Gone was the handy how-busy-are-you light.

    I am happy to present the solution for the monochromatically challenged among us: The single-LED load script.

    echo '#!/bin/sh
    while usleep $(($d*10000));do
    d=`cat /proc/loadavg|cut -d" " -f1|tr -d .|sed s/^0*//`
    [ $d = "" ] && d=0
    [ $d -lt 100 ] && (led diag on;usleep $(((100-$d)*10000))) || d=100
    [ $d -gt 0 ] && led diag off
    sh /tmp/laled.sh &
    Simply paste into the top of your Init script and reboot.

    It functions by sampling the load average once per second and converting it to milliseconds. For example, if the load average is 0.00, the power light will remain completely off. If it is 0.30, the power light will come on for 0.30 seconds, then turn off for 0.70 seconds (or thereabouts). If the load average is 1.00 (or greater), the power light will remain steady on. The gist is, the more "lit" the power light is, the more load the router is under.

    Asus routers in particular may be the only ones where the GPIO pins are reversed (i.e. the diag led "off" means "lit") - if yours behaves 'backwards', just change "led diag on" to "led diag off" and vice-versa.

    It's still not as pretty as the Linksys multicolor LEDs, but it'll do in a pinch - and I've already found it useful in diagnosing perfomance issues on my RT-N16. Your mileage may vary.

    I am _assuming_ all recent TB builds (and Victek?) include usleep - I run the Extras build, so I'm not 100% sure, but it's absolutely required here...resolution less than one millisecond would just not be useful.


  2. spookyneo

    spookyneo Networkin' Nut Member

    It crashed on my RT-N16. I could not get the router back on, I had to reset the NVRAM (with SES button).

    I don't know why it crashed, but all the LEDs were on.
  3. rhester72

    rhester72 Network Guru Member

    Wow - my sincerest apologies!

    I'm not sure exactly how this could have happened - even if usleep (or sed) wasn't present, it _could_ loop endlessly very rapidly and spike the CPU, but it shouldn't outright prevent a boot.

    I will try to do more testing on my end to see what's going on. In the meantime...

    - What build of Tomato are you running?
    - Does it include usleep and sed?

  4. spookyneo

    spookyneo Networkin' Nut Member

    Sorry for my lack of information. I was in a rush yesterday.

    I'm running build 50 of ND 1.28 on RT-N16. Typping usleep and sed in putty reveals that the commands do exist.

    Nice script by the way :) I'm looking forward to testing the new version !
  5. rhester72

    rhester72 Network Guru Member


    I've analyzed this thing up one side and down the other and can't find an issue. I've tried reproducing what you saw by forcibly removing the binaries, intentionally putting errors in the script, you name it - and each and every time the behavior is predictable (and never results in an unresponsive router).

    The best guess that I have is that you exceeded NVRAM limits (VERY easy to do when using OpenVPN!) once you committed the Init script change - this is not checked for (nor is an error thrown) when NVRAM is updated, but overflowing NVRAM will indeed cause quite a few problems for the router.

    I've put the script back up, but would be interested in seeing the output of the following:

    nvram show | tail -1

  6. occamsrazor

    occamsrazor Network Guru Member

    I don't mean to highjack this thread but it seems somewhat related...

    I have a WL-500GPv2 connected to a DLink adsl router which is used as a modem-only in bridged mode - i.e. the DLink handles the adsl PVC modem stuff, and the Tomato initiates the PPPoE connection through it. The Dlink has two lights, one showing the ADSL status (which is actually the adsl sync) and another called "internet" which shows if a PPPoE connection has been made successfully from the DLink (not the Tomato).

    The problem is the "internet" one will never be ON because the Tomato is making the PPPoE connection, while on the Tomato router the WAN light will always be ON because it sees the WAN is always connected to the Dlink. As a result, as long as the adsl is in sync, there is no way for me to tell if the internet is down or up, by which I mean whether the Tomato router is "connected" or "disconnected" as shown on its Overview page.

    So... I guess my question is, is there any way for me to show on one of the Tomato router lights whether the internet is actually connected or not? Given that the only lights available are Power, LAN x 4, Wifi, and WAN... I was thinking perhaps there was a way to have it like this:

    WAN light stable: WAN status "connected"
    WAN light flashing: WAN status "disconnected"
    WAN light off: No WAN cable present

    Any ideas?

Share This Page