Alternate Per User Bandwith Monitoring (Directly On Router)

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Goto page 1, 2, 3, 4, 5  Next
Author Message
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Thu Dec 18, 2014 5:42    Post subject: Alternate Per User Bandwith Monitoring (Directly On Router) Reply with quote
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.

To get this for yourself I have instructions on github: https://github.com/vortex-5/ddwrt-bwmon

Developer Notes Below:

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.
Sponsor
ckdalsdk12
DD-WRT User


Joined: 08 Mar 2014
Posts: 52

PostPosted: Sun Feb 01, 2015 11:05    Post subject: Reply with quote
Deleted

Last edited by ckdalsdk12 on Thu Nov 30, 2023 9:54; edited 1 time in total
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Sun Feb 01, 2015 16:24    Post subject: Reply with quote
I guess an igmp packet is not covered by the iptables counter? So far this is the only way I've seen to monitor packets for traffic.

All the other bandwidth counters are essentially doing a similar thing.
ckdalsdk12
DD-WRT User


Joined: 08 Mar 2014
Posts: 52

PostPosted: Sun Feb 01, 2015 17:43    Post subject: Reply with quote
Deleted

Last edited by ckdalsdk12 on Thu Nov 30, 2023 9:54; edited 2 times in total
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Sun Feb 01, 2015 17:52    Post subject: Reply with quote
No problem glad you like it.

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.
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Mon Feb 09, 2015 3:08    Post subject: Reply with quote
I've just updated the tool to be slightly better!

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.
raqua
DD-WRT User


Joined: 13 Feb 2014
Posts: 58

PostPosted: Fri Feb 13, 2015 22:04    Post subject: Reply with quote
Hi!

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.

Thx.

_________________
Netgear R7000 running BS DD-WRT build 26446 (home)
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Fri Feb 13, 2015 23:07    Post subject: Reply with quote
Can you send me the contents of mac-names.js?

Please remove the actual Mac addresses and replace them with XX before you post it publicly.
raqua
DD-WRT User


Joined: 13 Feb 2014
Posts: 58

PostPosted: Fri Feb 13, 2015 23:12    Post subject: Reply with quote
Hello, thanks for the fast reply.

Here is the contents of the requested file:
Code:

var MAC_NAMES = {
'00:18:41:E1:xx:xx': 'XXX-g1',
'D8:5D:4C:90:xx:xx': 'tplink',
'6C:AD:F8:2B:xx:xx': 'chromecast',
'74:D4:35:56:xx:xx': 'amd',
'b8:27:eb:fe:xx:xx': 'rpi',
'00:0D:60:2F:xx:xx': 'x31',
'A0:F4:50:5A:xx:xx': 'XXX-onev',
'E8:4E:06:12:xx:xx': 'edup',
'90:21:55:DB:xx:xx': 'desirez',
'00:26:C6:0C:xx:xx': 'luba',
'A0:0B:BA:E4:xx:xx': 'gnex',
'24:77:03:A9:xx:xx': 'precision',
'80:1f:02:bb:xx:xx': 'phenom',
'FF:FF:FF:FF:xx:xx': 'wol-reserved',
'BC:F5:AC:FC:xx:xx': 'nexus5',
'40:B0:FA:9B:xx:xx': 'nexus4',
'1e:39:ce:6b:xx:xx': 'odroid',
'DUMMY': 'DUMMY'
};

_________________
Netgear R7000 running BS DD-WRT build 26446 (home)
raqua
DD-WRT User


Joined: 13 Feb 2014
Posts: 58

PostPosted: Fri Feb 13, 2015 23:19    Post subject: Reply with quote
I also have found the reason for the first bug and have possible fix. This is the contents of my /proc/net/arp:
Code:

IP address       HW type     Flags       HW address            Mask     Device
xxx.xxx.40.1     0x1         0x2         08:19:a6:84:xx:xx     *        vlan2
10.75.68.254     0x1         0x6         ff:ff:ff:ff:xx:xx     *        br0
10.75.68.113     0x1         0x2         bc:f5:ac:fc:xx:xx     *        br0
10.75.68.115     0x1         0x2         1e:39:ce:6b:xx:xx     *        br0
10.75.68.108     0x1         0x2         90:21:55:db:xx:xx     *        br0
10.75.68.112     0x1         0x2         80:1f:02:bb:xx:xx     *        br0
10.75.68.114     0x1         0x2         40:b0:fa:9b:xx:xx     *        br0
10.75.68.102     0x1         0x2         6c:ad:f8:2b:xx:xx     *        br0


xxx.xxx.40.1 is my gateway and this IP is not found in the /tmp/traffic_post.tmp and /tmp/traffic_pre.tmp files.
Therefore
Code:

grep ${IP} /tmp/traffic_pre.tmp

result is empty and it crashes later in the processing, because no in_$$.tmp and out_$$.tmp are written.

Fix that works for me is to change
Code:

grep -v "0x0" /proc/net/arp | while read IP TYPE FLAGS MAC MASK IFACE

to
Code:

grep -v "0x0" /proc/net/arp | grep ${LAN_IFACE} | while read IP TYPE FLAGS MAC MASK IFACE


(twice in the script bwmon.sh)

_________________
Netgear R7000 running BS DD-WRT build 26446 (home)
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Sat Feb 14, 2015 4:09    Post subject: Reply with quote
I've patched it on github you can download it again with that link.

If you don't want to install it all over again you can just grab the bwmon.sh file to save yourself time.

Although I don't think it will be any different as you've already applied the fix.

Thanks btw.
raqua
DD-WRT User


Joined: 13 Feb 2014
Posts: 58

PostPosted: Sat Feb 14, 2015 14:46    Post subject: Reply with quote
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)
raqua
DD-WRT User


Joined: 13 Feb 2014
Posts: 58

PostPosted: Sat Feb 14, 2015 16:01    Post subject: Reply with quote
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.

Changed:
Code:

echo "'$MAC': '$NAME'," >> $DYNAMIC_FILE

to:
Code:

MAC_LOWERCASE=$(echo $MAC | tr '[A-Z]' '[a-z]')
echo "'$MAC_LOWERCASE': '$NAME'," >> $DYNAMIC_FILE


Now it works.

_________________
Netgear R7000 running BS DD-WRT build 26446 (home)
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Sat Feb 14, 2015 16:39    Post subject: Reply with quote
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.
vortex05
DD-WRT User


Joined: 14 Mar 2014
Posts: 218

PostPosted: Sat Feb 14, 2015 17:50    Post subject: Reply with quote
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.
Goto page 1, 2, 3, 4, 5  Next Display posts from previous:    Page 1 of 5
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