totalizator / tomato-sdhc-vlan

Automatically exported from code.google.com/p/tomato-sdhc-vlan
0 stars 0 forks source link

cstats data lost if cstats restarted and history saved in RAM. #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
>What steps will reproduce the problem?
1.  Have "IP Traffic Monitoring" stored in RAM
2.  On the "Admin: IP Traffic Monitoring" page press save
3.  Or instead of #2, stop and start the cstats process

>What is the expected output? What do you see instead?

I expect the IP traffic to be preserved, but it is lost.

>What version of the product are you using? On what operating system?

I'm using Toastman's latest TomatoUSB build on a Linksys E3000.

>Please provide any additional information below.

The cause for this problem is that the load procedure in cstats.c does not 
contain code to load the history if there isn't a "cstats_path" set.  Since 
"cstats_path" is null when RAM is used, the existing data isn't loaded when 
restarting cstats.

By comparison, rstats does load the existing data from the RAM disk if it's 
there.  The code that does that is lines 397 to 402 located at 
http://repo.or.cz/w/tomato.git/blob/refs/heads/Toastman-RT:/release/src/router/r
stats/rstats.c#l397.  It should be placed right after line 345 in 
http://repo.or.cz/w/tomato.git/blob/refs/heads/Toastman-RT:/release/src/router/c
stats/cstats.c.

The code is:

        f_read_string(source_fn, sp, sizeof(sp));       // always terminated
        _dprintf("%s: read source=%s save_path=%s\n", __FUNCTION__, sp, save_path);
        if ((strcmp(sp, save_path) == 0) && (load_history(hgz))) {
                _dprintf("%s: using local file\n", __FUNCTION__);
                return;
        }

Original issue reported on code.google.com by morac1...@gmail.com on 3 May 2012 at 6:31

GoogleCodeExporter commented 9 years ago
Although cstats/IPTraffic is based on the very same code as rstats (which keeps 
track of usage for one/single WAN interface), the truth is... cstats was never 
thought/designed to be storing its data in RAM (and/or NVRAM), mostly due to 
storage requirements (7920 bytes for each IP address being tracked).

Therefore, I thing this should be moved/changed from 'Defect' to 'Enhancement'.

Original comment by augu...@bott.com.br on 4 May 2012 at 2:25

GoogleCodeExporter commented 9 years ago
Maybe there can be a limit on the number of ip addresses tracked while in RAM 
then?

Personally I have a Linksys E3000 which has plenty of excess RAM and the data 
is stored on the RAM disk compressed anyway, so storage issues weren't a factor.

Original comment by morac1...@gmail.com on 4 May 2012 at 5:17