Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling accidental shutdowns #3

Closed
captn3m0 opened this issue Jan 19, 2017 · 5 comments
Closed

Handling accidental shutdowns #3

captn3m0 opened this issue Jan 19, 2017 · 5 comments

Comments

@captn3m0
Copy link
Contributor

I haven't setup a cron yet (as recommended), but I was wondering if the router goes down accidentally (say, on power loss) and I haven't checked the web-interface in a while, then the update/publish cycle won't get called.

Which means that the graphs would be inaccurate on the next reboot.

I think the wrtbmon code already has a lockfile, so running update/publish on a cron shouldn't have any adverse affects either.

@Kiougar
Copy link
Owner

Kiougar commented Jan 20, 2017

The /etc/init.d/wrtbwmon enable command enables the wrtbwmon service to run every time the router boots. This basically means the wrtbwmon setup command is run after every startup. This is the only thing needed by the update/publish cycle to work properly.

The update/publish cycle gets called every time you access the Usage page in your router. This ensures that the graphs you will see are the latest ones. AFAIK wrtbwmon uses iptables rules to track bandwidth so you shouldn't see any inaccurate data (whenever you run update the db file used by wrtbwmon is updated to the latest total bandwidth usage).

You are probably right that a cron job would not have adverse effects; however it is not needed. The interval used in the UI is only needed by the speed columns.

@captn3m0
Copy link
Contributor Author

I'm still going through the wrtbmon codebase, but still confused.

Where does wrtbmon persist the data between reboots? Wont the iptables rules get reset on a reboot?

@captn3m0
Copy link
Contributor Author

Ok, so looks like a reboot doesn't persist.

Yesterday (I had some data for sure):

image

Today:

image

  1. The data clearly reset between the 2 days, so persistence doesn't seem to be working. I'll likely add a cron for this.
  2. I'm still skeptical of the numbers though. Everything started from 0 as soon as I opened the Usage tab. Since the service is enabled, shouldn't it have just dumped whatever was the usage since last boot?

@Kiougar
Copy link
Owner

Kiougar commented Jan 20, 2017

I see now what you are trying to do. I don't think the cron job will be able to persist the data. This is because wrtbwmon setup (and subsequently luci-wrtbwmon) uses /tmp/usage.db as the location of the database file. Everything under the /tmp folder will be deleted after every reboot.

In my opinion the above is the correct way of handling data for your router. Storing a db file in any other place than the /tmp directory can quickly fill the memory of your router (making it unresponsive).

However, I'm open to suggestions if you have something in your mind that can "solve" your problem, without adding installation overhead (i.e. tricky configuration steps).

@captn3m0
Copy link
Contributor Author

  • I'll try to setup a mount so that the file is persisted on my home-server instead of the router.
  • The usage.db fie isn't actually that large. It takes one line per IP address, and depending on your address space it could be feasible to store it on the router. I have a very limiting router (2MB disk-space), and I can justify the usage.db filesize (<1kB as of now).

Maybe just having a configurable option on the location of the file. The usage.htm can continue to stay on /tmp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants