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 ... 16, 17, 18 ... 40, 41, 42  Next
Author Message
Caddish
DD-WRT Novice


Joined: 28 Jun 2010
Posts: 15

PostPosted: Thu Apr 21, 2011 15:30    Post subject: Reply with quote
Done, changed the value for getUsageDisplay to 3, toFixed(2), return '0.00' (line ~23 to 30 of the html):
Code:
if (bytes <= 0)
   return '0.00 ' + getUsageDisplay(3);
 
var e = 3;
   var suffix = " " + getUsageDisplay(e);
   if(_useSuffix || _useSuffix != "") { e = _useSuffix; suffix = ''}
         
return (bytes / Math.pow(_baseSelect, Math.floor(e))).toFixed(2) + suffix;


Now all I miss is a graph of the daily breakdown
Sponsor
FezJay
DD-WRT User


Joined: 11 Sep 2010
Posts: 178

PostPosted: Sat Apr 23, 2011 1:24    Post subject: Reply with quote
Caddish wrote:
Finally made it work, love it.

Though how hard would it be to show every number in GB (I'm searching for abuser so I don't really care about bytes) and right aligned to be easier to read (I have zero html experience though I'm fairly good with VBA and C#)?

Also would it be feasible to start the "Monthly Usage - Daily Breakdown" section with the reset day instead of the 1st day


Try this...

monitor.html?usageDay=23&baseSelected=1000&useSuffixIndex=3


3 - Is for GB's

A

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

Optware (jffs/mnt) 4GB Flash Drive
Caddish
DD-WRT Novice


Joined: 28 Jun 2010
Posts: 15

PostPosted: Sat Apr 23, 2011 2:55    Post subject: Reply with quote
Oh that's how to use this argument , I tryed to GB instead of 3 then I tryed 1 and it worked so I thought it was boolean. By the way instead of writing 0GB I replaced it by a "-" and it's much cleaner and easier to get to the important number
FezJay
DD-WRT User


Joined: 11 Sep 2010
Posts: 178

PostPosted: Sat Apr 23, 2011 11:48    Post subject: Reply with quote
Caddish wrote:
Done, changed the value for getUsageDisplay to 3, toFixed(2), return '0.00' (line ~23 to 30 of the html):
Code:
if (bytes <= 0)
   return '0.00 ' + getUsageDisplay(3);
 
var e = 3;
   var suffix = " " + getUsageDisplay(e);
   if(_useSuffix || _useSuffix != "") { e = _useSuffix; suffix = ''}
         
return (bytes / Math.pow(_baseSelect, Math.floor(e))).toFixed(2) + suffix;


Now all I miss is a graph of the daily breakdown


LOL, yeah Graphs...I would love to, but ideally I'd like to use Jquery for it. Makes things so much easier man.

Got to keep in mind though, people have different routers with different specs, gt to try and keep things simple.

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

Optware (jffs/mnt) 4GB Flash Drive
ozdma@yahoo.com
DD-WRT Novice


Joined: 25 Apr 2011
Posts: 2

PostPosted: Mon Apr 25, 2011 23:05    Post subject: Reply with quote
Hi All,

I'm semi-technical, so please bear with me...

I loved the opening post and then waded through a few pages of technical posts and my eyes glazed over...

The reports posted at the beginning seem to do exactly what I what I want - to segregate usage by user and produce simple information.

We are trying to find out where the excess usage is coming from as the usage counters on each computer don't add up to the total on the ISP website - sometimes with hundreds of MB difference... Last month, we are slowed to a crawl for 5 days and I work from home - ugh. There are a few other items around the house like jailbroken ipods/smart phones etc. that may be doing some auto updating (and for which I can't find bandwidth utilities) or it may be something stealthy running on someone's computer (I have removeed that %#$#^@%$# PC Tools app from computers a couple of times recently. Grrrr....) Wink

A few questions:

1. Is the link to google code at the beginning of these posts the current version?
2. It appears that you're running a program on the router with some nice reporting and segregating usage by mac address with some rolling up/summarizing of numbers. Do I understand that correctly?
3. Are you currently making updates to a "released" software or are you still in alpha/beta test right now?

I'm technical enough to have installed dd-wrt, but since the last time I opened up a unix command line was 1985 (LOL - with the exception of the dd-wrt install, it's true!)

I am looking for something that's relatively simple. I don't have a spare computer to run a remote reporting setup as described elsewhere on the BB.

My setup:
---------
Linksys WRT-54G
DD-WRT v24-sp2 (10/10/09) micro

Your input would be greatly appreciated and thanks in advance!

Cheers,

D
FezJay
DD-WRT User


Joined: 11 Sep 2010
Posts: 178

PostPosted: Thu Apr 28, 2011 9:48    Post subject: Reply with quote
Hey ozdma

I think you are in luck, a user with your router has got it going on his router and fortuantly has left his script Wink, which I have included below

Its all on page 14-17 as well. Hope it helps


UPDATE (Muz)

have gotten both wrtbwmon AND bw_monitor to work.

have also managed to install optware in the process.

here's the startup script:

#!/bin/sh

sleep 5
if [ -f /mnt/optware.enable ]; then
mount -o bind /mnt/etc /etc
mount -o bind /mnt/root /tmp/root
mount -o bind /mnt/opt /opt
else
exit
fi

if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
else
exit
fi

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

sleep 10

# Backup usage database file
while :
do
sleep 900
cp /tmp/usage.db /mnt/usage.db
done

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

Optware (jffs/mnt) 4GB Flash Drive
kublai
DD-WRT User


Joined: 03 Mar 2007
Posts: 111

PostPosted: Thu Apr 28, 2011 14:54    Post subject: Reply with quote
I am a bit confused about this. I want everything to run off my external usb drive on /opt
1. I have an external usb drive mounted on /opt
2. I have downloaded the 4 scripts (bw_monitor.sh, bw_monitor.shutdown, bw_monitor.startup, monitor.html) do I put all 4 in /opt/etc/init.d?
3. do I copy your script below and name bw_monitor.startup and use the bw_monitor.shutdown as the shutdown script?
4. I also have a oidentd script in my startup so can I append that? bloew is my script currently
#!/bin/sh
start oidentd
/opt/etc/init.d/oidentd start
#
5. How do I load the startup and shutdown scripts?
munzab wrote:
UPDATE

have gotten both wrtbwmon AND bw_monitor to work.

have also managed to install optware in the process.

here's the startup script:

#!/bin/sh

sleep 5
if [ -f /mnt/optware.enable ]; then
mount -o bind /mnt/etc /etc
mount -o bind /mnt/root /tmp/root
mount -o bind /mnt/opt /opt
else
exit
fi

if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
else
exit
fi

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

sleep 10

# Load database
cp /mnt/usage.db /tmp/usage.db

# Bandwidth Download/Upload Rate Counter
while :
do
/mnt/wrtbwmon setup
/mnt/wrtbwmon read
sleep 9
/mnt/wrtbwmon update /tmp/usage.db
/mnt/wrtbwmon publish /tmp/usage.db /tmp/www/usage.html /mnt/macip.txt
done &

# Backup usage database file
while :
do
sleep 900
cp /tmp/usage.db /mnt/usage.db
done



fantastic job fezjay, great script. no more leeching anonymously.


the only thing i needed to change was the dnsmasq.conf to my own users.txt as it would not recognise anything from the dnsmasq.


cheers
orionshock
DD-WRT Novice


Joined: 29 Apr 2011
Posts: 45

PostPosted: Fri Apr 29, 2011 9:20    Post subject: :?: Reply with quote
HELP PLEASE :: 17 pages later and still dumb...

ok.. Got OptWare installed and working.
I'd like all files being thought of created in /mnt/monitor

I don't have any IP's statically assinged via DNSMasq.

For clarity what i'd like settings :
Update Every 30 sec
Publish every 4 Updates
Backup every 30
Reset Every day
UserFile : /mnt/monitor/user.file
BackupUseage : /mnt/monitor/useage.backup ( Should this be a dir or file?)
BackupHist : /mnt/monitor/hist (dir)
MacUseageFile : /mnt/monitor/mac_useage.db
JSOutput : /mnt/monitor/
Do Usage File Restore : yes
Keep Last Javascript File : Yes
History Javascript File : Yes ( do i need it, what exactly does it benefit me for? )
Record Daily Usage : Yes
Auto Add MAC Addresses : Yes
Add 32 BIT support : ??
Show MAC Addresses : No
LOG : no..

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 /mnt/monitor/monitor.html ]; then
      sed 's/src=.*>/src="http:\/\/192.168.1.1:81\/user\/user_details.js"><\/script>/' /mnt/monitor/monitor.html > /mnt/monitor/monitor.html
   fi
   echo "RunScipt"
   /mnt/monitor/bw_monitor.sh 30 4 30 4 /mnt/monitor/user.file /mnt/monitor/useage.backup /mnt/monitor/hist/ /mnt/monitor/mac_useage.db /mnt/monitor/ 1 1 0 1 1 0 0 NO
   if [ ! -f $MONITOR_LOCK_FILE ]; then
      sleep 10
   fi
done


It's not making a .js file and nothing is showing when viewing the monitor.html file.


-------

If i turn logging on it says that there are no users in the dnsmasq2users file and then exits.

-------
Can i symlink bw_monitor.startup to /opt/etc/init.d/S99bwmon ?
Can i symlink bw_monitor.shutdown to /opt/etc/init.d/K06bwmon ?
orionshock
DD-WRT Novice


Joined: 29 Apr 2011
Posts: 45

PostPosted: Sat Apr 30, 2011 18:26    Post subject: Reply with quote
Update.

OK, solved problem from previous post. made a blank users.file with a all 0's mac and ip. It picked up the rest all ok & it is now working as intended for me Smile

2nd problem, reading though the code and output.. it only monitors 1 bridge "br0". while for the vast majority this works well... i need it to monitor wlan0.1 as well because I'm running a guest network on 192.168.2.1 and those IP's are not part of br0.
munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Sat Apr 30, 2011 23:25    Post subject: Reply with quote
Just a heads up - 1st of may, the monitor did not reset again.

any ideas what to do?
ozdma@yahoo.com
DD-WRT Novice


Joined: 25 Apr 2011
Posts: 2

PostPosted: Sun May 01, 2011 7:02    Post subject: Reply with quote
Many thanks!


FezJay wrote:
Hey ozdma

I think you are in luck, a user with your router has got it going on his router and fortuantly has left his script Wink, which I have included below

Its all on page 14-17 as well. Hope it helps


UPDATE (Muz)

have gotten both wrtbwmon AND bw_monitor to work.

have also managed to install optware in the process.

here's the startup script:

#!/bin/sh

sleep 5
if [ -f /mnt/optware.enable ]; then
mount -o bind /mnt/etc /etc
mount -o bind /mnt/root /tmp/root
mount -o bind /mnt/opt /opt
else
exit
fi

if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
else
exit
fi

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

sleep 10

# Backup usage database file
while :
do
sleep 900
cp /tmp/usage.db /mnt/usage.db
done
Dark_Shadow
DD-WRT Guru


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

PostPosted: Sun May 01, 2011 10:04    Post subject: Reply with quote
I would like to request URL logging per ip/host.
_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
kublai
DD-WRT User


Joined: 03 Mar 2007
Posts: 111

PostPosted: Sun May 01, 2011 15:25    Post subject: Reply with quote
Same for me 1st of month and it didn't reset. I changed the 4th parameter from 4 to 1.

munzab wrote:
Just a heads up - 1st of may, the monitor did not reset again.

any ideas what to do?
orionshock
DD-WRT Novice


Joined: 29 Apr 2011
Posts: 45

PostPosted: Mon May 02, 2011 6:57    Post subject: Reply with quote
@FezJay

Been running the script w/o problems for about a week now.. however the log is spitting up this as of recent.
Not sure if it's recent, but i'll keep an eye out for other things that could be causing it.

Code:


2011-05-01 23:49:40: ***publishUsage***
2011-05-01 23:49:40: ***updateJavascript***
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
2011-05-01 23:50:11: ***updateUsage***
2011-05-01 23:50:11: IPTABLES DATA

munzab
DD-WRT Novice


Joined: 06 Feb 2011
Posts: 29

PostPosted: Mon May 02, 2011 9:12    Post subject: Reply with quote
fezjay, do you know of a way to manually reset the usage data?problem is since it did not reset at the start of the month, it is adding download amount to what was already known, therefore making twice as much being used?


would you have a look at this and let me know if i set it up correctly to reset on the 01 of every month?

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

sleep 10
Goto page Previous  1, 2, 3 ... 16, 17, 18 ... 40, 41, 42  Next Display posts from previous:    Page 17 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