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

cstats location

Discussion in 'Tomato Firmware' started by _wb_, May 23, 2014.

  1. _wb_

    _wb_ Networkin' Nut Member

    Last edited: May 23, 2014
  2. koitsu

    koitsu Network Guru Member

    /proc/net/ipt_account is managed by the kernel; it's a "file on a filesystem" (the UNIX concept) except /proc is not a normal "storage-based filesystem" (like /tmp or a JFFS or ext3 filesystem, etc.). So that "file" may contain some of the relevant statistics the cstats code uses for calculations, but it is not "the cstats data" (as in the data you're wanting to get) -- it's partially the source of info, but not the compiled/written information that you're wanting.

    The code, as you've seen, is spaghetti and greatly lacks comments. Sad panda :(

    From a VERY quick skim/glance (read: I could definitely be wrong) it looks like NVRAM variable cstats_path is involved. However there are all sorts of files all over the place this thing seems to dump containing information which I have no familiarity with (I have zero familiarity with cstats), like function save_speedjs() and save_histjs(). There's even mention of something called /var/tmp/cstats-load in main() with just a blind call to unlink() (delete the file).

    The long version is: someone who is in-the-know with this code and cstats will probably have to answer, otherwise someone will need to sit down and reverse-engineer this thing.
     
  3. _wb_

    _wb_ Networkin' Nut Member

    Thanks @koitsu ... the code is hard to read indeed.

    I think I read somewhere @teaman integrated this to Tomato.

    Not sure if he posts anything here but that would help a lot. I just want the raw file or figure out how it is parsed and displayed on the GUI.
     
  4. DJF - EasyTomato

    DJF - EasyTomato Serious Server Member

    Is /tmp/var/spool/cstats-*.js the data you're looking for?
     
  5. _wb_

    _wb_ Networkin' Nut Member

    @DJF - EasyTomato that folder contains cron only.
    Code:
    /tmp/var/spool# ls
    cron
    /tmp/var/spool#
    The only raw data (in bytes) I see for IPT is in /proc/net/ipt_account. That is updated every 2 seconds.
     
  6. DJF - EasyTomato

    DJF - EasyTomato Serious Server Member

    Try sending a USR1 and USR2 signal to cstats in order to make it write those files.
    kill -16 <pid of cstats>
    and
    kill -17 <pid of cstats>

    Code:
      PID USER       VSZ STAT COMMAND
      549 root      1028 S    rstats
      556 root      1280 S    cstats
    
    root@unknown:/tmp/var/spool# ls -l
    drwxr-xr-x    3 root     root            60 Dec 31  1969 cron
    root@unknown:/tmp/var/spool# kill -16 556
    root@unknown:/tmp/var/spool# ls -l
    drwxr-xr-x    3 root     root            60 Dec 31  1969 cron
    -rw-r--r--    1 root     root         86697 May 24 09:21 cstats-speed.js
    root@unknown:/tmp/var/spool# kill -17 556
    root@unknown:/tmp/var/spool# ls -l
    drwxr-xr-x    3 root     root            60 Dec 31  1969 cron
    -rw-r--r--    1 root     root         25926 May 24 09:21 cstats-history.js
    -rw-r--r--    1 root     root         86697 May 24 09:21 cstats-speed.js
    
     

Share This Page