Posted: Mon May 04, 2009 13:08 Post subject: Per-user bandwidth monitoring script
Hi all,
I have developed a small script that runs on most linux-based routers, but primarily targeted for dd-wrt.
It allows to monitor bandwidth usage on a per-mac address basis.
At the moment it is not integrated and you have to know your way around the Linux OS to set it up (command line and cron jobs).
Please tell me what you think of it.
If a similar functionality could be integrated in the base dd-wrt firmware that would be awesome - no router firmware does that.
I need exactly the same here. I've just hired a fiber connection to share with some friends and we pay by bandwidth so we need to know how much each one uses.
Our solution until now is use a vnstat in each ones computer to measure, but have this integrated in the router would be great.
Unfortunately as our router (WRT54G2) only supports the DD-WRT micro we could not use your script mainly because we don't have a way to send the data do the server.
Is there any way to push data to a FTP server using the micro version?
Posted: Wed Jun 10, 2009 1:08 Post subject: Good stuff
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
@seocam, the wget and ftpput commands are available in the micro-plus version of dd-wrt, see if you can flash it to your WRT54G2. They should be enough for all remote backup & restore purposes.
Joined: 04 Jan 2007 Posts: 11564 Location: Wherever the wind blows- North America
Posted: Sat Jun 13, 2009 13:03 Post subject:
xorglub wrote:
@seocam, the wget and ftpput commands are available in the micro-plus version of dd-wrt, see if you can flash it to your WRT54G2. They should be enough for all remote backup & restore purposes.
Agreed....the WRT54G2 unit will take micro_plus and micro_plus_ssh directly. It will give you the same set of busybox commands as other builds of dd-wrt and if you use the ssh build, you of course, get ssh too.
redhawk _________________ The only stupid question....is the unasked one.
mmm...for bandwith Usege I use Protemac meter..on mac...
That seems to be a bandwidth monitor for only 1 computer at a time. It's also Mac only, meaning (for me) I'd need a similar solution on Windows and Linux too. They're talking about having the router monitor usage per mac-address, meaning it'll work with Windows, Mac, Linux, live distros, friend's computers, Xboxes/PS3/Wii's, etc. Also, it doesn't have to be installed on each and every computer on the network.
I'll be trying this script out later! Will let you know how it works for me.
*edit*
Seems to work pretty well. I played with the suggested cron jobs to have it update more often. Looks like it works well in 5-minute intervals, with the DB backed up to /mmc every 15 minutes. I added in a shutdown script to back up the DB as well.
I haven't looked at the original script too much, but is it possible to modify it to output ip address instead of mac address, or perhaps only a select few ip/mac addresses?
*EDIT*
Dug through the script a bit, and found that it pulls hostnames from /etc/dnsmasq.conf, /tmp/dnsmasq.conf, or a manually specified external file. It wasn't pulling the names on my setup, since dnsmasq.conf doesn't exist in my /etc or /tmp. This is most likely because I configure dnsmasq from an external script, not from the GUI. Manually specifying an external file didn't work, so I just made sure that there would be a copy of dnsmasq.conf in /tmp.
Script works pretty well though. I did have an issue with the instructions, though. The line in cron:
Otherwise, I think this would be great if it was integrated into the main GUI. Thank god I have this set up; now I can finally show the brother-in-law just how much bandwidth he uses, and can charge him any of the overage fees!
*EDIT ONE MORE TIME!*
I've added a couple lines to cron to backup the htm output and reset the stats at the end of the month:
This copies the htm page to /mmc at the end of the month (had to make it run on the 28th to 31st, but it'll overwrite the file each time so it won't duplicate it. It automatically names the backup file to "usage-Feb2010.htm" or whatever the month is. Finally, it removes the old DB, and the next time the script is run, it'll create a new one with the new month's stats.
*EDIT LAST TIME I SWEAR*
I modified the script a bit to add in a "Total Usage" statistic. Basically it just adds all 4 other stats together and creates it's own column in the HTML output.
Fair warning: This has been tested for only 15 minutes or so, and hasn't been tested in the "Off-Peak" timeslot. Let me know if you think it causes any problems.
Joined: 29 May 2008 Posts: 243 Location: United Kingdom
Posted: Fri Mar 05, 2010 15:54 Post subject:
Show do i run .sh scrips om dd wrt? and dos this work in WRT54G2 v1 _________________ TP-Link TL-WDR3600 v1 [EU]: r36330 (07/16/18 )
D-Link DIR-615 D2 [EU]: r36330 (07/16/18 )
Mikrotik RB750r2 (OpenWrt 17.01.4)
EE BrightBox 1 aka A4001N (OpenWrt 17.01.4)
Sagemcom FAST@5364 (VDSL2,FTTC (Fibre to the Cabinet) Synced 65/17
works fine. but how can i access the generated webpage on dd-wrt? i own only mini build without cifs, so i cannot storage the htm file on my debian webserver.
so, is it possible to access it thorugh http://router/usage.htm ? where i have to save this file.. _________________ RT-N66U @ Build 25697M K3.10.63
TL-WR842ND v1 @ BS-build 23919 WDS AP
TL-WR841ND @ BS-build 23919 WDS Client
TL-WR841ND @ BS-build 23919 Client Bridge ( Routed )
Show do i run .sh scrips om dd wrt? and dos this work in WRT54G2 v1
It should work on anything that can run DD-WRT, so long as you have either jffs, an SD card, an FTP server, or a cifs share accessible to the router (or some other method of storage that I've missed). Follow the instructions here:
http://code.google.com/p/wrtbwmon/wiki/Deploying
BasCom wrote:
works fine. but how can i access the generated webpage on dd-wrt? i own only mini build without cifs, so i cannot storage the htm file on my debian webserver.
so, is it possible to access it thorugh http://router/usage.htm ? where i have to save this file..
The page is saved in /tmp/www, so it's in Ram I believe. The file is accessible from http://router/user/usage.htm but it's lost if the router reboots or is powered off. If you have jffs, USB, or an SD mod, use those, otherwise maybe ftpput will work?
i have not enought space for jffs filesystem, no cifs in mini image, no sd mod, no usb _________________ RT-N66U @ Build 25697M K3.10.63
TL-WR842ND v1 @ BS-build 23919 WDS AP
TL-WR841ND @ BS-build 23919 WDS Client
TL-WR841ND @ BS-build 23919 Client Bridge ( Routed )
i have not enought space for jffs filesystem, no cifs in mini image, no sd mod, no usb
Then you'll have to switch to a firmware with cifs in it. I use the nokaid_generic from here on my WRT150N, and it has jffs, cifs, and mmc in it, and is one of the recommended builds at the moment. Not enough space for JFFS on a 4mb router though.
Without that, you'll have to run an FTP server and use ftpput then. Don't ask me how to use it; I don't know! Maybe if you're running a Linux/Mac machine with an SSH server, then scp might work too...
Best would be an SD mod though. If you're good with soldering, then that's the route I took. It was pretty easy to probe for 3 GPIO's (4th for CS wasn't needed). _________________ Buffalo WZR-HP-G300NH on 23919
im running tomato 1.27 so maybe this isnt the right place to be posting this but i get these errors when i run "/cifs1/wrtbwmon update /cifs1/usage.db peak"
Code:
# /cifs1/wrtbwmon update /cifs1/usage.db peak
cat: can't open '/tmp/in_9750.tmp': No such file or directory
cat: can't open '/tmp/out_9750.tmp': No such file or directory
[: 0: unknown operand
cat: can't open '/tmp/in_9750.tmp': No such file or directory
cat: can't open '/tmp/out_9750.tmp': No such file or directory
[: 0: unknown operand
DEBUG : New traffic for "mac address" since last update : 124k:2799k
DEBUG : New traffic for "mac address" since last update : 22k:2k
#
also im not sure if the above is the issue but it seems to loose data as my usage.htm that gets generated contains some data but alot of it is unaccounted for.
im not sure how to fix the above so any help would be great.
Posted: Tue Jan 04, 2011 21:54 Post subject: Less technical install instructions
Hi,
Is it possible to install this without knowing code? I tried looking at the above link (for deployment instructions) and i can not understand them.
i have a WRT54GL installed with DD-WRT mini.
I am constantly going over my home bandwidth limits (8 users) but i do not know if its normal use or if some one is unwittingly (using bittorrent without throttling upload etc) going over.
I dont want to meddle with peoples PCs for privacy reason so i would like an option to check each users bandwidth use per month at router level.
Posted: Tue Jan 04, 2011 22:51 Post subject: Re: Less technical install instructions
Akaz1976 wrote:
Hi,
Is it possible to install this without knowing code? I tried looking at the above link (for deployment instructions) and i can not understand them.
i have a WRT54GL installed with DD-WRT mini.
Follow my previous post:
fluffyllama wrote:
It should work on anything that can run DD-WRT, so long as you have either jffs, an SD card, an FTP server, or a cifs share accessible to the router (or some other method of storage that I've missed). Follow the instructions here:
http://code.google.com/p/wrtbwmon/wiki/Deploying
Alternatively, with 8 people sharing the router, is it not possible to bump to a higher level package from your ISP? Where I live, it's $10/month difference to go from 60gb to 100gb per month, and that increases DL speed to 15mbit from 7.5mbit. Also, with 8 people, a more powerful router may be helpful. Something like the Asus RT-N16, perhaps? That'd give you tons of room for bandwidth logs and the like. _________________ Buffalo WZR-HP-G300NH on 23919