vortex-5 / ddwrt-bwmon

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

1.8.1 does not work on kong DDWRT #45

Closed Meowzz95 closed 7 years ago

Meowzz95 commented 7 years ago

Firmware: DD-WRT v3.0-r30700M Kongac(09/27/16) Router : NetGear 6300v2

I followed all instructions in README except I am using router built-in memory as jffs instead of using an external USB drive. I've tried both Lighttpd Webserver on and off, both ended up in this same situation. This screenshot is taken when Lighttpd is off. router The list is always empty while the countdown is working. The following error is found in chrome JS console. Failed to load resource: http://router.com/bwreader.php?no-cache=1478006064082 the server responded with a status of 404 (Not Found)

In fact, I've used this several months ago until I upgraded one version which I had exactly the same problem as this version. I didn't try to fix it because I was a bit busy at that time, but now this problem still exists...

Sorry for the poor English... I'm not a native English speaker. Do let me know if there's anything unclear. Thanks!

vortex-5 commented 7 years ago

Lighthttpd runs on port 81 by default the URL is http://192.168.1.1:81 with default settings. Not sure how you got a dot com name resolution to work other than manually inserting the entry into your DNS masq

Meowzz95 commented 7 years ago

The name resolution is done by DNSmasq and I'll try to set port number to 81 and post the outcome here. Thanks!

Meowzz95 commented 7 years ago

Now I'm using Lighthttpd with port number set to 81. This is the first execution of startup.sh after rebooting the router. putty The problem still exists, countdown disappears but still can see the countdown is updating in chrome inspection, JS error is gone. ss

vortex-5 commented 7 years ago

you may want to check to see if 192.168.99.1:81/bwreader.php is accessible.

Meowzz95 commented 7 years ago

Yes it is accessible readerss_

Meowzz95 commented 7 years ago

The Lighthttpd seems to be working fine... php

Meowzz95 commented 7 years ago

It seems that the iptable command returned nothing? I don't really know this... what debugging info can I provide you?

Meowzz95 commented 7 years ago

This is the result of iptables -L , hope it helps.

root@DD-WRT:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     0    --  anywhere             anywhere            state RELATED,ESTAB                                                                                                                                                             LISHED
ACCEPT     udp  --  anywhere             anywhere            udp spt:bootps dpt:                                                                                                                                                             bootpc
DROP       udp  --  anywhere             anywhere            udp dpt:route
DROP       udp  --  anywhere             anywhere            udp dpt:route
ACCEPT     udp  --  anywhere             anywhere            udp dpt:route
DROP       icmp --  anywhere             anywhere
DROP       igmp --  anywhere             anywhere
ACCEPT     0    --  anywhere             anywhere            state NEW
ACCEPT     0    --  anywhere             anywhere            state NEW
DROP       0    --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
BWMON      0    --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             DESKTOP-OT1VR0B     tcp dpt:28292
ACCEPT     udp  --  anywhere             DESKTOP-OT1VR0B     udp dpt:28292
ACCEPT     0    --  anywhere             anywhere            state RELATED,ESTAB                                                                                                                                                             LISHED
ACCEPT     gre  --  192.168.99.0/24      anywhere
ACCEPT     tcp  --  192.168.99.0/24      anywhere            tcp dpt:1723
lan2wan    0    --  anywhere             anywhere
ACCEPT     0    --  anywhere             anywhere
ACCEPT     udp  --  anywhere             DESKTOP-OT1VR0B     udp dpt:22540
ACCEPT     tcp  --  anywhere             DESKTOP-OT1VR0B     tcp dpt:22540
ACCEPT     tcp  --  anywhere             192.168.99.145      tcp dpt:4466
ACCEPT     udp  --  anywhere             192.168.99.145      udp dpt:4466
ACCEPT     tcp  --  anywhere             192.168.99.112      tcp dpt:7909
ACCEPT     udp  --  anywhere             192.168.99.112      udp dpt:9909
ACCEPT     udp  --  anywhere             192.168.99.112      udp dpt:56149
ACCEPT     tcp  --  anywhere             192.168.99.112      tcp dpt:8386
ACCEPT     udp  --  anywhere             192.168.99.112      udp dpt:11710
ACCEPT     tcp  --  anywhere             192.168.99.112      tcp dpt:10335
ACCEPT     udp  --  anywhere             192.168.99.112      udp dpt:12322
ACCEPT     udp  --  anywhere             DESKTOP-OT1VR0B     udp dpt:22540
ACCEPT     tcp  --  anywhere             DESKTOP-OT1VR0B     tcp dpt:22540
ACCEPT     udp  --  anywhere             iPadmmm             udp dpt:1788
ACCEPT     tcp  --  anywhere             iPadmmm             tcp dpt:1788
ACCEPT     tcp  --  anywhere             192.168.99.112      tcp dpt:18386
ACCEPT     udp  --  anywhere             DESKTOP-OT1VR0B     udp dpt:28292
ACCEPT     tcp  --  anywhere             192.168.99.112      tcp dpt:7909
ACCEPT     udp  --  anywhere             192.168.99.112      udp dpt:9909
ACCEPT     udp  --  anywhere             192.168.99.112      udp dpt:55988
ACCEPT     udp  --  anywhere             SERVER              udp dpt:60417
ACCEPT     tcp  --  anywhere             DESKTOP-OT1VR0B     tcp dpt:28292
ACCEPT     udp  --  anywhere             SERVER              udp dpt:53922
TRIGGER    0    --  anywhere             anywhere            TRIGGER type:in mat                                                                                                                                                             ch:0 relate:0
trigger_out  0    --  anywhere             anywhere
ACCEPT     0    --  anywhere             anywhere            state NEW
DROP       0    --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain BWMON (1 references)
target     prot opt source               destination

Chain advgrp_1 (0 references)
target     prot opt source               destination

Chain advgrp_10 (0 references)
target     prot opt source               destination

Chain advgrp_2 (0 references)
target     prot opt source               destination

Chain advgrp_3 (0 references)
target     prot opt source               destination

Chain advgrp_4 (0 references)
target     prot opt source               destination

Chain advgrp_5 (0 references)
target     prot opt source               destination

Chain advgrp_6 (0 references)
target     prot opt source               destination

Chain advgrp_7 (0 references)
target     prot opt source               destination

Chain advgrp_8 (0 references)
target     prot opt source               destination

Chain advgrp_9 (0 references)
target     prot opt source               destination

Chain grp_1 (0 references)
target     prot opt source               destination

Chain grp_10 (0 references)
target     prot opt source               destination

Chain grp_2 (0 references)
target     prot opt source               destination

Chain grp_3 (0 references)
target     prot opt source               destination

Chain grp_4 (0 references)
target     prot opt source               destination

Chain grp_5 (0 references)
target     prot opt source               destination

Chain grp_6 (0 references)
target     prot opt source               destination

Chain grp_7 (0 references)
target     prot opt source               destination

Chain grp_8 (0 references)
target     prot opt source               destination

Chain grp_9 (0 references)
target     prot opt source               destination

Chain lan2wan (1 references)
target     prot opt source               destination

Chain logaccept (0 references)
target     prot opt source               destination
ACCEPT     0    --  anywhere             anywhere

Chain logdrop (0 references)
target     prot opt source               destination
DROP       0    --  anywhere             anywhere

Chain logreject (0 references)
target     prot opt source               destination
REJECT     tcp  --  anywhere             anywhere            reject-with tcp-res                                                                                                                                                             et

Chain trigger_out (1 references)
target     prot opt source               destination
vortex-5 commented 7 years ago

There's an IP Table policy called BWMON this is inserted by the script. It is a straight forward pass through rule as all traffic passes through this policy it allows the traffic to be counted. Many tools use the ip tables firewall packet counting facility to do this type of bandwidth monitoring.

start.sh sets up the initial rule you can try manually executing that.

This problem at the moment seems to be isolated to your particular router / revision number.

Meowzz95 commented 7 years ago

Okay I'll try that tomorrow, it's 23:59 at my country :)

Btw I do remember one of the very old version worked for me and one day the updated version does not work anymore on the same router and same firmware (not the same firmware as I am using right now)

Anyway thanks for the excellent project. I'll keep updated here.

vortex-5 commented 7 years ago

If you can let me know which release did work for you I can have a look at some of the differences between the versions. Ideally if you could tell me between which of the releases it broke that would be most helpful but I know that's a lot of work to find the exact point it stopped working.

Meowzz95 commented 7 years ago

I tried to manually execute start.sh, it shows successfully started but the result page is still empty, bwreader.php returns same thing as well.

I roughly remember the update info of the version which stops working for me, I'll try to find out which version it is. What files do I need to remove before I try to install an earlier version? Or I just do overwrite?

Wrechid commented 7 years ago

Hello vortex, it seems that I am having the same problem here... I have the same story too... It was working on an older version of bwmon... Not sure, I think it was around 1.7.0... It stopped working, and I forgot about it... Then recently I started playing with it... Installed the 1.8.1 version, and started having the same problem... I updated my dd-wrt to v30880, as that is what dd-wrt wiki gave me for my WNDR3700 router... Didn't reset defaults on router as I have many port forwards and ip addys reserved... But bwmon still didn't work... I did find the 30949 dd-wrt build for my router, but I wanted to do some more digging before I upgraded and reset all settings...

First of all, iptables appear to be working, with the BWMON chain counting data... Second, the usage.js and usage_stats.js files in /tmp/www do have data in them in a nice csv format... Mac addys and data use...

It appears that the data is being collected and backed up to the /jffs/data folder, but the website isn't able to get or see it... So I opened the error console on Firefox... Right away I started seeing 2 errors, http://192.168.2.1:81/usage_stats.js 404 Not Found http://192.168.2.1:81/dnsmasq-leases.js 404 Not Found

So I figured let's help it to find... I created a link like so, ln -s /tmp/www/usage_stats.js /jffs/www/

The web page instantly started showing data without refreshing the page... I'm still getting the dnsmasq-leases.js not found error, as I don't see the file anywhere... Digging into where it comes from now...

Hope this helps...

Meowzz95 commented 7 years ago

@Wrechid Yo.. Real pro here :) Thanks for helping me out

Wrechid commented 7 years ago

your welcome... i found the dnsmasq file and made a correction to the start.sh file that helps both errors... in the start.sh file i modified starting at line #25

copy html webgui

if [ "$($SCRIPT_DIR/lighttpd-running.sh)" = "true" ]; then cp -R $SCRIPT_DIR/www/ /jffs/www/ else cp -R $SCRIPT_DIR/www/ /tmp/www/ ln -s /tmp/dnsmasq.conf /tmp/www/dnsmasq-conf.js ln -s /tmp/dnsmasq.leases /tmp/www/dnsmasq-leases.js fi

to this

copy html webgui

if [ "$($SCRIPT_DIR/lighttpd-running.sh)" = "true" ]; then cp -R $SCRIPT_DIR/www/ /jffs/www/ ln -s /tmp/www/usage_stats.js /jffs/www/ ln -s /tmp/dnsmasq.conf /jffs/www/dnsmasq-conf.js ln -s /tmp/dnsmasq.leases /jffs/www/dnsmasq-leases.js else cp -R $SCRIPT_DIR/www/ /tmp/www/ ln -s /tmp/dnsmasq.conf /tmp/www/dnsmasq-conf.js ln -s /tmp/dnsmasq.leases /tmp/www/dnsmasq-leases.js fi

this will link the usage_stats.js, and dnsmasq-leases.js files so that lighttpd will find them each time it is started... i'm not sure that this is the correct fix, but its a work around for now...

Meowzz95 commented 7 years ago

@Wrechid YOU ARE AWESOME... Although I haven't tried your workaround :)

Wrechid commented 7 years ago

I love a good challenge, lol...

my final findings... i updated to the latest 30949 dd-wrt build for my router and notice that i still do not have php support... that would explain it... the required file paths are set in bwreader.php... since i don't have php support, it would fail to find the files... thats where the links come into play... we need a test for php support and if not available then use links...

to verify if this is your problem you can create a file /jffs/www/test.php in that file put:

<?php phpinfo(); ?>

save the file and in a browser navigate to http://:81/test.php

if php is working you should get a lot of php info in a pretty webpage else you'll get "503 - Service Not Available"

Meowzz95 commented 7 years ago

@Wrechid My php is working fine I've tested it. @vortex-5 said that some DDWRT build has broken php support in some issues so I've already ruled it out.

vortex-5 commented 7 years ago

There is no specific test for php support currently the whole point of running lighttpd is to be able to run scripts and services so the startup script checks for the process then will proceed to obtain all data from the php script. You said bwreader.php executes fine? You get data with it not just an error when accessed directly?

30949 specifically resolves the issue without any code changes for WNDR4300 routers.

vortex-5 commented 7 years ago

A simple work around is to just turn off the web server lighttpd it will cause the script to detect no service support correctly and switch to the normal 10 sec update mode.

Wrechid commented 7 years ago

Hello, yea I was thinking about trying without lighthttpd... I was just trying to figure out what was going on here... The bwreader.php does not load at all... If I test php via the "test.php" method I get error 503... Doing more digging, I see php installed in dd-wrt... Just lighthttpd doesn't have php support... I think it needs to be enabled via the shell .profile...

On December 21, 2016 12:18:56 PM EST, FanFan notifications@github.com wrote:

There is no specific test for php support currently the whole point of running lighttpd is to be able to run scripts and services so the startup script checks for the process then will proceed to obtain all data from the php script. You said bwreader.php executes fine? You get data with it not just an error when accessed directly?

30949 specifically resolves the issue without any code changes for WNDR4300 routers.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/vortex-5/ddwrt-bwmon/issues/45#issuecomment-268580644

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

Wrechid commented 7 years ago

@Meowzz95 sorry for delay, i see you are using Chrome, i'm not a regular user of Chrome... Does Chrome have an error console...? Using FireFox, there is a plugin called Error Console... Since the page does load just not show data, try to find the specific error... Inspecting the Element only told me there was and error in the head and body of the source...

vortex-5 commented 7 years ago

Just to clarify it doesn't show data because it's expecting to get the data from the bwreader.php.

The output is designed to be almost human readable all the data is within the pre tags each of the sections are given an id which the script looks for.

Wrechid commented 7 years ago

Yea, I seen that as I was looking through it... After making links to the usage.js and dnsmasq files the web page starts showing data... I have a new error in Firefox error console, reporting bwreader.php not working... I stopped digging into it, and it seems to be working with the links... I didn't verify the data was correct... Is the bwreader.php function needed for accurate data presentation via the web page...? When I was digging into the issue, I noticed methods of enabling php in lighthttpd by adding the needed info to the environment .profile and/or .bashrc...

I'll figure it out laterz, I was just trying to help you with my findings... I really like this setup that you put together, you have done a great job... I'm trying to figure out a way to send the data to a remote location and process the data for presentation on a remote location... For example : I want to make a widget for Windows desktop to display the data...

On December 22, 2016 2:11:21 PM EST, FanFan notifications@github.com wrote:

Just to clarify it doesn't show data because it's expecting to get the data from the bwreader.php.

The output is designed to be almost human readable all the data is within the pre tags each of the sections are given an id which the script looks for.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/vortex-5/ddwrt-bwmon/issues/45#issuecomment-268869094

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

gstrauss commented 7 years ago

Not sure if this is related, but older versions of lighttpd prior to lighttpd 1.4.40 had trouble with mmap on JFFS2. You might try a version of lighttpd built ./configure --disable-mmap (or without --enable-mmap) or, better, a version of lighttpd 1.4.40 or later.

sendfile() on older version of lighttpd might also cause problems. You might try the following in lighttpd.conf: server.network-backend = "writev"