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

SaveInterval Unit #263

Open
wy2919 opened this issue Jul 25, 2024 · 3 comments
Open

SaveInterval Unit #263

wy2919 opened this issue Jul 25, 2024 · 3 comments
Labels

Comments

@wy2919
Copy link

wy2919 commented Jul 25, 2024

Hello! Very cool application

It would be great if the unit of SaveInterval could be set to seconds, changing the unit would not affect the usage and would give the user more options and flexibility.

I read your answer in this thread, I think 4 years have passed, most of the servers are SSD now, IO should not be a big problem, could you consider changing the SaveInterval unit?

#157

@vergoh
Copy link
Owner

vergoh commented Jul 27, 2024

The question from #157 is still applicable:
What is the practical scenario for which you'd want to have the database written more often than the current limit of once every minute?

Changing the unit of an existing configuration isn't something I'm eager on doing. It would have the implication of breaking any possibly already existing post-configuration scripts which are setting SaveInterval so some specific value as that value wouldn't anymore have the desired effect. There are also for example plenty of embedded devices using vnStat where having a frequent disk write interval isn't practical due to how slow the media is or due to the wear writes can cause on the media. If there's nobody looking at the stats that often then it usually doesn't matter that much if the data is 1, 5 or 15 minutes old.

@wy2919
Copy link
Author

wy2919 commented Jul 29, 2024

I want to write a server traffic control program, because some servers have traffic restrictions, so I need to control my server traffic, use your open source vnstat program to get the server's current month's upload traffic, because the server export bandwidth is very large, so the measurement should be more accurate, so you need to vnstat shorter intervals!

If it is a compatibility issue, you see if you can add a new field for the unit of SaveInterval, the new field is just the unit of SaveInterval, the unit of the newly added field is minutes by default, but can be changed to seconds, so that you can be compatible with the old configuration file, but also provides additional extensions!

Of course, this is just a suggestion.

@vergoh
Copy link
Owner

vergoh commented Jul 31, 2024

I'm not sure if I fully understand the situation. The minimum value for SaveInterval is currently 1 so vnStat would update the database every minute. If you are targetting to stop the traffic on some server before the monthly transfer cap is reached, it should be enough to leave one minute worth of maximum transfer as "safety margin" when doing the evaluation of amount used so far (something you could use --alert for).

Is your configuration such that the server's transfer cap is so small and the maximum bandwidth so high that having a one minute "safety margin" would be too much? That would sound rather unusual but if that's the case, could you provide the actual numbers if possible?

If for example something like SaveIntervalSeconds would be implemented, the lower bound of the configuration would still be limited by UpdateInterval and PollInterval since there's no point saving the data more often than the data is getting read. That would most likely make writing the data possibly every 5-10 seconds as a lower limit if really necessary. I suspect the sqlite parameters could use some changing if such configuration is used in order to limit the disk write/sync penalty possibly caused by such frequent database writes (as in, I have no idea how much there would be a performance impact, if any, when using SSDs and the current default sqlite parameters).

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

No branches or pull requests

2 participants