Per-user Live Down/Upload Rate Monitoring [No PC needed!]

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 10, 11, 12  Next
Author Message
warhed
DD-WRT User


Joined: 24 Oct 2007
Posts: 71

PostPosted: Sat Jan 08, 2011 19:15    Post subject: Per User Bandwidth problems and questions Reply with quote
I am getting some problems (maybe?) with this script. I know nothing about Linux so this has been quite tough for me.

Question #1:
I assume the Usage.db is a file that will automatically be created? Or do I need to create usage.db and copy it to my jffs folder using WNSCP? This part isn't stated in the 1st page.

Questions #2:
How to see a running script?
How to kill a script? In particular this one in case there is a problem.

Question #3:
The usage page seems to be working, but my telnet session keeps saying:
/jffs/wrtbwmon: line 222: syntax error: (0-)/9
/jffs/wrtbwmon: line 222: syntax error: (3-)/9
DEBUG : iptables chain misplaced, recreating it...


Questions #4:
While I can use ARP to get a MAC from an IP, how do I get an IP from a MAC address?

Questions #5:
I am currently using a mounted 2gig USB stick formatted to EXT3 and can see it fine. Using this script, how much data would I be able to save, say with 20 users? I would like to be able to refer back 90 days and see if a user(s) have been bandwidth abusive.

Question #6:
Is there a way to open a usage.db file and see the data or is it being used by the router? I am not sure how I would save the file, while in use, and be able to refer back to data for say 90 days?

Questions #7:
Regarding the password protecting page, I can no longer download the usage.sh script from: http://www.dd-wrt.com/phpBB2/download.php?id=15634.

Source: http://www.dd-wrt.com/phpBB2/viewtopic.php?p=468131#468131



Thanks for any help on this. I hope I am not pissing anyone off but I just cannot find the answers to the above.


Last edited by warhed on Mon Jan 10, 2011 1:47; edited 1 time in total
Sponsor
warhed
DD-WRT User


Joined: 24 Oct 2007
Posts: 71

PostPosted: Sun Jan 09, 2011 20:54    Post subject: Router bricked Reply with quote
After testing the script manually via Telnet and also via the Web GUI Command line, rebooting the router erases the script, as expected.

After reboot I placed the same script in the comman console via the Web Gui. I ran it, and the user bandwidth worked fine. I saved it to the Startup option, rebooted the router, the router was bricked and kept rebooting every 15 seconds.

I had to use the TFTP method to restore my router back to pre User Bandwidth scripting.

I have a Linksys/Cisco WRT600N v1.1 unit.
I am using a Kingston 2 gig USB stick.

My script is as follows:
sleep 10

# Load database
cp /jffs/usage.db /tmp/usage.db

# Bandwidth Download/Upload Rate Counter
while :
do
/jffs/wrtbwmon setup
/jffs/wrtbwmon read
sleep 9
/jffs/wrtbwmon update /tmp/usage.db
/jffs/wrtbwmon publish /tmp/usage.db /tmp/www/usage.html /jffs/MAC-PCname.txt
done &

# Backup usage database file
while :
do
sleep 900
cp /tmp/usage.db /jffs/usage.db
done
# If you want to run other codes below this line, use "done &" instead of just "done" on the line above


Can anyone tell me why this would lock up? My firmware for the 600N is the latest beta (recommended) off the site. I really would like to use this script as it has been handy.

Thanks1

Update 1/9/2011 @ 5:47pm
I was wrong that this script does NOT seem to run from the web gui but does run from TELNET, so I must be doing something wrong here.
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Sun Feb 06, 2011 13:42    Post subject: Reply with quote
Lads,
I am really grateful that someone is taking the time to write up this stuff. This kind of setup is exactly what i need.

Im sharing my internet with my neighbour and though he said he isnt using much, the total bandwidth is insane.

since i myself have a few computers online at a time, i dont think just having the total bandwidth monitoring is useful.

As i have a wrt54g2 v1 and having v24 pre sp2 micro installed, im wondering if anybody could really help me set this script up.

im really poor at linux commands and i am unsure how to set about doing things right.

could anybody help me set up this script on ddwrt micro?ive been trying to dabble and get things running, but i dont even know how to get the .sh onto the router in the memory, let alone get it to run and output data.

i dont have an sd mod in this either, but i have a computer that can be connected to this router 24/7 if need be as its my main media machine that stays on. (im on windows btw for everything).

Thanks for helping me by writing a bit of an idiot's guide to get this working?
tangled111
DD-WRT Novice


Joined: 31 Jan 2011
Posts: 7

PostPosted: Sun Feb 06, 2011 14:40    Post subject: Reply with quote
munzab wrote:
Lads,
I am really grateful that someone is taking the time to write up this stuff. This kind of setup is exactly what i need.

Im sharing my internet with my neighbour and though he said he isnt using much, the total bandwidth is insane.

since i myself have a few computers online at a time, i dont think just having the total bandwidth monitoring is useful.

As i have a wrt54g2 v1 and having v24 pre sp2 micro installed, im wondering if anybody could really help me set this script up.

im really poor at linux commands and i am unsure how to set about doing things right.

could anybody help me set up this script on ddwrt micro?ive been trying to dabble and get things running, but i dont even know how to get the .sh onto the router in the memory, let alone get it to run and output data.

i dont have an sd mod in this either, but i have a computer that can be connected to this router 24/7 if need be as its my main media machine that stays on. (im on windows btw for everything).

Thanks for helping me by writing a bit of an idiot's guide to get this working?


1) I don't think you will be able to run this on mini. Mini has a reduced operating system. You can't even run "ls" on mini.

2) You should search through the wiki. It has all the info you need. It can be hard navigating to find the right articles you need for each step but they are all there.

good luck
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Sun Feb 06, 2011 16:25    Post subject: Reply with quote
thanks for that, i think the micro-plus version will work, therefore will have ls command as well as ssh.

http://www.dd-wrt.com/wiki/index.php/Micro-plus


lets just say i buy a wndr3700 and try and do that?would i be able to upload files via winscp?
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Fri Feb 11, 2011 21:21    Post subject: Reply with quote
so i got myself a wndr3700 and want to set this up. ive flashed the v24 sp1 15 something build and i have an issue with trying to get this script into command:

1. i dont have an sd card, where else can i upload the wrtbwmon file?

2. apart from /tmp , all the folders are read only?how do i get the file there?

i tried changing the paths to reflect to /tmp instead of /mmc, but it did not work. where else can i put the script?


thanks for helping me on this, remember, im not the most comfortable bloke with scripting etc, its all new at the moment
RobotBanana
DD-WRT Novice


Joined: 15 Jul 2010
Posts: 22

PostPosted: Sat Feb 12, 2011 1:40    Post subject: Reply with quote
munzab wrote:
so i got myself a wndr3700 and want to set this up. ive flashed the v24 sp1 15 something build and i have an issue with trying to get this script into command:

1. i dont have an sd card, where else can i upload the wrtbwmon file?

2. apart from /tmp , all the folders are read only?how do i get the file there?

i tried changing the paths to reflect to /tmp instead of /mmc, but it did not work. where else can i put the script?


thanks for helping me on this, remember, im not the most comfortable bloke with scripting etc, its all new at the moment


You have two options. If you have a cheap USB drive laying around, you can plug that in and go to Services -> USB to enable USB storage. Then you can put the script on there. That's probably the best option.

You could also create a JFFS2 partition on your router's internal memory (Administration -> Management), but it's safer to go with the USB key method.
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Sat Feb 12, 2011 14:59    Post subject: Reply with quote
RobotBanana wrote:
amitd wrote:
Thanks for wrtbwmon file.

whenever i run the file now, the new wrtbwmon(modified) is not generating the usage.html file. i went back to the original file and it worked fine, any suggestion what i am doing wrong, i am using following commands on my router Lynksys WRT54 GL(Firmware: DD-WRT v24-sp2 (10/10/09) mini).


At the command prompt, please type:
Code:
sort -n fghd

And let us know what the output is. You probably don't have the sort command available, in which case I'll have to defer to someone who's successfully gotten around that issue.



ive moved on and got a usb plugged in, so everything is going thru /opt as opposed to jffs.

however, ive gone thru the different bits, and if im not mistaken, im suffering from the no sort command, as cat and touch work, but not sort.

did anybody manage to get around this problem?thats the last hurdle im left with. thanks


edit:

progress. have it running finally. needed to change sort -n in the wrtbwmon file to cat and its now gathering data.

however, its only listing mac addresses in users and not the client's name.

here's my code:

sleep 10

# Load database
cp /mnt/usage.db /tmp/usage.db

# Bandwidth Download/Upload Rate Counter
while :
do
/mnt/wrtbwmon setup
/mnt/wrtbwmon read
sleep 9
/mnt/wrtbwmon update /tmp/usage.db
/mnt/wrtbwmon publish /tmp/usage.db /tmp/www/usage.html /mnt/MAC-PCname.txt
done &

# Backup usage database file
while :
do
sleep 900
cp /tmp/usage.db /mnt/usage.db
done


i cannot find a mac-pcname anywhere to confirm that.

ive enabled everything witn DNSmasq (apart from local DNS which was already off and though i turned that on, did not make a difference).


if i can get this sorted, will be golden.

thanks
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Sun Feb 13, 2011 19:47    Post subject: Reply with quote
i broke it again i think.

anyway, if i telnet into the router and do

cd /tmp
cat /tmp/usage.db

i get the line where it says which mac address is using the router.

however this is not going into the usage.html file at all.

im a bit at a loss. im looking at the wrtbwmon file and cant figure out what is wrong in it to be frank.


theres one line at the bottom:

echo " $0 publish /tmp/usage.db /www/user/usage.html /jffs/users.txt

should i change this to /tmp/www/usage.html and /mnt/users.txt ? i think i tried but nothing happened
RobotBanana
DD-WRT Novice


Joined: 15 Jul 2010
Posts: 22

PostPosted: Sun Feb 13, 2011 21:11    Post subject: Reply with quote
If you have Optware installed, you should be able to install the sort command by running:
Code:
ipkg update
ipkg install coreutils

Then try going back to the original wrtbwmon (with sort still in it) and see if that fixes your problems.

Regarding the MAC addresses, you have to actually create the /mnt/MAC-PCname.txt file and manually put the MACs and corresponding usernames into it. Each entry should look like:
Quote:
00:15:3A:B1:15:CB,John Smith PC

(i.e. MAC_ADDRESS,NAME)
With one entry per line.
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Sat Apr 30, 2011 23:27    Post subject: Reply with quote
anybody any ideas how to reset this, say every 1st of the month?
RobotBanana
DD-WRT Novice


Joined: 15 Jul 2010
Posts: 22

PostPosted: Sun May 01, 2011 0:41    Post subject: Reply with quote
munzab wrote:
anybody any ideas how to reset this, say every 1st of the month?


You could set up a cron job (Administration tab) to just delete /tmp/usage.db.

I have mine set up to save my usage.db and usage.html file at midnight on the 19th (the transition between the 18th and 19th of every month) so I can look at the numbers in the future, and then start the counts over. For reference, my crop job is:
Code:
0 0 19 * * root /opt/wrtbwmon/scripts/monthlyrefresh.sh


And the monthrefresh.sh script I wrote is:
Code:
#!/bin/sh

# This script must be run by crontab monthly (i.e. when your ISP
# restarts the count on your bandwidth).

# Save last month's data so you can look back at it.
# Note: mv, not cp, since we want to start the active count over
# (which we do by wiping out the active usage.db file).

mv /tmp/usage.html /opt/wrtbwmon/historical/$(date +%Y-%d-%m).html
mv /tmp/usage.db /opt/wrtbwmon/historical/$(date +%Y-%d-%m).db

# Remember to delete the backup in case your router reboots.
# We wouldn't want the old info to be added to instead of this
# month's info.

rm /opt/wrtbwmon/backup/usage.db
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Mon May 02, 2011 22:55    Post subject: Reply with quote
thanks. ive managed to manually reset by running the script from a telnet session.

ill see on the 1st if its worked, ive added it as a CRON job
r0gu3ptm
DD-WRT Novice


Joined: 30 May 2011
Posts: 7

PostPosted: Thu Jun 02, 2011 12:16    Post subject: Reply with quote
For me unfortunatelly this script doesnt work, I mean, in the usage.htm there is no data, and in the /tmp folder I have the traffic_55.tmp and trafic_66.tmp, the wrtbmon script and users.txt, also usage.db, and when I do cat usage.db there is no data in. Is anybody having a ideea of whats going wrong ? Thx.
optddwrt
DD-WRT Novice


Joined: 25 Jul 2011
Posts: 1

PostPosted: Tue Jul 26, 2011 19:33    Post subject: Reply with quote
I want to implement this script, but have no knowledge about programming or unix.

How do I do this?

I have E2000 with DD-WRT configured and working. E2000 is connected to my Windows 7 Laptop and I have download the files in C:\DDWRT directory.

Can someone please tell me step by step how can I run the script.

Thanks in advance.
Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 10, 11, 12  Next Display posts from previous:    Page 7 of 12
Post new topic   Reply to topic    DD-WRT 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