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

Question xml output hour #22

Closed
Hellowlol opened this issue Jun 25, 2015 · 4 comments
Closed

Question xml output hour #22

Hellowlol opened this issue Jun 25, 2015 · 4 comments
Labels

Comments

@Hellowlol
Copy link

Im using the command --exportdb --xml, my xml is then converted to json.

The first id in traffic.days.day and traffic.months.month always seem to be current month/day. However if i do the same to traffic.months.month the usage reported will be in the id of the current hours. (So say i download a huge file at 1700 o'clock the reported use will be in id 16)

Output https://gist.github.com/Hellowlol/7808a07c190a911cc208

Is this intended?

@vergoh
Copy link
Owner

vergoh commented Jun 27, 2015

Few comments to begin with

  • --exportdb isn't needed when --xml is given
  • recent versions have --json to output json format directly
  • 1.11 is a rather old version, but it doesn't have --exportdb so which version are you actually using?
  • you mixed traffic.months.month with traffic.hours.hour in your question?

The id of hourly data does indeed follow the current hour unlike with daily and monthly data. Depending on the update method being used, doing a huge download at 1700 o'clock before the update may cause the download to be added to the id 16 instead of id 17. It depends whether an update for id 17 has already been done before the download.

@Hellowlol
Copy link
Author

Thanks for your reply.

I'm sorry for mixing the questions but your answered the correct question.

Currently I'm using 1.11, but it's a part of a larger project so the commands depends on what version the user has. The --xml is there is for simplicity (for the same reason is --json not used) https://github.com/Hellowlol/HTPC-Manager/blob/master2/modules/vnstat.py

So say current time is 1700 would id 18, 19 etc usage always be 0 or would it belong to the previous day?

@vergoh
Copy link
Owner

vergoh commented Jun 27, 2015

If current time is 1700 then id is 17 (think of date +%H) assuming the database has been updated within the current hour. Otherwise id 17 points to the previous day if vnStat has been running for the last 24 hours, if not then id 17 will contain rx 0 and tx 0. Use the date structure from within each hour to check if the data is from the current day or the previous.

@Hellowlol
Copy link
Author

Thanks for confirming!

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