dd-wrt - Bandwidth Usage Monitor

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


Joined: 07 Oct 2010
Posts: 180

PostPosted: Fri Apr 12, 2013 19:14    Post subject: Reply with quote
orionshock wrote:
Aight... I have version 2 of the monitor file i wrote. This time with graphs and more magic


I decided to take a peek at your new script/page, and compare my various other files to the latest to see if I was behind on anything.
It's all working great *except* the "Monthly Breakdown" list/graph. That displays nothing at all. The other lists/graphs are working fine though.
Any ideas why that may be? So I need to wait a few days for them to show up? I have a couple of weeks worth of data in user_details.js.
I don't know enough javascript to troubleshoot.

Brad.

Edit: Semi-fixed. At the very bottom of OrionView.js there's a line "var _resetDay = undefined", which causes the test in setMonthlyBreakdown to throw an exception out of the function. Also, I tweaked my bw_monitor.sh to pass in a variable, but I mistakenly called it "resetDay" (no underscore). Fixing those two things caused it to work.
The next problem is the userIndex/hostIndex part isn't being calculated quite right. The table changes when I change selections, but the numbers don't match the selection. Working on that next.

Edit 2: Fixed that too. In some parts you're sorting the user list (by ID), but not when populating the MonthlyBreak dropdown. I changed that code to this:

Code:

$(document).ready(function ()
{
  var monthlyBreakSelect = $("#GlobalSettings_MonthlyBreak");
  users.sort(nestedNameSortOnID);
  $.each(users, function (userIndex, userUsage) {
    userUsage.userUsage.sort(nestedNameSortOnID);
    monthlyBreakSelect.append($("<option/>", { value: userUsage.ID, text: userUsage.ID + "  (User)", "data-userIndex": userIndex }));
    $.each(userUsage.userUsage, function (hostIndex, currentHost) {
      monthlyBreakSelect.append($("<option/>", { value: currentHost.ID, text: currentHost.ID + "  (Host)", "data-userIndex": userIndex, "data-hostIndex": hostIndex }));
    });
  });

which put the dropdown in line with the other lists.

Now I'm cooking with gas. Cool
Sponsor
bpsmicro
DD-WRT User


Joined: 07 Oct 2010
Posts: 180

PostPosted: Sat Apr 13, 2013 14:13    Post subject: Reply with quote
Since I can't leave well enough alone, I decided to change the chart for the Monthly Breakdown to a column chart, since that seems to make more sense to me for visualization.

In the function setMonthlyBreakdown, I changed the code that fills the chartDataTables to replace the "tot=" part (in two spots) with:

Code:

down = Number(readablizeBytes(dayTable.down, 2)[0]);
up = Number(readablizeBytes(dayTable.up, 2)[0]);
totalByDay.push([ lineDate.getDate().toString(), down, up]);


So the chartDataTables.totalByDay array gets three columns per row instead of two, and just the numeric value for the day of the month.

Then in setupCharts, I replaced the code that sets up the monthlyBreakChartObj with this:

Code:

data = new google.visualization.DataTable();
data.addColumn('string', 'Day');
data.addColumn('number', 'MB Down');
data.addColumn('number', 'MB Up');
data.addRows(chartDataTables.totalByDay);
var baroptions = {
  title: 'Monthly Breakdown By Day for User/Host',
  legend: {position: 'none'},
  chartArea: {width: '80%', height: '80%'},
  isStacked: true,
  hAxis: {slantedText: false, titleTextStyle: {color: 'green'}},
  vAxis: {title: 'MB', titleTextStyle: {color: 'green'}},
  series: {0:{color: 'blue', visibleInLegend: false}, 1:{color: 'orange', visibleInLegend: false}}
};
monthlyBreakChartObj = monthlyBreakChartObj || new google.visualization.ColumnChart(document.getElementById('SECTION_MONTHLY_BREAKDOWN_GRAPH'));
monthlyBreakChartObj.draw(data, baroptions);


The results will look something like the attached.

Brad.



MonthlyChart.PNG
 Description:
 Filesize:  11.62 KB
 Viewed:  15523 Time(s)

MonthlyChart.PNG


bpsmicro
DD-WRT User


Joined: 07 Oct 2010
Posts: 180

PostPosted: Sun Apr 14, 2013 21:27    Post subject: Reply with quote
One of the things I'd like to do is display the last update time on the usage page.

I found that modifying the reloadJavascript() method thusly:

Code:

outputString="_todaysDay=$today"'; var users=[]; _supportBit32='"$_supportBit32"'; _resetDay='"$_resetDay"';'
lastUpdate=$(date +"%F %T")
outputString="$outputString ""_lastUpdate='""$lastUpdate""';"


Added _lastUpdate with the time quoted when the user_details.js file was initially created. And I figured out how to display that on the page.
The problem is, intermediate updates are done via the updateJavascript() method, which uses a magic incantation (to me, anyway) of greps & seds to replace the data.

That's where I'm definitely stuck. I'm sure there must be a similar sed incantation to replace my _lastUpdate= value, but that one's beyond me.

Advice?
al_c
DD-WRT Guru


Joined: 13 Apr 2013
Posts: 2134
Location: Ottawa Canada

PostPosted: Sat Apr 20, 2013 12:11    Post subject: orionshock HTML results page Reply with quote
@bpsmicro,@orionshock

For orionshock, in particular, do you have a repository for your modified outputs?

I'd like to tweak it a bit further but wanted to start with the latest version?

Thanks!

Al
bpsmicro
DD-WRT User


Joined: 07 Oct 2010
Posts: 180

PostPosted: Sat Apr 20, 2013 12:16    Post subject: Reply with quote
I've gotten mine working pretty much exactly the way I want, but I had to tweak the actual shell slightly too. I'll compile some notes on exactly what I did and post my version of the files soon. Fezjay can pick & choose what he wants to put in the "official" releases. Smile

Brad.
al_c
DD-WRT Guru


Joined: 13 Apr 2013
Posts: 2134
Location: Ottawa Canada

PostPosted: Tue Apr 23, 2013 16:03    Post subject: I've tweak the OrionView outputs too Reply with quote
I want to start by saying a really big thank you to FezJay, Orionshock, bpsmicro and everyone else who has worked on this code. I can see who is downloading how much on my home network now. (The next step is to understand why my ISP's numbers are so different from mine but that is a completely different thread.)

I made a bunch of changes to the OrionView page... the biggest/most obvious being displaying the previous sections of the documment in tabs. Of course, this meant changes within the HTML, CSS & JavaScript files.

I also made minor changes in bw_monitor.sh so that the reset day is saved into the user_details.js file; and, added a new optional parameter for the bandwidth capacity and this value is also written to user_details.js

All of the updated files are included in the attached zip files. Just expand them in the usual spot (I've included an updated bw_monitor.startup script that copies all of the files to tmp/www (in the event that your router reboots)

I'm aware of two bugs at the moment
1. in the monthly breakdown graph, my dates are listed in descending order, and
2. the totals for two of my devices are swapped in the monthly breakdown table

There are also a few tweaks that I'd like to add in the near future (see the to-do tab).

Let me know what you think...



Internet Usage Statistics.png
 Description:
 Filesize:  46.3 KB
 Viewed:  15228 Time(s)

Internet Usage Statistics.png



OrionView v1.1.zip
 Description:

Download
 Filename:  OrionView v1.1.zip
 Filesize:  17.65 KB
 Downloaded:  822 Time(s)

al_c
DD-WRT Guru


Joined: 13 Apr 2013
Posts: 2134
Location: Ottawa Canada

PostPosted: Wed Apr 24, 2013 16:17    Post subject: Auto added entires sometimes have a Mac Address of 00:00...? Reply with quote
I've found that on my network occasionally a new device is auto-added and is recorded as having a mac address of 00:00:00:00:00:00

When I go into my users.file, I find an entry something like:
00:00:00:00:00:00,192.168.1.105,00:00:00:00:00:00,Auto-Added

It's easy enough to get the proper mac address,etc. (from the IP address) so that the users.file entry can be corrected but that still leaves funky data in user_details.js (and therefore also in the reports)

Has anyone else noticed this? Any idea why it is occurring?

Thanks!

Al
bpsmicro
DD-WRT User


Joined: 07 Oct 2010
Posts: 180

PostPosted: Wed Apr 24, 2013 16:21    Post subject: Reply with quote
Yeah, I see that too. It's a bit weird but I haven't looked deeper into it.
Culex
DD-WRT Novice


Joined: 26 Apr 2013
Posts: 4

PostPosted: Fri Apr 26, 2013 2:48    Post subject: Reply with quote
Quote:
When I go into my users.file, I find an entry something like:
00:00:00:00:00:00,192.168.1.105,00:00:00:00:00:00,Auto-Added
I'm seeing it in my dnsmasq2users.file too. It's the last entry, is that the same for you?

Code:
F0:4F:7C:4C:39:40,192.168.1.131,Mom,KindleFire
00:21:29:65:C0:A5,192.168.1.150,Dad,Garage
00:00:00:00:00:00,192.168.1.131,System,Auto-Added
That is the only entry. I don't know why. Perhaps have error checking code to ignore invalid mac address.

However, in my mac_usage.db
Code:
00:00:00:00:00:00,192.168.1.140,3668,1990,22
00:00:00:00:00:00,192.168.1.100,196415,2655,23
00:00:00:00:00:00,192.168.1.100,167132,374,24
00:00:00:00:00:00,192.168.1.100,32435,0,25
00:24:1D:83:63:80,192.168.1.100,4686847120,67990770,25

I've ommited ips in between, but 00 comes before the real macid with the rest of the information, but the webpage will show 0 bytes. Atleast the information is getting collecting.

Where is it getting the value 00:00:00:00:00:00?

Also I noticed in my BWMON chain,
Code:
RETURN     0    --  169.254.158.76       anywhere
RETURN     0    --  anywhere             169.254.158.76

uhm, why.
Culex
DD-WRT Novice


Joined: 26 Apr 2013
Posts: 4

PostPosted: Sun Apr 28, 2013 20:53    Post subject: Reply with quote
It would be really awesome to:

1.)check the bandwidth total per mac for the month
2.)compare with predetermined limit
3.)if over execute barebone function - admins can fill in for their own purpose, ie iptables and/or tc commands, send email notices. etc.

If someone could show me how to do the 1st part w/ 2 vars like $mac and $totalusage then I should be able to figure out the rest.
johnw230873
DD-WRT Novice


Joined: 24 Jan 2012
Posts: 23

PostPosted: Sat May 04, 2013 20:38    Post subject: Reply with quote
Al_c I was trying out your new reporting page but have run into a few issues.
I noticed that in the startup script it wasn't reading the correct html file and changed
sed -e 's/src=.*>/src="http:\/\/192.168.1.1\/user\/user_details.js"><\/script>/' /opt/monitor/setup/monitor.html > /tmp/www/monitor.html

to
sed -e 's/src=.*>/src="http:\/\/192.168.1.1\/user\/user_details.js"><\/script>/' /opt/monitor/setup/
OrionView-v1.1.html > /tmp/www/monitor.html


Which gives me a weebpage but the js still doesn't seem to be working, any ideas, I wondering if it is due to the reference path not being the ip of the router?
al_c
DD-WRT Guru


Joined: 13 Apr 2013
Posts: 2134
Location: Ottawa Canada

PostPosted: Fri May 17, 2013 18:53    Post subject: Reply with quote
John - sorry, I've been away from the forum for a couple of days and missed your message.

The change you suggested below is actually unnecessary (as I'm no longer using the monitor.html file at all).

When the startup script is run, do the '*-v1.1.*' files get copied over to /tmp/www/ ? (i.e., OrionView-v1.1.html, OrionView-v1.1.js, OrionView-v1.1.css)

I'm not an shell expert by any stretch of the imagination. It could be that the script is crapping out because /opt/montior/setup/monitor.html does not exist on your machine... I probably have it kicking around from before my changes. If you do not have that file, try deleting or commenting out the line.

If the files do get copied over, what page are you opening? It should be http://<router_ip>/user/OrionView-v1.1.html

What does the page display? Anything at all?

Let me know if this helps at all


Again sorry for not seeing this sooner.
al_c
DD-WRT Guru


Joined: 13 Apr 2013
Posts: 2134
Location: Ottawa Canada

PostPosted: Fri May 17, 2013 19:36    Post subject: what if argument #14 is set to 0? Reply with quote
From the argument descriptions:
Arg 14->Auto Add MACS(Optional): Indicates if the system to auto add MAC addresses that do not exist in the users file. Default is 1 (yes)

If you set this value to 0, will it prevent the problem? However it means that you'll have to edit your users.file as new devices appear on your router.

[I'm also looking into the bw_monitor.sh code and I'm tempted to add an if statement that checks the value of the MAC address prior to inserting it into users.file.]

Last but not least, I did find a reference to an old defect (#0000683) with the following description:
0000683 [DD-WRT v23] Router (WAN) MAC set to 00:00:00:00:00:00 when 'Connect on Demand' selected - SP1 (01/27/06)
But it appears this defect was resolved 7 years ago???

Culex wrote:
Quote:
When I go into my users.file, I find an entry something like:
00:00:00:00:00:00,192.168.1.105,00:00:00:00:00:00,Auto-Added
I'm seeing it in my dnsmasq2users.file too. It's the last entry, is that the same for you?

Code:
F0:4F:7C:4C:39:40,192.168.1.131,Mom,KindleFire
00:21:29:65:C0:A5,192.168.1.150,Dad,Garage
00:00:00:00:00:00,192.168.1.131,System,Auto-Added
That is the only entry. I don't know why. Perhaps have error checking code to ignore invalid mac address.

However, in my mac_usage.db
Code:
00:00:00:00:00:00,192.168.1.140,3668,1990,22
00:00:00:00:00:00,192.168.1.100,196415,2655,23
00:00:00:00:00:00,192.168.1.100,167132,374,24
00:00:00:00:00:00,192.168.1.100,32435,0,25
00:24:1D:83:63:80,192.168.1.100,4686847120,67990770,25

I've ommited ips in between, but 00 comes before the real macid with the rest of the information, but the webpage will show 0 bytes. Atleast the information is getting collecting.

Where is it getting the value 00:00:00:00:00:00?

Also I noticed in my BWMON chain,
Code:
RETURN     0    --  169.254.158.76       anywhere
RETURN     0    --  anywhere             169.254.158.76

uhm, why.
ericd
DD-WRT Novice


Joined: 08 May 2013
Posts: 4

PostPosted: Sun May 19, 2013 17:24    Post subject: problem with date in version 1.3 Reply with quote
Hi FezJay,
I really like your bandwidth monitor!
I installed version 1.3, and it was working perfectly until the second half of this month. The monitoring and db seem to be OK, but when I look at the monitor.html page it shows breakdown for the day 199 instead of 19 and 186 instead of 18 (yesterday). If I telnet to the router and use the date command from the setup instructions, it returns 18 or 19.
Do you have any idea how the date is getting corrupted with the extra digit? I looked through the html, but couldn't identify the cause.
The monthly summaries, and also the table of the days of the month are correct, it is just the current day section that is all zeros with the 199 or 186 date. The day 18 and 19 are correct in the table below with non-zero bandwidth data that looks correct.
Eric
Pamela
DD-WRT Novice


Joined: 21 May 2010
Posts: 35

PostPosted: Wed May 22, 2013 16:40    Post subject: Reply with quote
Hello All,

Much respect to all that kept this code going through the years!
I have MyPage installed but would like to see how this looks on my system.
Would I need to have wrtbwmon installed before installing the OrionView v1.1?

Where would I put the OrionView files?

T.I.A.

_________________
~Router Listing~
Linksys E1550- Firmware v24-sp2 (04/07/12) std-usb-nas - build 18946M NEWD-2 K2.6 Eko + OTRW2
Goto page Previous  1, 2, 3 ... 33, 34, 35 ... 40, 41, 42  Next Display posts from previous:    Page 34 of 42
Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum 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