traffic measurement
I mentioned a while ago that I was still looking for a decent way to measure the amount of traffic that passes over my interface. The problem is mostly due to the fact that my ISP refuses for some reason to measure over a proper 24 hour period (hie 00:00:00 - 23:59:59), instead they have opted to measure the bandwidth, from 09:00:00 - 08:59:59. [1]
As you can imagine this gives somewhat a problem because 99% of all the programs will not adhere to that or will not allow you to change the measurement period. Now for a while I have been wanting to do something like that. It tends to give me chronic headaches when you are trying to do something and have to calculate bandwidth over three different sets of times.
Sounds like teh fun huh :) I used to use knemo for this, but all of a sudden, knemo started to flake out on me and to deliver outrageous results (something among the lines of 106GB over 24 hours and then a 49GB over 2 hours .. which somehow seems outside the norm of possibilities of bog standard 802.11.
So that was becoming rather useless. The second problem with knemo is, is that it only works from within KDE. So dropping X and working purely from CLI, makes it stop monitoring how much traffic passes the interface.
But thanks to the guys in ‘chucks, who took the output of vnstat and poured it into readable chunks, I finally managed to rewrite the above statement to something approaching normal bash_code :)
The result now, looks like this: [2]
[michiel@hades]:[~]$ vdstat
Report Generated on: Wed Sep 12 11:40:57 BST 2007
Received = 71 MB ((73440 kB)
Transmitted = 9 MB (9730 kB)
+----------------------------------+
Data usage = 81 MB (83170 kB)
Measured over a period of 3 hour(s)
So I am rather happy with that. It probably could do with some minor code cleanup in my case, as well as writing the daily results to a logfile somewhere.
But at least it is much easier for me now to keep a decent track on how much bandwidth I am actually using/spilling ;)
[1] – No I have no idea why. It seems you need a NATO clearance higher than my current one to know
[2] – Sourcecode available from here.