dd-wrt - Bandwidth Usage Monitor

Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3 ... 25, 26, 27 ... 40, 41, 42  Next
Author Message
bpsmicro
DD-WRT User


Joined: 07 Oct 2010
Posts: 180

PostPosted: Wed Oct 26, 2011 20:30    Post subject: Reply with quote
On your last question, you're correct, just omit the missing parameter (so two commas).

Brad.
Sponsor
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sat Oct 29, 2011 1:14    Post subject: Reply with quote
barryware wrote:
@blurp.. That helped.. Thanks.

ok... a couple of assumptions...

My router ip is 192.168.254.1

I have a usb storage device mounted to /opt

I create a folder in opt called /bw_monitor

/opt/bw_monitor

I create a folder in bw_monitor called /history

/opt/bw_monitor/history

I put monitor.html and bw_monitor.sh in /opt/bw_monitor

change permissions of bw_monitor.sh to make it executable.

I do not intend to use dnsmasq for dhcp so I create and populate the user file (user.file) and put it in /opt/bw_monitor

Then plop this into my startup command:

#!/bin/sh
MONITOR_LOCK_FILE=/tmp/monitor-started.lock
MONITOR_STOP_FILE=/tmp/monitor-stop
MONITOR_STOPPED_FILE=/tmp/monitor-stopped
while [ ! -f $MONITOR_LOCK_FILE ] && [ ! -f $MONITOR_STOP_FILE ]; do
if [ ! -f /www/user/monitor.html ]; then
sed 's/src=.*>/src="http:\/\/192.168.254.1\/user\/user_details.js"><\/script>/' /opt/bw_monitor/monitor.html > /www/user/monitor.html
fi
/opt/bw_monitor/bw_monitor.sh 30 3 30 23 /opt/bw_monitor/user.file /opt/bw_monitor/mac_usage.backup /opt/bw_monitor/history/ /tmp/mac_usage.db /tmp/www/ 1 0 0 1 1 0 1
if [ ! -f $MONITOR_LOCK_FILE ]; then
sleep 10
fi
done

This should do it??

I can't test till later but I think I found my problem. (paths)
What paths did you mess up? I have it setup but the page is not populated.
_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13049
Location: Behind The Reset Button

PostPosted: Sat Oct 29, 2011 2:31    Post subject: Reply with quote
Dark_Shadow wrote:
What paths did you mess up? I have it setup but the page is not populated.


Well.. I spoke too soon. The app runs and the files get put in tmp and they get populated but the monitor.html file does not run.

I get the page, but there is no data..

This is now my startup:

#!/bin/sh
sleep 10
while [ ! -f /tmp/monitor-started.lock ] && [ ! -f /tmp/monitor-stop ]; do
cp /opt/bw_monitor/monitor.html /tmp/www/monitor.html
opt/bw_monitor/bw_monitor.sh 30 3 30 1 /opt/bw_monitor/users.txt /opt/bw_monitor/mac_usage.backup /opt/bw_monitor/history/ /opt/bw_monitor/mac_usage.db '' 1 1 1 1 1
if [ ! -f /tmp/monitor-started.lock ]; then
sleep 10
fi
done &

This is line 89 of monitor.html:

<script type='text/javascript' src='http://192.168.1.1/user/user_details.js'></script>

I thought the problem was the ip 192.168.1.1. My router is 192.168.254.1 so I changed that line but it didn't change anything.

As said.. the files are being moved and created. The app is running, the data files are being populated, but the html page does not run.. well it runs but it is not getting the data.

The page also reports errors. I can't bring it up right now but something about "users" is not defined.

I'm using IE for the browser

_________________
[Moderator Deleted] Shocked
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sat Oct 29, 2011 4:06    Post subject: Reply with quote
My S55bwmon

Code:
#!/bin/sh
MONITOR_LOCK_FILE=/tmp/monitor-started.lock
MONITOR_STOP_FILE=/tmp/monitor-stop
MONITOR_STOPPED_FILE=/tmp/monitor-stopped
while [ ! -f $MONITOR_LOCK_FILE ] && [ ! -f $MONITOR_STOP_FILE ]; do
   if [ ! -f /opt/www/monitor.html ]; then
      sed 's/src=.*>/src="http:\/\/192.168.10.1\/user\/user_details.js"><\/script>/' /opt/bwm/monitor.html > /www/user/monitor.html
   fi
   /opt/bwm/bw_monitor.sh 30 3 30 4 /tmp/dnsmasq.conf /opt/bwm/mac_usage.backup /opt/bwm/history/ '' '' 1 0 0 0 1 0 0 /opt/bwm/bwmon.log
   if [ ! -f $MONITOR_LOCK_FILE ]; then
      sleep 10
   fi
done


I have the same results BW. Files populating but not publishing to the HTML file.

_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sat Oct 29, 2011 4:12    Post subject: Reply with quote
barryware wrote:

This is line 89 of monitor.html:

<script type='text/javascript' src='http://192.168.1.1/user/user_details.js'></script>

I thought the problem was the ip 192.168.1.1. My router is 192.168.254.1 so I changed that line but it didn't change anything.
change it in /www/user/monitor.html, worked for me
_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13049
Location: Behind The Reset Button

PostPosted: Sat Oct 29, 2011 12:53    Post subject: Reply with quote
I copied your startup exactly.. an renamed my bw_monitor folder to bwm like yours.

I changed one line to my routers ip.. The other change I made is i'm not using dnsmasq so I have a file /opt/bwm/users.txt

as before.. the html page loads but no data and I get the following errors:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1; .NET4.0C)
Timestamp: Sat, 29 Oct 2011 12:50:58 UTC


Message: 'users' is undefined
Line: 93
Char: 29
Code: 0
URI: http://192.168.254.1/user/monitor.html


Message: 'users' is undefined
Line: 127
Char: 24
Code: 0
URI: http://192.168.254.1/user/monitor.html


Message: 'users' is undefined
Line: 501
Char: 26
Code: 0
URI: http://192.168.254.1/user/monitor.html


Message: 'users' is undefined
Line: 557
Char: 26
Code: 0
URI: http://192.168.254.1/user/monitor.html


Message: 'users' is undefined
Line: 625
Char: 41
Code: 0
URI: http://192.168.254.1/user/monitor.html


Message: 'users' is undefined
Line: 668
Char: 41
Code: 0
URI: http://192.168.254.1/user/monitor.html

I dunno

_________________
[Moderator Deleted] Shocked


Last edited by barryware on Sat Oct 29, 2011 13:22; edited 1 time in total
bpsmicro
DD-WRT User


Joined: 07 Oct 2010
Posts: 180

PostPosted: Sat Oct 29, 2011 12:58    Post subject: Reply with quote
You don't have Javascript disabled in your browser, do you? That'll definitely mess things up. Is the user_details.js file being created in the same directory as your monitor.html?
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13049
Location: Behind The Reset Button

PostPosted: Sat Oct 29, 2011 13:12    Post subject: Reply with quote
bpsmicro wrote:
You don't have Javascript disabled in your browser, do you? That'll definitely mess things up. Is the user_details.js file being created in the same directory as your monitor.html?


No.. it is not disabled... I got rid of DS's startup and went back to the one I posted earlier.

The app is running.. The files are where they are supposed to be. The .js script is being created in the same folder a monitor.html.

the user folder is created.. it is actually a symbolic link that points bact to my /opt/www folder

/www/user = /opt/www

the monitor-started.lock file in created in /tmp

EDIT: it has been running for a while.. mac_usage.db & mac_usage.backup are there & populated. No question the app is running.

_________________
[Moderator Deleted] Shocked
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13049
Location: Behind The Reset Button

PostPosted: Sat Oct 29, 2011 14:13    Post subject: Reply with quote
I enabled logging... below is the log.. I snipped out a bunch of data from where the users.txt file is read:

Code:

2011-10-29 09:04:49: ============== STARTING BW MONITOR ==============
2011-10-29 09:04:49: Assign Configuration and setup defaults
2011-10-29 09:04:49: Using custom users file
2011-10-29 09:04:49: ***hasUserFileChanged***
2011-10-29 09:04:49: Has Changed = 1
2011-10-29 09:04:49: ***generateSecureClient***

2011-10-29 09:04:51:  CONFIGURATION
------CONSTANTS-------
CHAIN_RULE=BWMON
CONNECTED_USERS_FILE = /proc/net/arp
LAN_IFACE = nvram get lan_ifname
DNSMASQ_TEMP_FILE_PATH = /tmp/dnsmasq2users.file
DEFAULT_USAGE_FILE_PATH = /tmp/mac_usage.db
JAVASCRIPT_FILE_NAME = user_details.js
------CONFIGURATION-------
Interval Update = 30
Publish Iteration = 3
Backup Iteration = 30
Reset Day = 1
User File Path = /opt/bw_monitor/users.txt
Backup Usage File Path = /opt/bw_monitor/mac_usage.backup
Backup History Path = /opt/bw_monitor/history/
MAC Usage File Path = /opt/bw_monitor/mac_usage.db
Javascript Output Path = /www/user/
Do Usage File Restore = 1
Keep Last Javascript File = 1
History Javascript File = 1
Record Daily Usage = 1
Auto Add MAC Addresses = 1
Add 32 Bit Support = 0
Show MAC = 1

2011-10-29 09:04:51: Checking IPs and iptables
2011-10-29 09:04:51: Main Controller
2011-10-29 09:05:21: ***updateUsage***
2011-10-29 09:05:21: IPTABLES DATA
Chain BWMON (1 references)
    pkts      bytes target     prot opt in     out     source               destination         
       2       80 RETURN     0    --  *      *       192.168.254.160      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.160     
      15     1070 RETURN     0    --  *      *       192.168.254.161      0.0.0.0/0           
      15     2532 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.161     
       6      359 RETURN     0    --  *      *       192.168.254.39       0.0.0.0/0           
       1      154 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.39     
Zeroing chain `BWMON'

2011-10-29 09:05:52: ***updateUsage***
2011-10-29 09:05:52: IPTABLES DATA
Chain BWMON (1 references)
    pkts      bytes target     prot opt in     out     source               destination         
      14      560 RETURN     0    --  *      *       192.168.254.121      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.121     
       0        0 RETURN     0    --  *      *       192.168.254.160      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.160     
       0        0 RETURN     0    --  *      *       192.168.254.161      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.161     
       7      418 RETURN     0    --  *      *       192.168.254.39       0.0.0.0/0           
       2      308 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.39     
Zeroing chain `BWMON'

2011-10-29 09:06:23: ***updateUsage***
2011-10-29 09:06:23: IPTABLES DATA
Chain BWMON (1 references)
    pkts      bytes target     prot opt in     out     source               destination         
       0        0 RETURN     0    --  *      *       192.168.254.121      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.121     
       0        0 RETURN     0    --  *      *       192.168.254.160      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.160     
       0        0 RETURN     0    --  *      *       192.168.254.161      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.161     
       5      299 RETURN     0    --  *      *       192.168.254.39       0.0.0.0/0           
       1      154 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.39     
Zeroing chain `BWMON'

2011-10-29 09:06:24: ***publishUsage***
2011-10-29 09:06:24: ***updateJavascript***
2011-10-29 09:07:01: ***updateUsage***
2011-10-29 09:07:01: IPTABLES DATA
Chain BWMON (1 references)
    pkts      bytes target     prot opt in     out     source               destination         
       0        0 RETURN     0    --  *      *       192.168.254.121      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.121     
       0        0 RETURN     0    --  *      *       192.168.254.160      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.160     
       0        0 RETURN     0    --  *      *       192.168.254.161      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.161     
       8      478 RETURN     0    --  *      *       192.168.254.39       0.0.0.0/0           
       2      308 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.39     
Zeroing chain `BWMON'

2011-10-29 09:07:31: ***updateUsage***
2011-10-29 09:07:31: IPTABLES DATA
Chain BWMON (1 references)
    pkts      bytes target     prot opt in     out     source               destination         
       0        0 RETURN     0    --  *      *       192.168.254.121      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.121     
       0        0 RETURN     0    --  *      *       192.168.254.160      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.160     
       0        0 RETURN     0    --  *      *       192.168.254.161      0.0.0.0/0           
       0        0 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.161     
       6      358 RETURN     0    --  *      *       192.168.254.39       0.0.0.0/0           
       2      276 RETURN     0    --  *      *       0.0.0.0/0            192.168.254.39     
Zeroing chain `BWMON'



Can anyone see the problem??

_________________
[Moderator Deleted] Shocked
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sat Oct 29, 2011 17:38    Post subject: Reply with quote
Did you input the correct IP address in /www/user/monitor.html?
_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13049
Location: Behind The Reset Button

PostPosted: Sat Oct 29, 2011 17:43    Post subject: Reply with quote
Dark_Shadow wrote:
Did you input the correct IP address in /www/user/monitor.html?


that would be 192.168.254.1.. yep..

_________________
[Moderator Deleted] Shocked
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sat Oct 29, 2011 17:47    Post subject: Reply with quote
barryware wrote:
Dark_Shadow wrote:
Did you input the correct IP address in /www/user/monitor.html?


that would be 192.168.254.1.. yep..
Only thing I can see is that your script is missing parts of the original script.

Code:
#!/bin/sh
MONITOR_LOCK_FILE=/tmp/monitor-started.lock
MONITOR_STOP_FILE=/tmp/monitor-stop
MONITOR_STOPPED_FILE=/tmp/monitor-stopped
while [ ! -f $MONITOR_LOCK_FILE ] && [ ! -f $MONITOR_STOP_FILE ]; do
        if [ ! -f /[WWW DIR]/monitor.html ]; then
                sed 's/src=.*>/src="http:\/\/192.168.1.1\/user\/user_details.js"><\/script>/' /[DIR]/monitor.html > /[WWW DIR]/monitor.html
        fi
        /[DIR]/bw_monitor.sh 30 3 30 4 [USER FILE] [DIR]/[USAGE BACKUP FILE] [HISTORY DIR] '' '' 1 0 0 0 1 0 0 [DIR]/[LOG FILE]
        if [ ! -f $MONITOR_LOCK_FILE ]; then
                sleep 10
        fi
done

_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13049
Location: Behind The Reset Button

PostPosted: Sat Oct 29, 2011 17:56    Post subject: Reply with quote
Dark_Shadow wrote:
barryware wrote:
Dark_Shadow wrote:
Did you input the correct IP address in /www/user/monitor.html?


that would be 192.168.254.1.. yep..
Only thing I can see is that your script is missing parts of the original script.

Code:
#!/bin/sh
MONITOR_LOCK_FILE=/tmp/monitor-started.lock
MONITOR_STOP_FILE=/tmp/monitor-stop
MONITOR_STOPPED_FILE=/tmp/monitor-stopped
while [ ! -f $MONITOR_LOCK_FILE ] && [ ! -f $MONITOR_STOP_FILE ]; do
        if [ ! -f /[WWW DIR]/monitor.html ]; then
                sed 's/src=.*>/src="http:\/\/192.168.1.1\/user\/user_details.js"><\/script>/' /[DIR]/monitor.html > /[WWW DIR]/monitor.html
        fi
        /[DIR]/bw_monitor.sh 30 3 30 4 [USER FILE] [DIR]/[USAGE BACKUP FILE] [HISTORY DIR] '' '' 1 0 0 0 1 0 0 [DIR]/[LOG FILE]
        if [ ! -f $MONITOR_LOCK_FILE ]; then
                sleep 10
        fi
done


I didn't define a couple of things.. if you look at my script, I just hard coded a couple of things (MONITOR_LOCK_FILE=)I just hard coded the file into the while statement.

All the files exist.. All are being populated. The only problem is that the html page is not reading the data. The .js file is in the same folder as the html file and has fresh data in it..

I've been dicking with this for hours & hours (collectively over the last few days) I see no reason it isn't working.. I still get the same errors as posted when I bring up the monitor.html page.

_________________
[Moderator Deleted] Shocked
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sat Oct 29, 2011 22:15    Post subject: Reply with quote
@FezJay,

Is there a way to lower the font size or make the page narrower? I have it embedded in my page, but its a little wide for the theme.


_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki


Last edited by Dark_Shadow on Sat Nov 19, 2011 19:31; edited 1 time in total
FezJay
DD-WRT User


Joined: 11 Sep 2010
Posts: 178

PostPosted: Sun Oct 30, 2011 11:20    Post subject: Reply with quote
barryware wrote:
Dark_Shadow wrote:
What paths did you mess up? I have it setup but the page is not populated.


Well.. I spoke too soon. The app runs and the files get put in tmp and they get populated but the monitor.html file does not run.

I get the page, but there is no data..
.
.
.
The page also reports errors. I can't bring it up right now but something about "users" is not defined.

I'm using IE for the browser



Are you using https to browse to the router configuration?

If you are using https and the javascript file is being referenced via http (which it is), you may run into a few security issues.

Is the user_details.js file being populated? Does it have numbers and reading etc?

If it does, then it means that page is unable to load or reference the js file (probably because there are 2 different protocols being used https and http).

If the user_details.js file is not being populated properly (no readings or user array is empty), then I would say that your users.file (your custom file) contains invalid characters or it is not meeting specifications.

Try those for now and see how it goes.

_________________
dd-wrt eko/V24-K26 15508
Belkin F7D4301
8MB Flash
64MB RAM

Optware (jffs/mnt) 4GB Flash Drive
Goto page Previous  1, 2, 3 ... 25, 26, 27 ... 40, 41, 42  Next Display posts from previous:    Page 26 of 42
Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> Broadcom SoC based Hardware 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 can attach files in this forum
You can download files in this forum