I have made all the fixes and changes that have been discussed recently.
I have put both commands in to determine the next day. What the following does is attempt the first command, if that fails, then the next command will be executed.
If they both fail, well, find a language that eloquently says your fucked lol (jks ). You may need to get a package down.
Code Snippet
Code:
nextDay=`expr $(date --date='next day' +"%d") '*' 1`
if [ $? -ne 0 ]; then
#Attempt another way to determine the next day
nextDay=`expr $(TZ=MST-24 date +%d) '*' 1`
fi
Code:
checkReset()
{
#(24 Hours * 60 * 60)-1 = 86400
#(Hour * 60 * 60) + (Minute * 60) + Seconds
secondsUntilNextDay=`expr $(expr $(date +%H) '*' 60 '*' 60) + $(expr $(date +%M) '*' 60) + $(expr $(date +%S))`
secondsUntilNextDay=`expr 86400 - $secondsUntilNextDay`
#Determine next day number and force to numeric
nextDay=`expr $(date --date='next day' +"%d") '*' 1`
if [ $? -ne 0 ]; then
#Attempt another way to determine the next day
nextDay=`expr $(TZ=MST-24 date +%d) '*' 1`
fi
#Determine if next day will be reached before or after update (allow 20 second buffer)
secondsWithUpdateUntilNextDay=`expr $(expr $secondsUntilNextDay - $_intervalUpdate) - 20`
#force reset day to numeric
resetDay=`expr $_resetDay '*' 1`
if [ $nextDay -eq $resetDay ] && [ $secondsWithUpdateUntilNextDay -le 0 ]; then
#wait until next day
currentDay=`expr $(date +%d) '*' 1`
while [ $currentDay -ne $resetDay ]; do
sleep 1
currentDay=`expr $(date +%d) '*' 1`
done
sleep 5
resetUsage
fi
}
I have checked this into the trunk version ONLY.
Only once it is completely tested, will I create a new major version 1.2 and make that available.
Joined: 26 Jan 2008 Posts: 13049 Location: Behind The Reset Button
Posted: Sat Oct 22, 2011 22:17 Post subject:
Dark_Shadow wrote:
Are there basic instructions for installing this?
Ditto... I've read & printed the documentation..
I have the original version installed and working..
RT-N16 installed on a usb mem stick mounted to /opt. Mypage brings up the bandwidth gui.
Been messing with this (newest version.. 1.1) all day and I can't get the new version to work.
The current (old) version is located in /opt/www/ and works great but it seems that the monitored clients are limited to 10 and the new version (based on screen shots) has much more detail.
The IP of the router is 192.168.254.1. I have edited the files to reflect the host ip..
The needed edits are confusing because of the diff colors in the samples.. What colors can / need to be edited for my (our) config?
I just can't get it to go.. _________________ [Moderator Deleted]
The hard part of the installation is making sure you have the right packages and secondly knowing a little bit about storage (usb or wget etc)
The main setup calls are from the bw_monitor.startup script file.
In this file you indicate where your files are (backups, bw_monitor.sh), and where you configure the actual bw_moinitor.sh script (intervals etc).
This all works fine if you have perm storage (USB etc), but things get a bit tricky but not impossible if you dont have USB.
As I have mentioned online, all you need to do is download the required files (scripts, html, backups) to tmp, rename them and then execute the bw_monitor.startup command pointing to the downloaded files.
This can be achieved by running them as a startup script (copy and past the contents from the bw_mointor.startup file into a startup script).
2. Save file to /tmp (renamed to with prefix '_stored_[name of file])
3. chmod +x script file (bw_monitor.sh)
4. bw_monitor.starup script contents copied and here (need to modify directories to point to tmp and point at renamed files)
As you can see, things are easier if you have USB storage and optware installed (you can use optwares startup script folders /opt/etc/init.d)
This does mean you need a little bit of linux dd-wrt know how (I had absolutely none when I began this script). _________________ dd-wrt eko/V24-K26 15508
Belkin F7D4301
8MB Flash
64MB RAM
Well YEA!!!... That is the doc I printed. I think I got the scripts loaded in the wrong folder.. Not wrong as long as you make the necessary edits to point to the correct folder(s).. This I think is my problem.. I'll get it.. Not scared.. _________________ [Moderator Deleted]
Joined: 31 Aug 2009 Posts: 2448 Location: Third Rock from the Sun
Posted: Sun Oct 23, 2011 12:49 Post subject:
My biggest problem is that the setup instructions are vague, for example...
Quote:
One way is to use persistant storage, such as flash drive or somthing similar (samba, jffs etc)
Downlaod the bw_monitor.sh script and save it
chmod +x the script. This makes it executable
Download the monitor.html file
Create and modify the below script and save it as a startup or a wanup script (this is described in detail in the Startup/Wanup Scripts section below):
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
it says to modify this script. What exactly is supposed to be modified? All in brackets? Only where it say "DIR"? _________________ Peacock Thread-FAQ -- dd-wrt Wiki
This is my startup script (Which I run from optware's init.d folder)
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 /tmp/www/monitor.html ]; then
sed 's/src=.*>/src="http:\/\/192.168.1.1\/user\/user_details.js"><\/script>/' /mnt/monitor/setup/monitor.html > /tmp/www/monitor.html
fi
/mnt/monitor/setup/bw_monitor.sh 30 3 30 4 /tmp/dnsmasq.conf /mnt/monitor/mac_usage.backup /mnt/monitor/history/ /tmp/mac_usage.db '' 1 1 1 1 1 0 1 ''
if [ ! -f $MONITOR_LOCK_FILE ]; then
sleep 10
fi
done &
The one thing that you should add to your script is the last '&' after 'done'.
This will basically allow this part of the script to run without preventing other startup services from running.
e.g.
while []; do
... CODE etc
done &
The reason I bring this up is because some people have noticed that the script will try to run before certain services are ready, like external drives.
The other approach is to put a 10 second sleep before execution. _________________ dd-wrt eko/V24-K26 15508
Belkin F7D4301
8MB Flash
64MB RAM