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

Feature Request: vnstat persistant stats #1061

Closed
unipacket1 opened this issue Dec 13, 2018 · 14 comments
Closed

Feature Request: vnstat persistant stats #1061

unipacket1 opened this issue Dec 13, 2018 · 14 comments

Comments

@unipacket1
Copy link

Per the discussion here https://forum.opnsense.org/index.php?topic=9503
would like to ask if it would be possible to add an option to save vnstat data between reboots.

@soder10
Copy link

soder10 commented Jan 2, 2019

If I am not mistaken, this is an issue only for /var logs stored on a tmpfs? Non-volatile /var will preserve the stats across reboot?

@mimugmail
Copy link
Member

Yep ...

@mimugmail
Copy link
Member

@fichtner adding _mfs to rc.conf template is enough?

@fichtner
Copy link
Member

fichtner commented Feb 15, 2019 via email

@soder10
Copy link

soder10 commented Feb 16, 2019

May I ask what does "MFS installation" mean in this context?

@mimugmail
Copy link
Member

/var in ramdisk

@fichtner
Copy link
Member

fichtner commented Feb 16, 2019 via email

@soder10
Copy link

soder10 commented Feb 16, 2019

Ah, ok so its Memory File System.

@soder10
Copy link

soder10 commented Feb 4, 2020

Am I mistaken, or this issue was closed as "not implemented" feature?

@fichtner
Copy link
Member

fichtner commented Feb 4, 2020

Yes, you are mistaken.

@soder10
Copy link

soder10 commented Feb 4, 2020

Ok, in that case I am confused a little bit :) I run vnstat on MFS, and if I reboot the stats get cleared out. Even worse, the VNSTAT service breaks (cannot start) as long as I dont reset the database manually. Has to do something with igb vs ppoe interface binding during pppoe session establishment.

@fichtner
Copy link
Member

fichtner commented Feb 4, 2020 via email

@iso70x
Copy link

iso70x commented Mar 31, 2021

I ran into this issue, and after a device restart the vnstat service failed to load. The error given in the log was related to the vnstat db file being inaccessible. It looks like there is some inconsistency between the package default intended behaviour (storing the db file outside of the /var folder to persist data across reboots), vs the "reset database" button (which forces a new file to be written into the /var/lib/vnstat folder that will be lost as soon as a reboot occurs).

I've noticed that at some point, the vnstat package created this link on my OPNsense appliance (which is configured to use MFS for /var and /tmp):

/var/lib/vnstat -> /root/var/lib/vnstat

I assume this is to work around the volatile nature of var when using MFS (ram) for storage. The issue seems to be that the target of this link isn't accessible by the vnstat user. As a result, it can't create the db in there or read any existing db file.

Hitting "reset database" works temporarily, as this removes the link again and stores the db in the MFS folder structure, but then it's lost again as soon as a reboot occurs.

A permanent workaround seems to be changing the owner of the /root/var/lib/vnstat folder using:

chown -R vnstat:vnstat /root/var/lib/vnstat

After doing this, the service can be started up, and it will create the vnstat database in there. This survives reboots and the service starts without errors as well as showing historical stats even on VMS systems.

@soder10
Copy link

soder10 commented Apr 1, 2021

I ran into this issue, and after a device restart the vnstat service failed to load. The error given in the log was related to the vnstat db file being inaccessible. It looks like there is some inconsistency between the package default intended behaviour (storing the db file outside of the /var folder to persist data across reboots), vs the "reset database" button (which forces a new file to be written into the /var/lib/vnstat folder that will be lost as soon as a reboot occurs).

I've noticed that at some point, the vnstat package created this link on my OPNsense appliance (which is configured to use MFS for /var and /tmp):

/var/lib/vnstat -> /root/var/lib/vnstat

I assume this is to work around the volatile nature of var when using MFS (ram) for storage. The issue seems to be that the target of this link isn't accessible by the vnstat user. As a result, it can't create the db in there or read any existing db file.

Hitting "reset database" works temporarily, as this removes the link again and stores the db in the MFS folder structure, but then it's lost again as soon as a reboot occurs.

A permanent workaround seems to be changing the owner of the /root/var/lib/vnstat folder using:

chown -R vnstat:vnstat /root/var/lib/vnstat

After doing this, the service can be started up, and it will create the vnstat database in there. This survives reboots and the service starts without errors as well as showing historical stats even on VMS systems.

Thanks for the detailed description. I hope this gets fixed sometime now as the devs understand the scenario better.

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

No branches or pull requests

5 participants