Per-user bandwidth monitoring script

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Contributions Upload
Goto page Previous  1, 2
Author Message
Akaz1976
DD-WRT Novice


Joined: 04 Jan 2011
Posts: 3

PostPosted: Wed Jan 05, 2011 14:29    Post subject: Reply with quote
I have no option to upgrade as i am already near max Sad.

Yesterday my house hold used 6GIG down/1 GIG up. What could lead to non-tech users to upload 1GIG? I can understand that watch streaming video can lead to high bandwidth usage on download side. But why the big upload usage?

I will try the other solution. I dont mind having the PC on. Infact i may only need to run it for a day or so to pin down bandwidth use by PC.
Sponsor
fluffyllama
DD-WRT Novice


Joined: 19 Jan 2009
Posts: 12
Location: Canada

PostPosted: Wed Jan 05, 2011 18:52    Post subject: Reply with quote
Akaz1976 wrote:
I have no option to upgrade as i am already near max Sad.

Yesterday my house hold used 6GIG down/1 GIG up. What could lead to non-tech users to upload 1GIG? I can understand that watch streaming video can lead to high bandwidth usage on download side. But why the big upload usage?

I will try the other solution. I dont mind having the PC on. Infact i may only need to run it for a day or so to pin down bandwidth use by PC.


Their traffic usage would have to be torrenting or something, or perhaps uploading many videos to Youtube. For example, my wife just browses and doesn't download much, so her usage last month was 21gb down 600mb up, but her brother (who lives with us for now - long story), used 44gb down and 32gb up! They both watch the same amount of streaming video, but only her brother torrents regularly. Hell, 6gb/1gb is nothing for my house; the three of us did 18gb/6gb on Boxing Day!

Also, I forgot to mention, but I don't believe the MySQL part is necessary in the link I gave you. I recall not doing it before, when I used that solution. I don't think the program stores any data without MySQL, but I could be wrong. For your purposes though, it should be enough.

_________________
Buffalo WZR-HP-G300NH on 23919
Akaz1976
DD-WRT Novice


Joined: 04 Jan 2011
Posts: 3

PostPosted: Wed Jan 05, 2011 19:23    Post subject: Reply with quote
fluffyllama wrote:

Also, I forgot to mention, but I don't believe the MySQL part is necessary in the link I gave you. I recall not doing it before, when I used that solution. I don't think the program stores any data without MySQL, but I could be wrong. For your purposes though, it should be enough.


Phew! since that MySQL stuff was making me sweat just reading it. So once i install this how would i store and view usage?

btw i am in oakville, ON (notice u were a canuck too) on Cogeco Ultimate 30 with 125GB limit ($75). Overage is capped at $50 so essentially i am paying $125 for unlimited. Still to high me thinks but such is life.
fluffyllama
DD-WRT Novice


Joined: 19 Jan 2009
Posts: 12
Location: Canada

PostPosted: Wed Jan 05, 2011 19:38    Post subject: Reply with quote
Akaz1976 wrote:
Phew! since that MySQL stuff was making me sweat just reading it. So once i install this how would i store and view usage?

I don't remember; it's been over a year since I used RFlow. See what you can get today, and if you can't get results, I'll boot into Windows tonight and check it out.

Akaz1976 wrote:
btw i am in oakville, ON (notice u were a canuck too) on Cogeco Ultimate 30 with 125GB limit ($75). Overage is capped at $50 so essentially i am paying $125 for unlimited. Still to high me thinks but such is life.

$125 for unlimited is pretty good. Where I used to work, it was ~$1500 for unlimited, but that was a 10mbit up/down tier 1 fiber drop with a service level guarantee. That was necessary because we hosted our own web servers plus FTP for customers to send in their huge files for us.

Right now I have Shaw Extreme, which is 15mb down/1mb up (can go up to 30mb down), and 100gb/month for $60-ish; however, I've never been charged any overage in 7 years of being their customer, and we consistently go way over the mark (194gb last month, 149gb November, 192gb October, etc...), so I only pray that they don't catch on, or I'll be having a word with my brother-in-law.

*edit*

Just booted into Windows (needed Windows to flash new firmware into my AVR-based oscilloscope Very Happy ). Basically, you need to follow part 1 of http://www.dd-wrt.com/wiki/index.php/Using_RFlow_Collector_and_MySQL_To_Gather_Traffic_Information and only the first paragraph of part 2. After that click the Network button in the bottom left of the RFlow Collector, and make sure that the local subnet and "filter wich IPs schould not count?" shows your router address under "simply IP". Hit save. In the main window, uncheck where it says "only Online User" and "only Online WLan Clients", otherwise it will only show PC's that are powered on.

Good luck tracking down the culprit!

_________________
Buffalo WZR-HP-G300NH on 23919
Amiga
DD-WRT Novice


Joined: 08 Nov 2006
Posts: 16

PostPosted: Wed Jan 26, 2011 4:01    Post subject: Reply with quote
Any chance a nice soul could do a YouTube video on getting this script up (installed) and running? A lot of Canadian souls will need something to reference now that UBB (Usage Based Billing) with 25GB caps is pretty much set in stone.

Most DSL folks use Tomato/MLPPP, but DD-WRT with this script and its built-in MLPPP might be the answer to low cap woes.
Kr0nZ
DD-WRT Novice


Joined: 17 Jul 2011
Posts: 1

PostPosted: Sun Jul 17, 2011 18:39    Post subject: Reply with quote
( I posted this originally on the wrtbwmon site, but thought it might be better to post it here too)

I have this working perfectly with my DD-WRT v24-sp2, I been looking for a script like this for ages, now hopefully I want be the one getting in trouble all the time for going over bandwidth

If you dont have 'ftpput' as I didnt have it on mine, I just used wget and cron jobs, I have a media center PC that is always running MythTv 24/7 so this was an acceptable solution for me, Although I would like to figure out how-to upload to my database through HTTP POST if at all possible, or maybe through telnet.

Ok so if anyone is reading this trying to get your usage.db backed up without ftpput this is what I did. Your going to need a Linux PC that is always running. First you need to edit the 'wrtbwmon' file that you downloaded from here, to include a line to backup the database file on to the routers webserver so you can download it.

So log onto the PC you will be storing your usage database file on, and get the file above
Code:

wget http://wrtbwmon.googlecode.com/files/wrtbwmon

open up the file then scroll down to line 129 to where it says "#Free some memory". Just infront of this line start a new line then enter
Code:

cp ${2} /tmp/www/usage2.htm

After every update this will move your database to a easily accessible location to everyone on the network. Make sure you copy it with the extention ".htm" The DD-WRT router didnt allow me to download any other file type from it, save the file to you home directory for now.

Next we have to set up a way to transfer the files. For this I used my MythTv PC thats running Ubuntu, on this PC I already have a webserver setup for MythWeb so I'll use that, but you can just as easy install your own.

What your going to need is the webserver root folder this is usually '/var/www/'. In this folder I created a folder named 'wrtbwmon' this is where you can store your modified 'wrtbwmon' script and your database file.
Create a testfile in this folder
Code:

echo 'this is a test' > test.txt

Now you should be able to access this file by typing in something like
"http://192.168.1.123/wrtbwmon/test.txt" from any computer on your network.
(192.168.1.123 the IP of the 24/7 PC makes sure your change this to your backup PC's IP)

After you have confirmed your webserver is running you should now copy over you modified wrtbwmon script from above
Code:
cp /location/of/modified/script/wrtbwmon /var/www/wrtbwmon/wrtbwmon


Now you need to setup a cron job to retrieve the database from the router and save it to the PCs webserver, so in a terminal type:
Code:

 crontab -e

then enter the following job
Code:

 */8 * * * * cd /var/www/wrtbwmon && wget http://192.168.1.1/user/usage2.htm && mv usage2.htm usage.db

(be sure to change 192.168.1.1 to your own routers IP, and /var/www/ to your PC's webserver root folder)
I've set this up to run every 8 minutes(*/Cool but you can change this to what ever you want, you can test the command by just typing everything after the
Quote:
*/8 * * * *
in a terminal.

After the above command executes you should end up with a file 'usage.db' accessible by http://192.168.1.123/wrtbwmon/usage.db

Now all thats left to do is tell the router where to retrieve the files, so open up the dd-wrt web GUI and goto the Administration tab. Half way down you will see a 'Cron' section this is where you will execute your commands, Cron will need to be enabled to see the command box.
Now just paste in the following commands, be sure to change the IP to the IP your will use.
Code:

* * * * * root [ ! -f /tmp/usage.db ] && wget http://192.168.1.123/wrtbwmon/usage.db -O /tmp/usage.db
* * * * * root [ ! -f /tmp/wrtbwmon ] && wget http://192.168.1.123/wrtbwmon/wrtbwmon -O /tmp/wrtbwmon && chmod +x /tmp/wrtbwmon
* * * * * root /tmp/wrtbwmon setup br0
* * * * * root /tmp/wrtbwmon update /tmp/usage.db
*/5 0-3 * * * root /tmp/wrtbwmon update /tmp/usage.db peak
*/5,59 4-8 * * * root /tmp/wrtbwmon update /tmp/usage.db offpeak
*/5 9-23 * * * root /tmp/wrtbwmon update /tmp/usage.db peak
*/30 * * * * root /tmp/wrtbwmon publish /tmp/usage.db /tmp/www/usage.htm

Then Save and Apply Setting, if you have already been running wrtbwmon for awhile and would like to backup your current usage.db
Just ssh into the router or use the web GUI "Administration >> Commands" and run the following command:
Code:

cd /tmp && cp /tmp/usage.db /tmp/www/usage.db

Then on your backup Pc just run the Cron job:
Code:

cd /var/www/wrtbwmon && wget http://192.168.1.1/user/usage2.htm && mv usage2.htm usage.db

you can verify by cating the file:
Code:

cat /var/www/wrtbwmon/usage.db


Hope this helped someone, I might even post this on the actuall DD-Wrt forum[/code]
ltek
DD-WRT Novice


Joined: 26 May 2011
Posts: 16

PostPosted: Tue Jul 19, 2011 8:22    Post subject: Reply with quote
I need to log network utilization over a period of a few months to track DL & UL bandwidth needed so I can gauge the size of the pipe needed for a given location.

Will this script log snapshots of the bandwidth DL * UL on say 1 min intervals?

I need to be able to export the data and run reports using Excel to find the High/Low/Ave.

thx
ketan
DD-WRT Novice


Joined: 11 Aug 2011
Posts: 1

PostPosted: Thu Aug 11, 2011 0:37    Post subject: Re: Good stuff Reply with quote
Would you tell , how did you setup the scrip in router?
greyback wrote:
Hi xorglub,
this is what I've been searching for, for quite a while now. I share my bandwidth with 3 housemates, and someone is being naughty. I've struggled to set up a per-MAC log system using RFlow and Ntop on a server, but the data doesn't match that of the ISP or the simple dd-wrt bandwidth graph, and analysing every packet is overkill really.

I've just set up your script now, with luck this is all I need. It would be great to incorporate this into the dd-wrt webUI.

I would also be curious to see if a 30 minutely backup of the usage file to the jffs would be a terrible thing or not. And a quick restore file is there on bootup script later, we've basic reboot-proofedness

Thanks v much
-G
roady
DD-WRT Novice


Joined: 25 Feb 2014
Posts: 17

PostPosted: Wed Mar 12, 2014 15:53    Post subject: Reply with quote
Hey guys,

Can we get this script as a default part of latest firmware of dd-wrt?

Bandwidth monitoring per mac ID is one sexy feature i'm looking forward to.

Just because I'm no pro at linux, i'm not able to implement it.

It'd be great if something can be done about this...
Sopalajo de Arrierez
DD-WRT Novice


Joined: 04 Dec 2015
Posts: 5

PostPosted: Sun Dec 13, 2015 13:47    Post subject: Possible output to stdout? Reply with quote
Great script, XorGlub.
How could I do to get the results of wrtbwmon on screen/stdout?
I have multiple DD-WRT devices on my network, and would like to script a general bandwith usage, so I am thinking about issuing some SSH command and parsing the results myself.
jsteng
DD-WRT Novice


Joined: 10 Jun 2009
Posts: 44

PostPosted: Wed Nov 30, 2016 20:21    Post subject: Reply with quote
Is this still valid?

Can this feature be included with DD-WRT?
really great in catching erring machines doing nasty stuffs.
al_c
DD-WRT Guru


Joined: 13 Apr 2013
Posts: 1974
Location: Ottawa Canada

PostPosted: Mon Jan 02, 2017 14:26    Post subject: Reply with quote
jsteng wrote:
Is this still valid?

Can this feature be included with DD-WRT?
really great in catching erring machines doing nasty stuffs.

That is a long dead thread... see the thread related to my YAMon script or the YAMon web site for an active & current project

Al
Goto page Previous  1, 2 Display posts from previous:    Page 2 of 2
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Contributions Upload All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum