Tomato command line to get connection uptime?

Discussion in 'Tomato Firmware' started by stormy, Aug 14, 2012.

  1. stormy

    stormy Networkin' Nut Member

    Is there any command line that allows seeing the ADSL "uptime"?

    I know the router uptime is using that command "uptime" but looking for the ADSL/PPPoE connection uptime. I know I can grep the /var/log/messages, but this can get overwritten after some time..

  2. crashnburn

    crashnburn Network Guru Member

    Funny, I am trying to figure out the same.. Internet uptime v/s downtime for my DSL Line.
  3. Porter

    Porter LI Guru Member

  4. crashnburn

    crashnburn Network Guru Member

  5. Porter

    Porter LI Guru Member



    Do you want me to cook you dinner, too?
  6. koitsu

    koitsu Network Guru Member

    Can't you just access your DSL bridge or your cable modem and look at the log from there? Usually physical interface or line quality issues will show up there. I don't think this is really a router's responsibility; for example, PPPoE going down could be the result of a physical line quality problem (SNRs going out of range, etc.), or be due to a protocol problem (e.g. ADSL line itself is perfectly fine, but the ISP chose to reboot their DSLAM or device that does the PPPoE encapsulation). You won't be able to know the difference within TomatoUSB.

    It's much more effective to look at your DSL bridge or cable modem directly. Many of them have administrative interfaces, such as Motorola's cable modems which listen on (and you do not need to have your machines as part of that network to access it), which contains signal stats and logs. I wrote a perl script to ""parse"" the HTML from my cable modem so I can have stats/etc. available periodically on my FreeBSD box. Example:

    Aug 14 13:40:00        Firmware: SB_KOMODO- (Apr 17 2012 15:09:37)
    Aug 14 13:40:00    Boot Version: PSPU-Boot(25CLK) 1.0.12.
    Aug 14 13:40:00    Modem Uptime: 15 days 20h:22m:1s
    Aug 14 13:40:00  Down Channel  1: 705000000 Hz,  0 dBmV power, 37 dB SNR, mods: QAM256
    Aug 14 13:40:00  Down Channel  2: 717000000 Hz,  0 dBmV power, 37 dB SNR, mods: QAM256
    Aug 14 13:40:00  Down Channel  5: 735000000 Hz,  0 dBmV power, 37 dB SNR, mods: QAM256
    Aug 14 13:40:00  Down Channel  8: 753000000 Hz,  -1 dBmV power, 34 dB SNR, mods: QAM256
    Aug 14 13:40:00    Up Channel  9:  23700000 Hz,  47 dBmV power, 5.120 Msym/sec, mods: [3] QPSK [3] 64QAM, status: Success
    Aug 14 13:40:00    Up Channel  7:  35400000 Hz,  48 dBmV power, 2.560 Msym/sec, mods: [3] QPSK [2] 16QAM, status: Success
    Aug 14 13:40:00    Up Channel  8:  30600000 Hz,  47 dBmV power, 5.120 Msym/sec, mods: [3] QPSK [3] 64QAM, status: Success
    Aug 14 13:40:00 Stats Channel  1: 62229824776 unerrored, 27312 correctable, 639 uncorrectable
    Aug 14 13:40:00 Stats Channel  2: 62229190775 unerrored, 29670 correctable, 511 uncorrectable
    Aug 14 13:40:00 Stats Channel  5: 62229194756 unerrored, 25780 correctable, 567 uncorrectable
    Aug 14 13:40:00 Stats Channel  8: 62229203202 unerrored, 17507 correctable, 546 uncorrectable
  7. stormy

    stormy Networkin' Nut Member

    Thanks for the reply.. I'm using what I think is latest version of the Tomato firmware, however that command doesn't work.

    # cat /etc/motd
    Tomato v1.28.1816
    # wanstatus
    -sh: wanstatus: not found
    # cpu
    -sh: cpu: not found
    # memory
    -sh: memory: not found
    # dns
    -sh: dns: not found
    I connect to the modem using telnet/ssh.
  8. koitsu

    koitsu Network Guru Member

    Where did you get those commands ("wanstatus", "cpu", "memory", "dns") from? Nobody in this thread has mentioned any commands to try.
  9. stormy

    stormy Networkin' Nut Member

    Reply #3 by Porter says:

    I tried the other commands in the near by section of that code to show that they don't work either.. it must be some internal commands or maybe honored in some other context. For now I look at the log and that mostly gives the answer.. also looking at ifconfig ppp0 shows how much data passed, so can give a rough idea.
  10. koitsu

    koitsu Network Guru Member

    "wanuptime" isn't a command -- what Porter said is extremely misleading.

    What he did was point you to a piece of code in TomatoUSB that refers to a server-parsed HTML document (e.g. the GUI of TomatoUSB) and told you to look at the "wanuptime" variable used within JavaScript (NOT THE CLI!). This variable correlates directly with the field you see in the GUI under Status -> Overview labelled Connection Uptime.

    It's the sign of someone who did not read what you asked (you specifically asked for a CLI command that could provide you that information).

    You can't even do something utterly horrible like use wget/curl to fetch (plus do authentication) and then strip out the line in the output you want -- because JavaScript is involved.

    And again: looking at the log (/var/log/messages), or doing ifconfig ppp0 and looking at interface statistics, does not tell you what the nature of the problem is (when things go down). It doesn't tell you if there is a physical line problem (e.g. SNR or power level issue on your DSL line), or if your ISP just decided to reboot their DSLAM or do maintenance on it (those are two COMPLETELY different situations). Re-read the first paragraph of my earlier post. The delineation is important when reporting "my service is down" to your ISP (e.g. is PPPoE down or is your actual DSL line having issues (SNR/power levels, etc.)). There's a huge, huge difference between the two.

    You should instead try to get this information from your DSL bridge rather than from your router. If you did PPPoE on your DSL bridge (some bridges support this -- and it's awesome, let me tell you), you could determine both of those situations using the bridge.

    Anyway, if that lack of delineation is acceptable to you, no, to my knowledge there is no way to get this information accurately/reliably. You can probably find some posts on the Internet where people have said look at the modification timestamp of /var/run/ (or similar) but that isn't indicative of anything. Reading the syslog for pppd (e.g. /var/log/messages) is the best choice.
  11. Porter

    Porter LI Guru Member

    Sorry, but wanuptime is a command and it actually provides the "ADSL uptime". But its output is altered in the GUI and it seems it is the only direct command you can actually use on the command line. Everything else seems to be server-parsed HTML. I understand that this might have been misleading.

    From my point of view I just got lucky. ;)

    And I agree with you, koitsu that ADSL uptime doesn't say anything about the source of stormy's problems.

    For some ADSL modems nice people have programmed GUIs that make accessing and interpreting theses values very easy. Just find out the modem model and google for it.
  12. stormy

    stormy Networkin' Nut Member


    I don't have any problem with my connection, someone ELSE (crashnburn) posted on my entry (wanted some coffee too).. so all these suggestions to look in the ADSL modem are good, but do not apply to me :)


    As I said:

    # wanuptime
    -sh: wanuptime: not found

    does not work on the latest Tomato CLI (via ssh/telnet)..


    Actually the timestamp on /var/run/ is a nice trick :) seems very accurate so far. thanks.
  13. koitsu

    koitsu Network Guru Member

    Sorry Porter, there's two terms being used here and I appear to have confused the two. Earlier stormy tried running "wanstatus" (see previous post) as a CLI command, which is where I got the idea someone said wanstatus was an actual binary/CLI command. That's where my confusion began. :)

    Those two terms:


    "wanstatus" is actually the name of the JavaScript variable for the GUI, blah blah blah -- like I said above.

    "wanuptime" IS an actual CLI command and does work (for me as well, and I don't use PPPoE):

    root@gw:/tmp/home/root# wanuptime
    root@gw:/tmp/home/root# which wanuptime
    So possibly the command is only available on some TomatoUSB versions (or possibly only newer builds, newer than what stormy runs?). I run tomato-K26USB-1.28.0500.2MIPSR2Toastman-RT-N-VPN.trx.

    The number appears to be the number of seconds the connection has been up. GUI says:

    Status Connected
    Connection Uptime 15 days, 06:30:37
    Remaining Lease Time 2 days, 11:11:44
    Simple math:

    root@gw:/tmp/home/root# expr 1319103 / 60
    root@gw:/tmp/home/root# expr 21985 / 60
    root@gw:/tmp/home/root# expr 366 / 24
    Yup, looks right.
  14. stormy

    stormy Networkin' Nut Member

    Oh, wow..I was not aware that TomatoUSB is actually a different firmware/fork. I was always wondering why no new code is coming out.. now I see all these forks out there.. I might give one of them a try, thanks :)
  15. Toastman

    Toastman Super Moderator Staff Member Member

    Wow, it's rather odd that you missed that!

    For anyone else reading this thread, tomatoUSB as such has not been actively maintained for over a year now. Teddy Bear, the developer who began it, has left the project and will not be returning to it. I was asked by him to take over the project but all attempts to contact people to obtain necessary permissions and passwords has failed.

    There are several branches based on tomatousb code that was last published about a year ago. Depending on the developer of the "mod" there is no absolute consistency between them, but in general they are pretty much similar in base functions.

    Mods by Toastman/Victek/Shibby are most popular, there are also special developments by others such as Teaman (VLAN GUI/MULTISSID) and JYAvenard (PPTP, + many bugfixes) which are usually also incorporated into other builds. All of the current developers borrow bits of code from others and the GPL spirit as still alive and well in the Tomato world!
  16. stormy

    stormy Networkin' Nut Member

  17. Toastman

    Toastman Super Moderator Staff Member Member

    Would a photo of the developer actually make the firmware run any better?

    This is my favourite cat, my friend, who died of cancer many years ago :p
  18. stormy

    stormy Networkin' Nut Member

    I think developer personality has to do a lot with the longer term quality and direction of the code.. That cat photo is certainly playing on emotions there :) Thanks all for the help on this thread.

  19. kthaddock

    kthaddock Network Guru Member

    Do you choose firmware as developer looking ? oh my good!!

    Ps: I like the CAT !
  20. mvsgeek

    mvsgeek LI Guru Member

    As long as it doesn't make it run like a dog;)
    p.s. I like your cat too.
  21. crashnburn

    crashnburn Network Guru Member

    Stormy - Relax. I created a thread and little later found yours asking similar stuff (not same). PS: I cant imagine how someone like you who works for Oracle HQ at Redwood city would respond on this fashion.

    Koitsu - asked me to check out his replies on this thread. Simple?

    One of my earlier ADSL Modems used to log the error codes and frequency / times it used to go down. So, I used to use that and copy info from it when I had to complain to ISP for frequent disconnections or poor service.

    Right now, the new DSL modem does not seem to log that way. I'll see if I can look up and post the model of the DSL Modem.

    So, I figured maybe there was an easy way for RT-N16 / Tomato router to "Log Internet Ups & Downs" - Maybe it is already logging this and I have to filter it.. OR I have to write / use some existing script. So, I was looking for guidance on how one could do that.

    Given that Tomato USB is not the ONLY forum or ONLY technology I end up working with and there are many other tech devices and things to HANDLE, it would make sense to look for existing solutions rather than start one from scratch. Save time.

    Any thoughts?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice