Posted: Thu Dec 18, 2014 5:42 Post subject: Alternate Per User Bandwith Monitoring (Directly On Router)
This is a heavy modification of WRTBWMON as seen in the other contribution post with a large UI modification.
The goal of this project was to create a lighter version that reduces the workload of the router compared to the existing solution.
Here's what the UI Looks like
The UI will adjust for mobile by removing the total downloaded and uploaded columns leaving only the transmission speeds when there is not enough space.
The feature set is about the same as WRTBWMON with a main difference that most of the work now happens in HTML and javascript reducing the amount of calculations the router needs to make.
As for the spirit of this project the intent is still to be as lightweight as possible to that end there is still one more improvement I would like to make. I would like to have user adjustable polling but I haven't been able to figure how to execute a cgi-bin style service on demand through a http post or get request. If any developers here know how to do that please PM me and I can get user adjustable polling working.
I'm actually still looking for a way to get some code execution to happen via web service call (similar to the old cgi-bin).
that way in theory I can reduce the amount of router load when you're not looking at the page.
the old cgi-bin was removed from dd-wrt for a security reason.
That's at the top of my todo list but I've kinda hit a dead end.
Other things I'm planning to add is probably sorting when you click the top header but admittedly it's not as high as improving efficiency even though right now I measure the script causes the cpu usage to go up less than 2%.
Maybe someone on the forums can help me with how to execute a script on post request and return the result in the response.
In this new version I'm now by default getting all hostnames from the DnsMasq config file.
Meaning if you configured static leases for your devices you no longer have to mess around with a messy mac-names.js file.
It will automatically find the dns names for you!
Note: if you are updating over an old version and would like to save your mac-names.js custom file make a copy of the /opt/mac-names.js before upgrading.
To upgrade simply extract by placing the bwmon.tar.gz file into your /opt/ folder (or where you've chosen to install it)
and execute tar -xzvf bwmon.tar.gz
you can then optionally restore your old mac-names.js if you wish please look at start.sh to disable automatic hostnames if you are using the manual mac-names.js file.
With automatic hostnames what you've configured to be the host name on the "services" tab will be the host name you see in the bandwidth logger. It couldn't be simpler.
I just installed this in my router and there are some issues with it.
1) when I run it from CLI on router, I get frequent
messages like this
Code:
sh: 0: unknown operand
cat: can't open '/tmp/in_17177.tmp': No such file or directory
cat: can't open '/tmp/out_17177.tmp': No such file or directory
sh: 0: unknown operand
cat: can't open '/tmp/in_17177.tmp': No such file or directory
cat: can't open '/tmp/out_17177.tmp': No such file or directory
sh: 0: unknown operand
cat: can't open '/tmp/in_17177.tmp': No such file or directory
cat: can't open '/tmp/out_17177.tmp': No such file or directory
sh: 0: unknown operand
cat: can't open '/tmp/in_17177.tmp': No such file or directory
cat: can't open '/tmp/out_17177.tmp': No such file or directory
sh: 0: unknown operand
cat: can't open '/tmp/in_17380.tmp': No such file or directory
cat: can't open '/tmp/out_17380.tmp': No such file or directory
sh: 0: unknown operand
cat: can't open '/tmp/in_17380.tmp': No such file or directory
cat: can't open '/tmp/out_17380.tmp': No such file or directory
sh: 0: unknown operand
cat: can't open '/tmp/in_17380.tmp': No such file or directory
cat: can't open '/tmp/out_17380.tmp': No such file or directory
sh: 0: unknown operand
cat: can't open '/tmp/in_17380.tmp': No such file or directory
cat: can't open '/tmp/out_17380.tmp': No such file or directory
sh: 0: unknown operand
I briefly looked at the scripts as I understand a shell scripting a bit, but I do not understand it just yet how it works in detail. However, no /tmp/in_$$.tmp or out_$$.tmp files are created on my router.
traffic_pre.tmp and traffic_post.tmp are generated.
2) even though bwmon-dnsmasq.sh seems to properly create mac-names.js with all my static IPs, ony 2 of them are visible on report web page. Others are presented as MAC addresses.
Let me know if I can help debugging somehow or if I did something really stupid and introduced these problems myself.
I have applied it already, glad I could help, it is useful functionality.
Was that MAC names file of any use? I run this since yesterday. Not all machines were online, but out of the 9 that are registered, only odroid and phenom are detected. Others just show MAC addresses. This seems to be constant result, even after running clear.sh multiple times, only those two are recognized. _________________ Netgear R7000 running BS DD-WRT build 26446 (home)
I found the fix also for the first issue. It is a case problem, where some of mac addresses were uppercase and some lowercase in mac-names.js. Those which worked were lowercase, so I adjusted bwmon-dnsmasq.sh to always produce lowercase mac address list.
I would rather put that fix on the JavaScript front end. I'll have a fix that deals with that later today.
What router are you using since atheros routers aren't encountering these issues.
edit: Never mind it's in your signature.
Anways I rather fix this in the javascript to reduce load on the router. In this case it doesn't matter since bwmon-dnsmasq is only run once on startup but it'll be easier to maintain in the future sh scripts can look quite ugly over time.
Done I've updated the mac address code on the front end to be fault tolerant so as to ignore the case.
The reason for putting it here is that it protects against user error if the user is manually crafting a mac-names.js file it would also be case insensitive for them.
I have updated the files on github please also not the binary has been removed from the main repo. It is now located under "releases"
This will make it easier for people to track which version they are on and see if an update is available.
I've also removed the /bwmon/data/usage.js blank sample file. Now you can overwrite directly over your existing install without any adverse affects since you can do so without overwriting your usage file.
I have marked this release as 1.1 (release 1.0 never had automatic dns). Any bugfixes will increment 1.1.x
Any feature additions will increment the minor number 1.x.