vortex-5 / ddwrt-bwmon

An Individual Bandwidth Monitor For DD-WRT
171 stars 37 forks source link

Mac addresses only on display #71

Closed Alek01 closed 4 years ago

Alek01 commented 4 years ago

Although it took me a while to come across your script, it is nevertheless AWESOME! I even kept my old router with dd-wrt just because of BWMON. Well, there were some issues first (mac addresses only on display) so I upgraded dd-wrt to the latest version (DD-WRT v3.0-r42954 std (04/20/20) Dlink-DIR-632A). For the short period of time it worked fine (while the router was the dhcp server), but there were some dhcp issues on the router, so I rather assigned the dhcp chores to another device (also to reduce the overhead of the router). The mac-names.js solution for the display is an excellent feature too, as it could be personalised very easily. I have played with the shell scripts, tried upper and lower case mac addresses, but for some reason it just does not want to match it up and display it. Tried to follow this thread: https://github.com/vortex-5/ddwrt-bwmon/issues/14 (How would I disable the automatic dnsmasq hostname resolution located in start.sh) but it seems that since that discussion (version) a lot of things have changed. But this is basically what I would like, ignore everything else, just read the mac-names.js. Is there an easy way to do this? And thanks for the great tool!!!

vortex-5 commented 4 years ago

mac-names.js should override everything else. It also may be possible since this feature is very old that there might be a bug and I might need to investigate but a few things to try before it comes to that.

Maybe your code for mac-names.js is not following javascript syntax?

If you want to override DHCP you can just turn off dnsmasq on your router through the normal router UI.

vortex-5 commented 4 years ago

Here's a sample mac-names.js file:

mac-names.txt

It is important you save the file in unix file format (LF) not windows file format CR-LF I've noticed certain routers don't like the windows CR LF format.

Alek01 commented 4 years ago

Thanks for a very quick response. Turned off dnsmasq on the router, but that did not make any difference.

Also re-created the mac-names.js on the router, but that did not seem to have any effect either. Ran startup.sh after both changes. Running the normal version (not the lighthttpd one).

I checked the syntax, which seemed pretty straightforward, but did not notice any issues:

root@------:/jffs/bwmon# more /tmp/www/mac-names.js var MAC_NAMES = { '00:00:00:67:89:ab': 'First and every other pc name', '00:00:00:67:37:b7': 'printer', '00:00:00:60:69:09': 'voip phone', '00:00:00:29:fe:2a': 'S-DESK-L', '00:00:00:44:d4:34': 'S-DESK-WL', '00:00:00:d8:3e:4f': 'S-m', '00:00:00:e1:6c:96': 'Air-San', '00:11:22:33:44:55': 'Last PC Name' };

Padded with 0s the first 5 hex values, would the - or _ have any issues in the names?

vortex-5 commented 4 years ago

I just tested the feature now and it seems to be working on my router. is the mac-names.js file accessable from your router?

try going to it

http://192.168.1.1:8000/mac-names.js

Where your router's bandwidth state page is given by:

http://192.168.1.1:8000/bwmon.html

This can be different if you're running this in lighttpd server mode or just standard router/user/www mode.

vortex-5 commented 4 years ago

Also FYI for future reference it's better to pad the last 5 HEX values rather than the first 5 the first 3 are OUI manufacturer id's and there's not a lot of them.

In your example you don't actually need my sample entries:

var MAC_NAMES = { '00:00:00:67:37:b7': 'printer', '00:00:00:60:69:09': 'voip phone', '00:00:00:29:fe:2a': 'S-DESK-L', '00:00:00:44:d4:34': 'S-DESK-WL', '00:00:00:d8:3e:4f': 'S-m', '00:00:00:e1:6c:96': 'Air-San' };

Alek01 commented 4 years ago

Thanks, yes, the bwmon is visible on http://ip.address/user/bwmon.html and the mac-name is also visible on http://ip.address/user/mac-names.js, running just the just standard router/user/www mode.

I update the mac-names.js in /jffs/bwmon/www: -rwxrwxrwx 1 root root 319 date-here mac-names.js run startup.sh, that copies it to /tmp/www -rwxr-xr-x 1 root root 319 date-here mac-names.js

Maybe the access rights are not right?

For the installation I have followed your guide to the letter and it worked fine (except for this issue).

vortex-5 commented 4 years ago

Access rights should be "-rw-r--r--"

Alek01 commented 4 years ago

Set the rights as you mentioned, no difference, as expected, as it made it more restrictive, but startup.sh re-sets them anyway.

You mentioned that:" The latest tested version of DD-WRT confirmed to be working is 42925 with this module ", as I am running 42954, maybe that has introduced something?

Will keep playing with it, as it is a really nice tool, but if noone else has this issue, then I don't really want to take up of your time. Thanks for your help so far and will let you know if I was able to sort it :)

Alek01 commented 4 years ago

One thing I was going to ask you though... maybe a workaround In bwmon.sh at the end of it it has this: ... echo " $0 publish database_file path_of_html_report [user_file]" ... echo " $0 publish /tmp/usage.db /www/user/usage.htm /jffs/users.txt" echo "Note : [user_file] is an optional file to match users with their MAC address" echo " Its format is : 00:MA:CA:DD:RE:SS,username , with one entry per line"

I tried to extend the existing (in bwmon-running.sh): from $SCRIPT_DIR/bwmon.sh publish /tmp/www/usage.js /tmp/www/usage_stats.js to $SCRIPT_DIR/bwmon.sh publish /tmp/www/usage.js /tmp/www/usage_stats.js /jffs/bwmon/users.txt

in users.txt following the sample: e0:a3:00:00:00:00,pc1 d4:f5:47:00:00:00,pc2 64:80:00:00:00:00,pc3

It has not worked either :( My question is, should it have worked, is this feature still available?

If yes, at least it would give me another option to trial :)

Thanks heaps!

vortex-5 commented 4 years ago

I tested everything when you posted the initial issue and everything works for me. So it's a somewhat unknown issue at the moment based on your configuration / router.

Also I'm currently running this on 43099 it's unlikely that it's a downgrade fixable issue.

Alek01 commented 4 years ago

Digging a bit deeper, from the router log it appeared that one of the file was missing: httpd : Request Error Code 404: File user/dnsmasq-leases.js not found (dnsmasq-leases.js -> /tmp/dnsmasq.leases)

Created the file manually (in /tmp/dnsmasq.leases): 00:00:00:00:11:22 name-of-the-device 00:00:00:00:11:23 name-of-the-device_02

and from then on it worked as intended, reading info from the mac-names.js.

So it seems regardless what was in the dnsmasq.leases, it just needed it....

I also created dnsmasq.conf: dhcp-host=00:00:00:00:11:22,name-of-the-device dhcp-host=00:00:00:00:11:23,name-of-the-device_02

Thanks, not sure why those files were not there (most likely as the router is not DHCP server nor local DNS), but by manually creating them

The main thing, it works now!!!

Thanks.

vortex-5 commented 4 years ago

The default configuration of DDWRT uses dnsmasq it appears you're saying that if you change the service on the router to use DHCPd then the script isn't ignoring the request for dnsmasq. The script is designed to continue requesting for it but it should still run without actually needing it.

I guess I'll investigate this use case when I get an opportunity.

Alek01 commented 4 years ago

I do not use the DHCPd on the router and I think that has caused the problem (missing 2 files). It still runs without those 2 files, just does not include the mac-names file. Once those files were there (created manually by me), it read the mac-names file and worked fine since :)

I think majority of users use the router as the dhcp server that's why they do not have any issues (with mac-names to user friendly hostnames conversions).

vortex-5 commented 4 years ago

Try this see if this solves your issue without the need of the work around. bwmon.tar.gz

In theory I've figured out what the problem is but I need a confirmation before I draft a new minor bug fix version.

Alek01 commented 4 years ago

It did!

Deleted all the files that I created, did all the steps , except for step #6: wget https://github.com/vortex-5/ddwrt-bwmon/files/4640355/bwmon.tar.gz and worked perfectly from the start!

Thanks mate, much appreciated!

vortex-5 commented 4 years ago

Great new bug fix version released based off of this version.