forums.humdi.net

humdi.net project forums
It is currently Mon 06.09.2010 00:18

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Collect data between certain hours.
PostPosted: Sun 25.07.2010 02:37 

Joined: Sat 24.07.2010 20:50
Posts: 3
Code:
$ vnstat --version
vnStat 1.10 by Teemu Toivola <tst at iki dot fi>


Ubuntu 10.04
Code:
$ uname -a
Linux subbass-desktop 2.6.32-24-generic-pae #38-Ubuntu SMP Mon Jul 5 10:54:21 UTC 2010 i686 GNU/Linux


I have been using VnStat a long time now with a couple home made scripts to calculate my usage over a rolling 30 day period (is there any chance of a feature request for this, please).

My ISP allows quota free downloading between midnight and 8am. So I only now need to log between 8am and midnight "peak" time.

How should I manage to tell the daemon to only log data 8am>midnight. I understand with previous version I could change the cron and manage it, but I don't know how to do the same with the daemon.

Thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: Collect data between certain hours.
PostPosted: Tue 27.07.2010 02:07 
Site Admin
User avatar

Joined: Sat 03.01.2004 18:43
Posts: 462
Location: Oulu, Finland
subbass wrote:
I have been using VnStat a long time now with a couple home made scripts to calculate my usage over a rolling 30 day period (is there any chance of a feature request for this, please).

Has the one day resolution you are probably getting (unless you log the hourly output) been enough? Or do you scripts do some sort of averaging for the oldest day or do you check the total only every midnight? :)

Feature request are always welcome. I've added that rolling x day period and the limited logging to the TODO list.

subbass wrote:
How should I manage to tell the daemon to only log data 8am>midnight. I understand with previous version I could change the cron and manage it, but I don't know how to do the same with the daemon.

Even with the previous version, changing the cron timing was little bit of a hack since I hadn't planned of having that kind of feature in advance. That's the case with the daemon too. You can achieve that same result by adding a cron entry that stops/kills the daemon at midnight (that will force a database write) and then start the daemon again at 8am using the --sync parameter (forces the daemon to ignore all previous traffic that it didn't see). The only way to mess with the result would in that case be to reboot your system between midnight and 8am since that would cause the daemon to start logging. I can probably provide more detailed instructions for those cron entries if you need. Adding that --sync parameter to the start section of the vnstat script in /etc/init.d and then having the cron entries do /etc/init.d/vnstat stop or start is likely to be the easiest way.

_________________
- Teemu Toivola


Top
 Profile  
Reply with quote  
 Post subject: Re: Collect data between certain hours.
PostPosted: Tue 27.07.2010 02:32 

Joined: Sat 24.07.2010 20:50
Posts: 3
Thanks for the reply Vergo. I am happy to see the features considered for a future release.

The scripts consisted of two components, one to run from cron at 23:59 to make a log entry of the amount transferred; and the main command to read the log and calculate data; it also could list the previous 30days as well as show you todays totals. There are probably a bunch of things wrong with them as I'm not esecially good at Bash, but they seem to work.

The scripts are here:

rdnm : http://pastebin.com/KGHkr0Uf

rdnmcron : http://pastebin.com/aGH90RCU

rdnm has a couple of different outputs. short and long.

example of short:

Code:
$ rdnm

          Bandwidth usage breakdown
        30 day     .....  165570.72 MiB
        Todays     .....     200.75 MiB
        combined   .....  165771.47 MiB


example of long:

Code:
$ rdnm -l

Days 1-10             Days 11-20              Days 21-30
3266.56                 9405                    11893
6574.08                 8202                    8810
634.23                  5640                    2828
2299                    7560                    2509
4595                    6680                    1666
3849                    5960                    4700
2208                    3293                    7980
3119                    1616                    5332
702.85                  11215                   12181
4121                    13023                   3709


          Bandwidth usage breakdown
        30 day     .....  165570.72 MiB
        Todays     .....     272.62 MiB
        combined   .....  165843.34 MiB


The accuracy has been ok previously as I upgraded my account not long after having to write this to an unmetered business account. Sadly the ISP have now also upgraded the metering to catch me up. I can't vouch that it has been 100% accurate and it would be very hard to tell as other PC's at home here (plus a couple ps3's) generate some traffic that I don't count.

I think I can manage to do the suggestions you mentioned ok, I'll tackle that tomorrow most likely as its 12:30am now here and I have learnt the hard way not to fiddle when tired ;)

Thanks again for the help :]


Top
 Profile  
Reply with quote  
 Post subject: Re: Collect data between certain hours.
PostPosted: Thu 29.07.2010 00:42 

Joined: Sat 24.07.2010 20:50
Posts: 3
I've implemented another solution, I've switched ISP's to another without a quota.

Problem solved ;)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group