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

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Contributions Upload
Goto page Previous  1, 2, 3 ... 9, 10, 11, 12  Next
Author Message
John877
DD-WRT Novice


Joined: 22 Apr 2013
Posts: 21

PostPosted: Wed Aug 28, 2013 12:54    Post subject: Reply with quote
I have a question of my own. (Wanted to make it a separate post as it didnt have to do with the reply to the guy above. hope its cool)

I would like to add another line to the bottom of the table that shows total downloaded/uploaded in the course of the month. not just individual totals but overall totals.

If thats possible please let me know what to add or what.

thanks
Sponsor
ijamjl
DD-WRT Novice


Joined: 15 Aug 2013
Posts: 8

PostPosted: Fri Aug 30, 2013 4:49    Post subject: Reply with quote
John877 wrote:
ijamjl wrote:
Sorry for bump but would appreciate help. Edited above post, now that I have a better idea of how to use this thing.


I am by no means an expert myself as I am still fairly new to this but I have gotten this working.

1. Try naming it users.txt. thats what ive done and it works. dont know if theres something with maybe using the - in the filename or not. also make sure the users.txt file is in same folder as wrtbwmon.
2. as for changing sleep 9 to sleep 3 that wont make the page refresh in 3 seconds as opposed to 9, that is a delay between those commands in the script. from my understanding you dont want that to be too quick either or it wont work cause the reading might not have been fully done yet for it to write to the db file.

as for your last comment about the excessive writing, that is true as it will wear out the flash memory that is built into the router. i have mine set to back up every 2 hours, some might say that that is a bit too frequent but meh its better than the original like 15 seconds of Kodis script Very Happy
In order to have the page refresh faster, look in wrtbwmon file and scroll down to where it says Create HTML Page and look close to the end of it where it has the refresh code. theres somewhere it says var seconds=11 id imagine change that to 3-4 and it should refresh faster. I havent tried it so if it doesnt work then just change it back.

Also for reference this is the startup script I am using.
Code:

#!/bin/sh
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 10
/jffs/wrtbwmon update /tmp/usage.db
/jffs/wrtbwmon publish /tmp/usage.db /tmp/www/usage.html /jffs/users.txt
done &

# Backup usage database file every 2 hours
while :
do
sleep 7200
cp /tmp/usage.db /jffs/usage.db
done


Also check this post........
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=494846#494846


Thank you for the reply.

I changed the name to users.txt, but still no names displayed; only MAC addresses. And yes, the file is in the same folder as wrtbwmon.

Do you think it has anything to do with the fact that (so it seems) everyone else is using the path /jffs? Or my path (/tmp/mnt/sda1) is fine the way it is?
John877
DD-WRT Novice


Joined: 22 Apr 2013
Posts: 21

PostPosted: Sat Aug 31, 2013 5:36    Post subject: Reply with quote
as long as the path leads to the proper location of the files, it doesnt matter where they are.
so you have the DNSMasq options all on?
the users file is it in <MAC Address>,<Name> format? apparently some routers dont like the mac address to be in capital letters either. that could be the issue. also i believe no spaces between mac address and the comma and the name. the name can have spaces though and one entry per line.
ijamjl
DD-WRT Novice


Joined: 15 Aug 2013
Posts: 8

PostPosted: Sun Sep 01, 2013 15:54    Post subject: Reply with quote
John877 wrote:
as long as the path leads to the proper location of the files, it doesnt matter where they are.
so you have the DNSMasq options all on?
the users file is it in <MAC Address>,<Name> format? apparently some routers dont like the mac address to be in capital letters either. that could be the issue. also i believe no spaces between mac address and the comma and the name. the name can have spaces though and one entry per line.


I have DNSMasq, Local DNS, and No DNS Rebind all enabled; and the Additional DNSMasq Options, I entered:

domain=lan
local=/lan/
expand-hosts

I saw a post that said to add that in. I hope read it correctly, lol.

When trying to put all the MAC addresses in lowercase, then the page loads as an empty table. I guess I need the MAC addresses to be in capital. And yes, the form is correct. I'm supposed to keep the colons in the MAC address, correct? For example, it should look like:

aa:bb:cc:dd:ee:ff,My Computer
gg:hh:ii:jj:kk:ll,My Phone

Any other suggestions? Or are my DNSMasq options set incorrectly?
John877
DD-WRT Novice


Joined: 22 Apr 2013
Posts: 21

PostPosted: Mon Sep 02, 2013 15:10    Post subject: Reply with quote
heres some screenshots of how my stuff is set up:
http://i.imgur.com/dSTYr8z.png
http://i.imgur.com/PWAl04q.png

obviously the addresses are blurred and hostnames are but i have set that up as well for another reason. not sure if it impacts the wrtbwmon. i found an app for my phone called wrtgate and it relies on that list to see the computers properly.

when you changed the mac addresses to lowercase and you say it loaded a blank table, did you give it a fair bit of time to read the file? also i find its best if you dont edit the file while on the router but rather edit it locally on your computer then copy it over to the router and overwrite it.

just side question, is there a reason youre using usb flash instead of jffs? does your router not support it? what router is this by chance? again im no expert but i am just curious.
ijamjl
DD-WRT Novice


Joined: 15 Aug 2013
Posts: 8

PostPosted: Mon Sep 02, 2013 21:34    Post subject: Reply with quote
John877 wrote:
heres some screenshots of how my stuff is set up:
http://i.imgur.com/dSTYr8z.png
http://i.imgur.com/PWAl04q.png

obviously the addresses are blurred and hostnames are but i have set that up as well for another reason. not sure if it impacts the wrtbwmon. i found an app for my phone called wrtgate and it relies on that list to see the computers properly.

when you changed the mac addresses to lowercase and you say it loaded a blank table, did you give it a fair bit of time to read the file? also i find its best if you dont edit the file while on the router but rather edit it locally on your computer then copy it over to the router and overwrite it.

just side question, is there a reason youre using usb flash instead of jffs? does your router not support it? what router is this by chance? again im no expert but i am just curious.


I already had the first screenshot set up the same way, so I'm not going to upload that. The second link, it's not the same. Here it is:

http://imgur.com/iMEdrPm

First, I noticed that you set up "Used Domain" as "LAN & WLAN". When I tried that, web pages would not load on my computer. When I switched it back to just WAN, everything started working fine again. I'm not sure what the difference is but in order for me to web browse, I have to set it up "Used Domain" as "WAN".

Next, you entered all of the connections under "Static Leases", so I tried to put just one, my active computer that I'm using right now. I'm not sure what the point of it is for wrtbwmon, so I'm just leaving the one entry for now. I didn't see a difference anyway. Maybe you entered it solely because you have that wrtgate app? I didn't quite understand what you were saying because I've never used/heard of that app.

Oh, and yes, I did give an ample amount of time for the router to read/gather data after changing everything to lower case. As for your point about editing the file directly on the router, I have no idea how to do that. Every time, I pull the USB out of the router and put it back into my computer to make any edits. It's quite a hassle, but luckily my router isn't far away Razz

Finally, I don't think the router supports jffs, or if it does, I have two reasons why I'm not: (a) I have no idea how to use/access it, and (b) I think I read on one of the posts in this thread that jffs wears out very quickly, or something along those lines.

EDIT: just uploaded the USB settings. I think it does support jffs, but like I said, I'm not sure how to use it. Do I just telnet, cd to /jffs and put all the files there?

My router is an Asus RT-N13U b1 running on DD-WRT v24-sp2 (07/24/13) build 22118.
John877
DD-WRT Novice


Joined: 22 Apr 2013
Posts: 21

PostPosted: Tue Sep 03, 2013 2:51    Post subject: Reply with quote
To use the JFFS partition, you create it by turning it on in the settings and then when you log in to your router with filezilla or winscp or equivalent you will see a jffs folder there. just toss the files in there and then edit the startup script accordingly. make sure you do the wrtbwmon setup command from a telnet/ssh session logging in a root and the login password. then you should see a usage.html file in the /tmp/www/ folder and there should be a usage.db file in the /tmp/ folder. then if thats all ok then restart the router to make sure the startup script works.

As for the JFFS wearing out, it can wear out if you set the backup of the usage.db file from /tmp/ to /jffs/ at like 15 seconds or so. I have mine set to like 2 hours so it shouldnt be too bad.

About that WRTGate app, yeah that is partly the reason i set up the static leases is cause the app wouldnt see the names otherwise, only the MAC Addresses. That is also useful for setting up a pseudo-static IP for your LAN computers as well. In other words the devices can all "get IP automatically" but as the static leases are set up the router will assign that MAC Address that LAN IP every time. Its just a neater way of doing static IPs without setting them manually on every device.
ijamjl
DD-WRT Novice


Joined: 15 Aug 2013
Posts: 8

PostPosted: Wed Sep 04, 2013 14:47    Post subject: Reply with quote
John877 wrote:
To use the JFFS partition, you create it by turning it on in the settings and then when you log in to your router with filezilla or winscp or equivalent you will see a jffs folder there. just toss the files in there and then edit the startup script accordingly. make sure you do the wrtbwmon setup command from a telnet/ssh session logging in a root and the login password. then you should see a usage.html file in the /tmp/www/ folder and there should be a usage.db file in the /tmp/ folder. then if thats all ok then restart the router to make sure the startup script works.

As for the JFFS wearing out, it can wear out if you set the backup of the usage.db file from /tmp/ to /jffs/ at like 15 seconds or so. I have mine set to like 2 hours so it shouldnt be too bad.

About that WRTGate app, yeah that is partly the reason i set up the static leases is cause the app wouldnt see the names otherwise, only the MAC Addresses. That is also useful for setting up a pseudo-static IP for your LAN computers as well. In other words the devices can all "get IP automatically" but as the static leases are set up the router will assign that MAC Address that LAN IP every time. Its just a neater way of doing static IPs without setting them manually on every device.


I was about to go through the steps you posted, but then wanted to ask if it would make any difference. I mean, my only issue is that the MAC addresses display instead of the host name, and you said that as long as the path is correct, it shouldn't matter where the file is. I don't mind using the USB; I mean, it's super old anyway. However, if you think switching everything over to jffs will maybe work a little magic, then I'll go for it.
John877
DD-WRT Novice


Joined: 22 Apr 2013
Posts: 21

PostPosted: Wed Sep 04, 2013 16:04    Post subject: Reply with quote
Im assuming youve updated this line with the correct users.txt filename since i remember you said youd changed it
/mnt/sda1/wrtbwmon publish /tmp/usage.db /tmp/usage.html /mnt/sda1/MAC-PCname.txt

I dont know really now. I had issues with this as well and it seemed to just magically start working. I do remember however that in the very beginning i did forget to actually run the setup but yet somehow the usage html file got created. probly due to a restart of the router. Id try the startup script commands one by one in putty and see if something changes. probly a restart after all of it as well.

Also make sure the appropriate files are marked as executable too.
ijamjl
DD-WRT Novice


Joined: 15 Aug 2013
Posts: 8

PostPosted: Wed Sep 04, 2013 16:14    Post subject: Reply with quote
John877 wrote:
Im assuming youve updated this line with the correct users.txt filename since i remember you said youd changed it
/mnt/sda1/wrtbwmon publish /tmp/usage.db /tmp/usage.html /mnt/sda1/MAC-PCname.txt

I dont know really now. I had issues with this as well and it seemed to just magically start working. I do remember however that in the very beginning i did forget to actually run the setup but yet somehow the usage html file got created. probly due to a restart of the router. Id try the startup script commands one by one in putty and see if something changes. probly a restart after all of it as well.

Also make sure the appropriate files are marked as executable too.


Hm. What exactly do you mean by "run the setup" and "marked as executable"? Perhaps my problem exists somewhere between these two. I thought the setup was being run at startup because the script is saved to startup in the Commands tab. And as for being marked as executable, do you mean that they aren't read-only files, or do I have to enter another command line? Something that sounds like chmod 700 or something like that.
John877
DD-WRT Novice


Joined: 22 Apr 2013
Posts: 21

PostPosted: Wed Sep 04, 2013 16:19    Post subject: Reply with quote
chmod +x wrtbwmon

also from putty enter the command:
/bin/sh /jffs/wrtbwmon setup
(of course your path will vary)

then check in the /tmp/www/ folder to make sure the usage.html file is there. if it is already there as a result of restarting, delete it then do setup again. then after the script is in the startup, restart.
chintansoni
DD-WRT Novice


Joined: 26 Aug 2012
Posts: 5

PostPosted: Mon Sep 09, 2013 11:16    Post subject: File wrtbwmon is getting deleted Reply with quote
I am using TP Link N740 router.

I am able to setup this, however when I try to restart my router, wrtbwmon is automatically getting deleted.

I tried saving this file under /tmp and /dev ... but no luck!

Also When I try to upload this file under /mmc it gives me error "Read only file system"


Can anyone help?
ijamjl
DD-WRT Novice


Joined: 15 Aug 2013
Posts: 8

PostPosted: Sat Dec 28, 2013 22:04    Post subject: Reply with quote
Hi, I'm back. I wanted to ask another question.

How would I be able to reset the amounts under "Total" "Download" and "Upload"? I want to know which part to change so that if I wanted it to reset at the end of the day, or at the end of every hour, I'd be able to do so.
John877
DD-WRT Novice


Joined: 22 Apr 2013
Posts: 21

PostPosted: Sun Dec 29, 2013 6:10    Post subject: Reply with quote
Anyone have an idea how I can add monthly total for all users on the wrtbwmon page? that would be also really helpful as well.
bokka
DD-WRT Novice


Joined: 01 Feb 2014
Posts: 1

PostPosted: Sat Feb 01, 2014 8:00    Post subject: Reply with quote
Just in case anyone is wondering, this does work on Atheros routers as well. I have this running on a Dlink DIR-825 C1 without a problem. I also had problems with the Mac to PC name mapping, the format that IS working for me is
6c:62:6d:1a:XX:XX,katy-pc,
So with the end comma. I also have my file called MAC-PCname.txt and its working.

Many thanks OP for this! Its a great script.
Goto page Previous  1, 2, 3 ... 9, 10, 11, 12  Next Display posts from previous:    Page 10 of 12
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