D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Download meter for demon internet.

 

On Fri, 2009-11-27 at 10:16 +0000, Rob Beard wrote:

> Could be useful for those folks who use Three mobile broadband as that 
> too is on a 30 day limit.
> 
> Rob

Ok,this can be treated as a beta release then, I have been running it a
couple of years now and just recently adjusted it to support the newer
vnstat that it depends on.

First up if you want to make use of it:
        sudo apt-get install vnstat

Then tell vnstat which network adapter to monitor, for me its :
        sudo vnstat -u -i eth0

Copy the two scripts into your path, for convenience I use ~/bin 

rdnm is the normal command you run to get output, rdnmcron is run at
11:59 each evening from crontab, so add the following line to your cron:

        59 23 * * * /home/subbass/bin/rdnmcron  > /dev/null 2>&1

You can use the command:
crontab -e
Then paste the above line in, that *should* be all the setup you need to
do.

It stores a couple little text fiels with the bandwidth use in ~/.rdnm
and can output a short list that look like this:
subbass@subbass-desktop:~$ rdnm

          Bandwidth usage breakdown
        30 day     .....  148876.76 MB
        Todays     .....    1894.40 MB
        Combined   .....  150771.16 MB

30 is the previous 30 days current use up until 11:59pm the previous
night
Today is todays current use
Combined is the total up until last night and today's.

You can also have a longer output so you can check when a particularly
hefty days leeching might be going to drop off your 30 day total, or
just for the heck of it. That takes this form:
subbass@subbass-desktop:~$ rdnm -l

Days 1-10             Days 11-20              Days 21-30
1402.88                 4463                    4661
1894.40                 5900                    4617
5642.24                 6823                    3764
2447.36                 5557                    571.72
1884.16                 6767                    2048
1849                    6156                    3979
6362                    7606                    11764
7313                    10918                   8161
6351                    7630                    2590
4765                    2260                    2730


          Bandwidth usage breakdown
        30 day     .....  148876.76 MB
        Todays     .....    1894.40 MB
        Combined   .....  150771.16 MB
So if I was on a limit and near to my quota I could see that a 5.6GB day
was going to drop off in 3days.

Its would be fairly simple to adjust the number of days tracked, but you
would have to play around with the long output formatting..

Hopefully it may be of use to others.


-- 
John Williams
My linux blog of notes and guides
http://subbass.blogspot.com/

Attachment: rdnm
Description: application/shellscript

Attachment: rdnmcron
Description: application/shellscript

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html