For those who are interesed I created some scripts to do graphical IP accounting on the ASUS. A description and some installation details are on the WikiPage:
GraphicalIpAccounting
Tarballs are attached!
Hope you like it :)
Printable View
For those who are interesed I created some scripts to do graphical IP accounting on the ASUS. A description and some installation details are on the WikiPage:
GraphicalIpAccounting
Tarballs are attached!
Hope you like it :)
*cough* *cough*
I'm sober now...
Good Work, sodb!
Your scripts inspired me to start exploring the world of bash scripts/awk/iptables/etc. And the working model was of great help to start understanding how to deal with these progs.
I found it a nice exercise to adapt the scripts to extend their functionality.
v2 of tarballs are attached.
changes:
- all usage data is stored in relative usage counters instead of absolute iptables counters
- router: counts for in/outbound traffic of the router itself (ftp/http) to the WAN
- other: counts for those LAN ip addresses that are not monitored individually (in my case 192.168.1.17-192.168.1.254)
- introduced 2 new "ip addresses" in the usage logging:
- store all data in a data folder that is set in the init.sh script
- changed structure of data files:
- per ip address:
- hourly usage of today in the file <ip adress>.day.dat
- hourly usage of a earlier day in a file like <ip adress>.20041012.dat
- daily total usage of this and earlier month in a file like <ip adress>.200410.dat
- totals for all completes months up to now in the file <ip adress>.history.dat
- over all ip addresses:
- total usage of today up till now per ip address in the file all.day.dat
- total usage of completed days of this month per ip address in the file all.month.dat
- all history data is being kept and can be shown by web page
- all accounting scripts combined to 1: account_traffic.sh:
- script runs every hour
- script will detect and act to day changes (at midnight)
- script will detect and act to month changes (at midnight, 1st day of month)
- script can be run with parameter "init", "daychange", "mothchange" to force a init of iptable counters, day change or moth change resp.
- changed web pages:
- combined all web pages into 1 --> traffic.cgi
- all presentations done by graphs (no more select boxes etc)
- the bars in the graphs can be clicked to zoom in on details
my scripts depend on awk being found by the system, which you can arrange by the command:
ln -s <your path to busybox full version> /bin/awk
Hope you like it and I am waiting for some comments of you.
Mark
found some small mistakes in the tar files so i updated them in my original posting
@mark.
can i also use the howto from sodb for install?
is there something different if i want to use graphical ip accounting with fw 1.8.xx?
thx in advance...
xelephant,
you certainly can use it with new firmware. Change the mount point in the init.sh script. The wiki page is not describing the scripts that Mark wrote. I installed Mark's scripts with some small changes (e.g. the root crond file is lacking in the tar ball). Using the post of Mark I will update the wiki page so that it describes the latest version,
regards
Hi
I've a Asus WL-500g at home to distribute internet access for 4 computers, 3 Windows PC and 1 Macintosh. We are all students living in the same house.
So here's what I'm searching: I would like to have, at the end of the month, a graphic showing the percentage of every computer's downloads so that each one could pay the ammount according to the internet's use. I'm really new to all this and none of us here at home are familiar with coding.
Is "Graphical IP accounting" is suitable to do what I want? If so, there is any way to run a script automatically without having to type everything by hand?
Thank you in advance and forgive my ignorance
Best Regards
Nuno
I canīt find the installation manual for Mark's ipaccounting. I think that quide which is described on http://wiki.wl500g.info/index.php/GraphicalIpAccounting is still showing installation process for old scripts, isnīt it? Where could I find new installation quide? Iīm beginner in Linux.
- after router restarting is it working again or I will have to run it manualy?
Thanks a lot.
Kamil.
I canīt find installation guide for Mark's scripts. Do anybody have it? I think that the guide on wiki pages is still for older ipaccounting scripts.Quote:
Originally Posted by sodb
What will happend after router restarting? Will I have to start scrips manualy again? And how to dissable scripting? I would like to print via USB port sometimes.
K
That is what post-boot/-firewall/-mount is for.Quote:
What will happend after router restarting? Will I have to start scrips manualy again?
Once you unplug your usb stick, anything on /tmp/harddisk/ is unaccesible and scripts will fail, but no harm is done. If you like you can just stop the crond (killall crond) and then restart it when you plug your stick back in. But the easiest of course is to buy an usb-hub. Then you can have everything pluged in all the time! Not very expensive either.Quote:
And how to dissable scripting? I would like to print via USB port sometimes.
S.
Hello Mark,Quote:
Originally Posted by Mark Koops
I need you help regarding to Graphical IP Accounting V2. I would like to use your vesrion. For installing I used the HOWTO from SODB, but in your tarball I couldnot find the root for crond. I used from V1.
In our wifi site we used Ips with step 10, as 10, 20, 30, 40, 50. In a case of INIT.SH setting I have to use LOWERIP=10 UPPERIP=50, but it takes very long time for ASUS to calculate and to prepare a dat files .. around 70minutes! And the generated HTML pages is very big ... a lot of unused IPs beetween 10-20-30-40-50. There is some possibilities or setting how to meka it little bit faster and how I can select just a used IP-s to HTML generating and accounting?
Thank you
Wizi
Hello,
Mea Culpa .... my fault .... WORKING FINE !!!!!
.............. just found some features, which doesnot works :(
... to get the traffic to the web I had to use eth0
... but still the field OTHERS and ROUTER doesnot calculate the traffic - but the router_in and router_out chains contains data !
... on the web are still missing the HISTORYCAL data, but in history folder the data are ....
can somebody help me?
Thanks a lot, WiZiPoK
Hi together,
I am using Marks script, but traffic is not counted. I think the cause are wrong values in the init.sh. Could someone tell me please what to type in? Here is some inormation about my config.
- My router has LAN adress 192.168.1.1
I do not have a fixed WAN adress
I have clients in the range from 192.168.1.50 to 192.168.1.61
Here is init.sh:
What should I use as WAN address?Code:#directory where accounting scripts reside
accountdir=/tmp/harddisk/accounting
datadir=/tmp/harddisk/accounting/data
# pointer to AWK applet
AWK="/bin/busybox awk"
LAN="192.168.1.1"
WAN="???.???.???.???"
#ipprefix consists of the first 3 number of your
#LAN side ip addres. Together with a 4th number in the
#range lowerip to upperip, it makes the range of ip addresses
#to be monitored in your LAN.
#
#warning: upperip relates to LANMask as:
#ipprefix.upperip is the highest address that fits in ipprefix.0/LANMask
ipprefix="192.168.1"
let lowerip=50
let upperip=61
LANMask=???
What is a LANMask and which value should I use?
Thanks for your help
Thomas
Use ifconfig (ifconfig eth1 | grep inet) to find WAN address, and LAN mask should be 255.255.255.0
B.
I know my actuall Ipadress but is changes every day. So I think i were not very useful to change it every day manually.
255.255.255.0 is the subnet mask. But LANMask seems to be something different. And the example show a value of 28. But what should that be?
Examplescript:
Code:#directory where accounting scripts reside
accountdir=/mnt/usbfs/accounting
datadir=/accountingdata
# pointer to AWK applet
AWK="awk"
LAN="<LAN side ip address of your router>"
WAN="<WAN side ip address of your router>"
#ipprefix consists of the first 3 number of your
#LAN side ip addres. Together with a 4th number in the
#range lowerip to upperip, it makes the range of ip addresses
#to be monitored in your LAN.
#
#warning: upperip relates to LANMask as:
#ipprefix.upperip is the highest address that fits in ipprefix.0/LANMask
ipprefix="192.168.1"
let lowerip=2
let upperip=16
LANMask=28
Well 24 is just another way of saying 255.255.255.0 (32 bits where the 24 first are 1 others are 0) so 28 would translate to 255.255.255.255.240 which means only the 16 first adresses are valid..
You should propably just set it to 24.
B
Hi,
for me the Mark's script starts to calculate when I changed the ETH1 to ETH0 inside add_iptables.sh script, just try it ...
But I couldnot discover why the ROUTER and OTHER strings not contains any traffic :(
WiZiPoK
I have the same problem :-(Quote:
Originally Posted by WiziPok
:confused:
Its still not working. dat files are created but they contain value 0 only :
Could someone post the files "add_iptables.sh" and "init.sh" forWL500gx from a installation that is logging traffic please?Code:06/06/05 23:00 out in
06/06/05 23:13 out in
Thank you so much.
Thomas
Hi, here is my init.sh script
at ADD_IPTABLES everywhere were is ETH1 I changed to ETH0Code:#directory where accounting scripts reside
accountdir=/opt/accounting
datadir=/opt/accounting/data
#pointer to AWK applet
AWK="awk"
LAN="192.168.1.0"
WAN="192.168.0.2"
#ipprefix consists of the first 3 number of your
#LAN side ip addres. Together with a 4th number in the
#range lowerip to upperip, it makes the range of ip addresses
#to be monitored in your LAN.
#
#warning: upperip relates to LANMask as:
#ipprefix.upperip is the highest address that fits in ipprefix.0/LANMask
ipprefix="192.168.1"
let lowerip=9
let upperip=12
LANMask=28
minute=`date +"%M"`
hour=`date +"%H"`
year=`date +"%Y"`
month=`date +"%m"`
day=`date +"%d"`
yday=$day
....but it is unbelievable, TODAY 08.june at 00:00 my INIT SCRIPT stop with ERROR. I dont understand why ... When I set the DATE back to 07.june 23:50 the INIT.SH script run without error, after mindnight stopd with failure.
the WRONG SINTAX WAS :
after removing "LET" and "-1" everything is working OK .... but the :"yesterday" day doesn.t set correctly :(Code:yday=$day-1
and everything is runnig FASTER.
I realy don't understand this DATE issue :((
WiZiPoK
to wizipok: and why did you change eht1 to eth0?
just to start to count :)Quote:
Originally Posted by kamilek
I solved the probs around the OTHERS and ROUTER counting ... There was a differenet string compare inside the "iptables -L -vx" and account_traffic.sh
There was enough to change the sring to "anywhere" :)
WiZIPoK
A while ago I did some fiddeling with these scripts my self and made them work ok. But in the end I made a new, easier and better solution that worked for me. Basically I just calculate usage each our and then upload the data to a web server I have runnig with a php script that stores the values in a mysql db. Then I have a php page there that shows my statistics. But for those who doesn't have a php server lying around that might not work.
But anyways, I said I made the Gr. accountings scripts kinda work before I made my own so I figured I could post them here. You can have a look, but I can't give you any garanties that they'll work for you, as I did a bit of tinkering with them..
The important files to look at and adapt are:
init.sh, ipaddresses.txt, mkcron, root
And the ones that does the work are:
add-iptables, and account_traffic.sh
Maybe it'll be a help to someone..
B.
So what do I have to change in account_traffic.sh?Quote:
Originally Posted by WiziPok
So the line "let yday=$day-1" does problem only 8. and 9. day in each month. The other days are OK. Rewriting it to "yday=$day" is not solution because of problems with history data. What to do with it?
ah simple arithmetic like that doesn'e work in shell script.
try:
$yday=`expr $day - 1`
And take a look at a scripting tutorial:
ex: http://www.freeos.com/guides/lsst/ch02sec07.html
Hi Barsju,
yes, I used very close script to yours. In some scripts on 500gx I have to replace $WAN with the realy IP with numbers .. After is Everything start to work ...
What kind of improvement did you done in your script?
The one think what is very strange, inside the code (init.sh)
the last rows " let yday=$day-1 " doesnot work ..... or its works DEPENDING ON ACTUAL DATE .....Code:minute=`date +"%M"`
hour=`date +"%H"`
year=`date +"%Y"`
month=`date +"%m"`
day=`date +"%d"`
let yday=$day-1
As KAMILEK wrote, doesnot wor on 8th and 9th day in month :) Why?
WiZiPoK
You are RIGHT !Quote:
Originally Posted by barsju
yes, the expression :
inside init.sh works fine ..Code:yday=`expr $day - 1`
WiZiPoK
Oh. You don't really need those, and I guess I should not have included them. The current hour is to show traffic for current hour. (Normally you only calculate traffic for completed hours.) But I'll include the traffic_curr.cgi for completeness.Quote:
Originally Posted by Kasio
As for the crontab, it is in the root file. Take a look there. And mkcron..
S.
Any way that you can make this public ?Quote:
Originally Posted by barsju
Maybe the empty sql db and the needed php ?
Regards
Hallo all :)
is this allstats working on a gx with wl500g-1.9.2.7-5a ?
if i start account_traffic.sh me got a error from sed
and the cgi display a "Segmentation fault"Code:# ./account_traffic.sh
setting/updating usage counter files
sed: bad format in substitution expression
sed: bad format in substitution expression
sed: bad format in substitution expression
sed: bad format in substitution expression
sedsed: bad format in substitution expression
: bad format in substitution expression
append usage to day dat files
tailing counter files
finished.
Anyone with the same error and had fixed this ?
Best Regards
found the "Segmentation fault" error but have one more q. :)
Is there some tuning that not only IE display the graph correct ?
Me have some prob with Firefox.
Best Regards
Plese helpCode:[admin@WL500g accounting]$ ./add_iptables.sh
./add_iptables.sh: 3: awk: not found
[admin@WL500g accounting]$
Upgrade to latest firmware.Quote:
Originally Posted by connic
I have in WL500g firmvare version 1.9.2.7-4. This wersion it not supports?Quote:
Originally Posted by Oleg
:confused: Now notification:
Code:[admin@WL500g accounting]$ ./add_iptables.sh
./add_iptables.sh: 3: /tmp/harddisk/accounting: Permission denied
Upgrade to 1.9.2.7-6b.Quote:
Originally Posted by connic
With firmware 1.9.2.7-6b:Quote:
Originally Posted by Oleg
where's AWK applet? In file "init.sh" is line with text:Code:[admin@WL500g accounting]$ ls
account_traffic.sh
graph_day.awk
mkcron.sh
accounting_v2.tar
graph_month.awk
monthtot.sh
add_iptables.sh
httpd.conf
rem_iptables.sh
daytot.sh
init.sh
usage.sh
graph_all.awk
ipaddress.txt
[admin@WL500g accounting]$ ./add_iptables.sh
./add_iptables.sh: 3: /tmp/harddisk/accounting:Permission denied
# pointer to AWK applet
AWK="AWK"
I Attache main files for verification.
Just remove the following lines from add_iptables.sh, because they are not used:
Have you installed the scripts in the /tmp/harddisk/accounting directory? If not, change installation directory in init.sh accordingly.Code:# ipnumbers of PC's in LAN
ipnumbers=`cat $accountdir/ipaddress.txt| $AWK '{print $2 }'`
BTW: I am working at a graphical version based on rddtools. It generates nice usage graphs in gif format. Will post things soon!
Ahh, thats cool if you can make one with rddtools :))
Regards
There is allready something for openwrt and rrd
http://wiki.freifunk-leipzig.public-...tzwerkStatisik