From mboxrd@z Thu Jan 1 00:00:00 1970 From: git@ipfire.org To: ipfire-scm@lists.ipfire.org Subject: [git.ipfire.org] IPFire 2.x development tree branch, next, updated. 0fa8d28e8fe5f6a9a04b8d13b4dc6bb6b1f54c8f Date: Tue, 21 Apr 2015 20:47:39 +0200 Message-ID: <20150421184740.02CBD21EA6@argus.ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4753198763193809030==" List-Id: --===============4753198763193809030== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree". The branch, next has been updated via 0fa8d28e8fe5f6a9a04b8d13b4dc6bb6b1f54c8f (commit) from a47376207fbce85385dc6086a87d54ec2e6aa0f1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0fa8d28e8fe5f6a9a04b8d13b4dc6bb6b1f54c8f Author: Alexander Marx Date: Tue Apr 21 11:25:29 2015 +0200 Squid-accounting: new Version 1.0.3 (graph updates, movedb update) =20 New Version. Now the data is correctly moved to hist table when month has changed. Also the graphs for old month starts by zero. In old version graphdata was started by total amount of bytes. ----------------------------------------------------------------------- Summary of changes: lfs/squid-accounting | 4 ++-- src/squid-accounting/accounting.cgi | 21 +++++++++++++-------- src/squid-accounting/acct-lib.pl | 17 ++++++----------- src/squid-accounting/acct.pl | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) Difference in files: diff --git a/lfs/squid-accounting b/lfs/squid-accounting index 7eae4fb..af7b281 100644 --- a/lfs/squid-accounting +++ b/lfs/squid-accounting @@ -9,13 +9,13 @@ =20 include Config =20 -VER =3D 1.0.2 +VER =3D 1.0.3 =20 THISAPP =3D squid-accounting-$(VER) DIR_APP =3D $(DIR_SRC)/$(THISAPP) TARGET =3D $(DIR_INFO)/$(THISAPP) PROG =3D squid-accounting -PAK_VER =3D 4 +PAK_VER =3D 5 =20 DEPS =3D "perl-DBI perl-DBD-SQLite perl-File-ReadBackwards perl-PDF-AP= I2 sendEmail" =20 diff --git a/src/squid-accounting/accounting.cgi b/src/squid-accounting/accou= nting.cgi index eabb0c2..1ec9849 100755 --- a/src/squid-accounting/accounting.cgi +++ b/src/squid-accounting/accounting.cgi @@ -907,7 +907,7 @@ sub generatemonthgraph{ my $sth; my $cnt=3D0; #If we want to show Data from within last 2 months, get DATA from ACCT - if ( ! $grmon < ($mon+1) && $gryear =3D=3D ($year+1900)){ + if ( $grmon =3D=3D ($mon)+1 && $gryear =3D=3D ($year+1900)){ $sth=3D&ACCT::getmonthgraphdata("ACCT",$from,$till,$grhost); }else{ #If we want to show data from a date older than last two months, use ACCT_= HIST @@ -1959,9 +1959,9 @@ END sub viewtablehosts{ $dbh=3D&ACCT::connectdb; &Header::openbox('100%', 'left', $Lang::tr{'acct hosts'}); - my $mon=3D$_[0]; - my $year=3D$_[1]; - my ($from,$till)=3D&ACCT::getmonth($mon,$year); + my $mon1=3D$_[0]; + my $year1=3D$_[1]; + my ($from,$till)=3D&ACCT::getmonth($mon1,$year1); $count=3D0; #Menu to display another month print< - - + + =09 diff --git a/src/squid-accounting/acct-lib.pl b/src/squid-accounting/acct-lib= .pl index 7969a50..6891235 100644 --- a/src/squid-accounting/acct-lib.pl +++ b/src/squid-accounting/acct-lib.pl @@ -93,8 +93,8 @@ sub delbefore { } =20 sub movedbdata { - $dbh->do("insert into ACCT_HIST select datetime(TIME_RUN,'unixepoch'),NAME,= SUM(BYTES) from ACCT where date(TIME_RUN,'unixepoch') < date('now','-2 month= s') group by NAME,date(TIME_RUN,'unixepoch');"); - $dbh->do("DELETE FROM ACCT WHERE datetime(TIME_RUN,'unixepoch') < date('now= ','-2 months');"); + $dbh->do("insert into ACCT_HIST select datetime(TIME_RUN,'unixepoch'),NAME,= SUM(BYTES) from ACCT where datetime(TIME_RUN,'unixepoch') < datetime('now','s= tart of month') group by NAME,datetime(TIME_RUN,'unixepoch');"); + $dbh->do("DELETE FROM ACCT WHERE datetime(TIME_RUN,'unixepoch') < date('now= ','start of month');"); } =20 sub gethourgraphdata { @@ -119,10 +119,10 @@ sub getmonthgraphdata { my $name=3D$_[3]; my $res; $dbh=3Dconnectdb; - if ($table eq 'ACCT'){ - $res =3D $dbh->selectall_arrayref( "SELECT strftime('%d.%m.%Y',xx.tag),(S= ELECT SUM(BYTES)/1024/1024 FROM ACCT WHERE date(TIME_RUN,'unixepoch') <=3D xx= .tag and NAME =3D '".$name."') kum_bytes FROM (SELECT date(TIME_RUN,'unixepoc= h') tag,SUM(BYTES)/1024/1024 sbytes FROM ACCT WHERE NAME=3D'".$name."' and TI= ME_RUN between ".$from." and ".$till." GROUP by date(TIME_RUN,'unixepoch')) x= x;"); + if ($table eq 'ACCT_HIST'){ + $res =3D $dbh->selectall_arrayref( "SELECT strftime('%d.%m.%Y',TIME_RUN),(= SELECT SUM(BYTES)/1024/1024 FROM ACCT_HIST WHERE TIME_RUN <=3D ah.TIME_RUN an= d TIME_RUN > date($from,'unixepoch') and NAME =3D '".$name."') kum_bytes FROM= ACCT_HIST ah WHERE date(TIME_RUN) > date(".$from.",'unixepoch') AND date(TIM= E_RUN) < date(".$till.",'unixepoch') AND NAME =3D '".$name."' group by date(T= IME_RUN);"); }else{ - $res =3D $dbh->selectall_arrayref( "SELECT TIME_RUN, (SELECT SUM(BYTES)/10= 24/1024 FROM ACCT_HIST WHERE TIME_RUN <=3D ah.TIME_RUN and NAME =3D '".$name.= "') kum_bytes FROM ACCT_HIST ah WHERE TIME_RUN BETWEEN date(".$from.",'unixep= och') AND date(".$till.",'unixepoch') AND NAME =3D '".$name."' group by TIME_= RUN;"); + $res =3D $dbh->selectall_arrayref( "SELECT strftime('%d.%m.%Y',xx.tag),(SE= LECT SUM(BYTES)/1024/1024 FROM ACCT WHERE date(TIME_RUN,'unixepoch') <=3D xx.= tag and TIME_RUN > ".$from." and NAME =3D '".$name."') kum_bytes FROM (SELECT= NAME,date(TIME_RUN,'unixepoch') tag,SUM(BYTES)/1024/1024 sbytes FROM ACCT WH= ERE NAME=3D'".$name."' and TIME_RUN between ".$from." and ".$till." GROUP by = NAME,date(TIME_RUN,'unixepoch')) xx;"); } $dbh=3Dclosedb; return $res; @@ -337,12 +337,7 @@ sub getmonth{ my $monat=3D$_[0]-1 if($_[0]); my $tag=3D1; my $time1=3Dtimelocal(0,0,0,$tag,$monat,$jahr); - my $time2=3D0; - if (($monat+1) =3D=3D 12){ - $time2=3Dtimelocal(0,0,0,$tag,0,$jahr+1); - }else{ - $time2=3Dtimelocal(0,0,0,$tag,$monat+1,$jahr); - } + my $time2=3Dtimelocal(0,0,0,$tag,($monat+1),$jahr); --$time2; return ($time1,$time2); } diff --git a/src/squid-accounting/acct.pl b/src/squid-accounting/acct.pl index 79fc7ba..7222689 100755 --- a/src/squid-accounting/acct.pl +++ b/src/squid-accounting/acct.pl @@ -100,7 +100,7 @@ if (-f $proxyenabled && $proxylog eq $Lang::tr{'running'}= ){ open (FH,">/var/log/accounting.log"); close (FH); chmod 0755, "/var/log/accounting.log"; - #move all db entries older than 2 months to second table and cumulate them= hourly + #move all db entries older than this month to second table and cumulate th= em daily &ACCT::movedbdata; &ACCT::logger($settings{'LOG'},"New Month. Old trafficvalues moved to ACCT= _HIST Table\n"); if ($settings{'USEMAIL'} eq 'on'){ hooks/post-receive -- IPFire 2.x development tree --===============4753198763193809030==--