Posted: Sat Jan 08, 2011 19:15 Post subject: Per User Bandwidth problems and questions
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?
Posted: Sun Jan 09, 2011 20:54 Post subject: Router bricked
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.
# 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.
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?
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.
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
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.
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.
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:
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:
# 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).
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.