What's new

Traffic stats not saved (despite 'custom location')?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

exscape

New Around Here
Hi!
Sorry about the two threads, but I figured one thread per issue is at least better than having two separate questions in one.

I've set up my router to store traffic history:
Traffic history location: Custom location
Save frequency: Every 1 hour (for testing)
Save history location: /jffs/stats/ (exists and is writable)

I used the 'create data files' options the first time around, and have per-IP logging enabled.
I've previously tried storing stats on /mnt/sda1/stats/ (USB stick) but tried JFFS when that didn't work.

What happens is that while running, it all works - the stats look good etc. But when I shut down/reboot, all stats are reset.
The stats directory contains two files, tomato_cstats_[id].gz and tomato_rstats_[id].gz.

It does appear to save stats to the files - the mtime is updated and the files grow, etc... Yet on reboot the stats disappears and the files start over (are smaller than before the reboot):

# Pre-reboot
admin@RT-AC66U:/jffs/stats# uptime
09:36:37 up 1:06, load average: 0.00, 0.00, 0.00
admin@RT-AC66U:/jffs/stats# ls -l
-rw-rw-rw- 1 admin root 512 Mar 13 09:30 tomato_cstats_50465dd1b7b8.gz
-rw-rw-rw- 1 admin root 80 Mar 13 09:30 tomato_rstats_50465dd1b7b8.gz

# After reboot, a minute later
admin@RT-AC66U:/jffs/stats# uptime
00:00:48 up 0 min, load average: 0.41, 0.13, 0.04
admin@RT-AC66U:/jffs/stats# ls -l
-rw-rw-rw- 1 admin root 20 Jan 1 00:00 tomato_cstats_50465dd1b7b8.gz
-rw-rw-rw- 1 admin root 51 Jan 1 00:00 tomato_rstats_50465dd1b7b8.gz
admin@RT-AC66U:/jffs/stats# date
Sat Jan 1 00:00:55 GMT 2011

... it seems the clock is also not saved (no RTC?), which I guess is not a huge problem if NTP works properly. About a minute af actual time later, the clock is correct again, but the files are of course not restored.

Any advice? If this keeps up I might as well store in RAM and not cause wear to the disks!
 
There is no RTC in the router indeed.

I do not recommend storing stats to JFFS, unless you use a very long save delay (once a day, for example). Writing to nvram every hours will prematurely wear out your flash. Best to use a USB flash drive - cheaper to replace a worn out USB drive than a 200$ router with defective flash.

I can't think of any reason why the data file would be rewritten from scratch, especially since the datafile cannot be automatically created (unless you somehow had the option to create the data file staying enabled between reboots).
 
Thanks for the reply. It doesn't look like that:

# nvram show | grep stats_new
rstats_new=0
size: 36395 bytes (29141 left)
cstats_new=0

I'm very new to everything that has to do with the router software, though (I've only used Linux computers as routers before, i.e. no finished software like the *WRT* variants).

These are all of the settings:

admin@RT-AC66U:/www# nvram show | grep stats
size: 36395 bytes (29141 left)
rstats_new=0
cstats_all=1
cstats_exclude=
rstats_offset=1
cstats_include=
rstats_stime=1
rstats_exclude=
rstats_data=
rstats_path=/jffs/stats/
rstats_bak=0
rstats_sshut=1
rstats_enable=1
rstats_colors=
cstats_new=0
cstats_sshut=1
cstats_enable=1
 
Thanks for the reply. It doesn't look like that:

# nvram show | grep stats_new
rstats_new=0
size: 36395 bytes (29141 left)
cstats_new=0

I'm very new to everything that has to do with the router software, though (I've only used Linux computers as routers before, i.e. no finished software like the *WRT* variants).

These are all of the settings:

admin@RT-AC66U:/www# nvram show | grep stats
size: 36395 bytes (29141 left)
rstats_new=0
cstats_all=1
cstats_exclude=
rstats_offset=1
cstats_include=
rstats_stime=1
rstats_exclude=
rstats_data=
rstats_path=/jffs/stats/
rstats_bak=0
rstats_sshut=1
rstats_enable=1
rstats_colors=
cstats_new=0
cstats_sshut=1
cstats_enable=1

I can't see any reason why the stats would be reset between reboot, sorry. Only theory I might have would be the router rebooting while it's still saving stats, leaving an empty file. Try with a USB disk to see if it makes any difference.
 
I used a USB disk before I tried JFFS. However I just noticed in the "ps" output that both rstats and cstats are run with the parameter --new !
Based on what I've read in the source that shouldn't happen, but clearly that is the problem.

So now the question isn't why the stats aren't being saved, but who is starting them with --new despite the NVRAM variables being 0. :confused:

Edit: Uh, this might be resolved now. As for why, well... Who knows?
I did "nvram set cstats_bak=1" and "nvram set rstats_bak=1", but my guess is that was *not* the solution.

Rather, all I did was to ensure that the _new variables were = 0, and ran "reboot" via SSH. After the reboot, the stats were intact, and the services didn't start with --new.
After that, I tried a "hard" reboot by hitting the power switch on the router. The stats survived that, too!
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Members online

Top