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

allow monthly bandwidth tracking to start on a different day for each interface #174

Open
paulo-erichsen opened this issue Oct 22, 2020 · 3 comments

Comments

@paulo-erichsen
Copy link

description

this is a feature request for vnstat to allow keeping track of billing cycle usage for different interfaces that start on different days

can we make the MonthRotate option to be set on a per interface basis?

description for MonthRotate from vnstat.conf(5)

   MonthRotate
          Day of month that months are expected to change. Usually set to 1 but can be set to alternative values for example for tracking monthly billed traffic where  the
          billing  period  doesn't start on the first day. For example, if set to 7, days of February up to and including the 6th will count for January. Changing this op‐
          tion will not cause existing data to be recalculated. Value range: 1..28

use case

say I have different ISPs on different interfaces, or for example one interface could be a cellular connection while the other interface using a different ISP. I'd like to easily be able to get the monthly usage for both interfaces even though their billing cycles are different

example:

  • ISP A on interface A: cellular data that starts its billing and monthly usage on the 15th of each month
  • ISP B on interface B: regular ISP that has higher bandwidth that has billing starting on the 1st of each month
@vergoh
Copy link
Owner

vergoh commented Oct 31, 2020

Thanks for the feature request. I think this is something that should be possible to implement. Currently the main limiting factor is the implementation of the configuration file reader which doesn't support per interface configurations on a generic level. There's also the MonthRotateAffectsYears setting in the configuration of which I'm not sure if it too should be then be interface specific or not.

@rwb196884
Copy link

rwb196884 commented Jun 3, 2024

Since this obviously isn't going to happen here's a script to get the total since some time.

begin=$( date -d "2024-06-01" +%s )
mb=$( vnstat -i hp --json | jq -r ".interfaces[0].traffic.fiveminute" | jq ".[] | select( .timestamp >= $begin ) | {\"t\": [.rx, .tx] | add}" | jq '[.t] | add' |
 paste -sd+ | bc | xargs -i echo "scale=0;{}/(1024*1024)" | bc )

@rwb196884
Copy link

Or maybe not

# vnstat -i hp --json d | jq -r ".interfaces[0].traffic.day" | jq ".[] | select( .timestamp >= $begin ) | {\"t\": [.rx, .tx] | add}" | jq '[.t] | add' | past
e -sd+ | bc | xargs -i echo "scale=2;{}/(1024*1024)" | bc
769.40
# vnstat -i hp --json | jq -r ".interfaces[0].traffic.fiveminute" | jq ".[] | select( .timestamp >= $begin ) | {\"t\": [.rx, .tx] | add}" | jq '[.t] | add' | paste -sd+ | bc | xargs -i echo "scale=2;{}/(1024*1024)" | bc
260.49
#

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

3 participants