/[smecontribs]/rpms/smeserver-smeadmin/contribs10/smeserver-smeadmin-1.6-bz12684-fixppoe-FTTH.patch
ViewVC logotype

Contents of /rpms/smeserver-smeadmin/contribs10/smeserver-smeadmin-1.6-bz12684-fixppoe-FTTH.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Mon May 20 03:12:23 2024 UTC (6 months ago) by jpp
Branch: MAIN
CVS Tags: smeserver-smeadmin-1_6-13_el7_sme, smeserver-smeadmin-1_6-14_el7_sme, HEAD
* Sun May 19 2024 Jean-Philippe Pialasse <jpp@koozali.org> 1.6-13.sme
- fix pppoe not loging [SME: 12684]
  increase db volume field. filter display to last 24 months
  display in GB/MB instead of GiB/kiB

1 diff -Nur --no-dereference smeserver-smeadmin-1.6.old/root/etc/e-smith/web/functions/smeadmin smeserver-smeadmin-1.6/root/etc/e-smith/web/functions/smeadmin
2 --- smeserver-smeadmin-1.6.old/root/etc/e-smith/web/functions/smeadmin 2024-05-19 22:52:30.397000000 -0400
3 +++ smeserver-smeadmin-1.6/root/etc/e-smith/web/functions/smeadmin 2024-05-19 22:53:29.702000000 -0400
4 @@ -1170,7 +1170,7 @@
5 sub showPppoe
6 {
7 # get first db entry
8 -my $requete="SELECT substr(debut,1,4), substr(debut,6,2) FROM pppoe ORDER BY debut ASC LIMIT 1";
9 +my $requete="SELECT substr(debut,1,4), substr(debut,6,2) FROM pppoe WHERE debut >= CURDATE() - INTERVAL 24 MONTH ORDER BY debut ASC LIMIT 1";
10
11 #connexion a la base de donnees mySQL
12 connectBD();
13 @@ -1180,7 +1180,7 @@
14
15 my @debut = $rq->fetchrow_array();
16 # get first db entry
17 -my $requete_DESC="SELECT substr(fin,1,4), substr(fin,6,2) FROM pppoe ORDER BY debut DESC LIMIT 1";
18 +my $requete_DESC="SELECT substr(fin,1,4), substr(fin,6,2) FROM pppoe WHERE debut >= CURDATE() - INTERVAL 24 MONTH ORDER BY debut DESC LIMIT 1";
19
20 #connexion a la base de donnees mySQL
21 connectBD();
22 @@ -1189,6 +1189,7 @@
23 $rq_DESC->execute or print $q->p(sprintf(gettext("MySQL error : Can't execute query : %s\n"),$rq_DESC->errstr));
24
25 my @fin = $rq_DESC->fetchrow_array();
26 + #$debut[1] -- if ($debut[1] == $fin[1]);
27
28 my $end_yymm = $debut[0].$debut[1];
29 my $yymm = $fin[0].$fin[1];
30 @@ -1208,9 +1209,9 @@
31 print $q->th(gettext("OUT (GB)"));
32 print $q->th(gettext("TOTAL (GB)"));
33 $q->end_Tr;
34 -
35 - while ($end_yymm < $yymm) {
36 -
37 + my $nblines = 0;
38 + while ($end_yymm < $yymm || $nblines < 1) {
39 + $nblines =1;
40 if ($startMonth eq '12') {
41 $endMonth = 1;
42 $endYear = $startYear + 1;
43 @@ -1233,9 +1234,9 @@
44 # print "**$end_yymm<br>\n";
45
46 $requete="SELECT substring(`fin`,1,7) as 'month',
47 -round(SUM(`volume_in`)/1024/1024/1024,3) as 'In (Go)' ,
48 -round(SUM(`volume_out`) /1024/1024/1024,3) as 'Out (Go)' ,
49 -round(SUM(`volume_in` + `volume_out`)/1024/1024/1024,3) as 'Total (Go)' ,
50 +round(SUM(`volume_in`)/1000/1000/1000,3) as 'In (Go)' ,
51 +round(SUM(`volume_out`) /1000/1000/1000,3) as 'Out (Go)' ,
52 +round(SUM(`volume_in` + `volume_out`)/1000/1000/1000,3) as 'Total (Go)' ,
53 SUM(TIME_TO_SEC(`duree`))/3600/24 as 'duree'
54 FROM `pppoe` WHERE
55 # mois
56 @@ -1275,10 +1276,10 @@
57 [gettext("Duration"),],
58 [gettext("IP Address"),sub { return ipnum2ipdot(@_); } ],
59 [gettext("Connection peer"),sub { return ipnum2ipdot(@_); } ],
60 - [gettext("Incoming data (Ko)"),sub {return sprintf('%.2f',$_[0]/1024);}],
61 - [gettext("Outgoing data (ko)"),sub {return sprintf('%.2f',$_[0]/1024);}]
62 + [gettext("Incoming data (MB)"),sub {return sprintf('%.2f',$_[0]/1000/1000);}],
63 + [gettext("Outgoing data (MB)"),sub {return sprintf('%.2f',$_[0]/1000/1000);}]
64 ],
65 - \"SELECT debut,fin,duree,ip,peer,volume_in,volume_out FROM pppoe ORDER BY debut DESC",
66 + \"SELECT debut,fin,duree,ip,peer,volume_in,volume_out,fin-debut as 'encours' FROM pppoe WHERE debut >= CURDATE() - INTERVAL 24 MONTH ORDER BY debut DESC",
67 \gettext("Detailed list of ADSL/PPPoE connections.\n"));
68 }
69 #----------------------------------------------------------------
70 @@ -1425,9 +1426,17 @@
71 print $q->Tr($q->td({bgcolor=>"#9999FF",colspan=>"7"},sprintf(gettext("Disconnection lasted more than %s minutes"),$params{'LimitPppoeDisconnect'}))) if (($rq2->fetchrow_array)[0] eq '1');
72
73 #on match le nb d'heure de la duree cnx
74 - $ligne[2]=~/(\d{2}):\d{2}:\d{2}/;
75 + my $curdur;
76 + if ($ligne[2]) {
77 + # ended connection
78 + $ligne[2]=~/(\d{2}):\d{2}:\d{2}/;
79 + $curdur=$1;
80 + }else{
81 + # ongoing connection
82 + $curdur=$ligne[7]/3600;
83 + }
84 #si le nb d'heure < limite et different de null, surbrillance
85 - print $q->start_Tr({bgcolor=>((($1 < $params{'LimitPppoeDuration'}) && ($1 ne ''))?"#FF4444":"#FFFFFF")});
86 + print $q->start_Tr({bgcolor=>((($curdur < $params{'LimitPppoeDuration'}) && ($1 ne ''))?"#FF4444":"#FFFFFF")});
87 }
88 elsif ($q->param('service') eq 'sshd')
89 {
90 diff -Nur --no-dereference smeserver-smeadmin-1.6.old/root/usr/bin/smeadmind smeserver-smeadmin-1.6/root/usr/bin/smeadmind
91 --- smeserver-smeadmin-1.6.old/root/usr/bin/smeadmind 2024-05-19 22:52:30.390000000 -0400
92 +++ smeserver-smeadmin-1.6/root/usr/bin/smeadmind 2024-05-19 22:53:06.837000000 -0400
93 @@ -497,7 +497,8 @@
94 if ($ppoeif ne 'none' && $ppoemode eq 'pppoe') {
95
96 my $recBytes=`cat /proc/net/dev|grep $ppoeif|cut -d ':' -f2|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d ' ' -f1`;
97 - my $senBytes=`cat /proc/net/dev|grep $ppoeif|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d " " -f9`;
98 + #my $senBytes=`cat /proc/net/dev|grep $ppoeif|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d " " -f9`;
99 + my $senBytes=`cat /proc/net/dev|grep ppp0|cut -d ':' -f2|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d ' ' -f9`;
100
101 #my $requete="SELECT pid_pppd FROM pppoe WHERE ORDER DESC LIMIT 1";
102 #my $rq=$bd->prepare($requete) or print $q->p(sprintf(gettext("MySQL error : Impossible to prepare SQL query \"%s\" : %s\n"),$requete,$bd->errstr));
103 @@ -904,7 +905,8 @@
104 #Jul 14 12:49:58 sas pppd[1878]: rcvd [IPCP ConfAck id=0x2 <addr 213.41.134.153>]
105 #Match: date hostname pppd[pid]: rcvd [IPCP ConfAck id=0xxx? <addr ip>]
106 #if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: rcvd \[IPCP ConfAck id=0x\w+ <addr (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})>\]/o)
107 - if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: rcvd \[IPCP ConfAck id=0x\w+ <addr (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})>\]/o) {
108 + #if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: rcvd \[IPCP ConfAck id=0x\w+ <addr (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})>\]/o) {
109 + if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: local IP address (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
110 #$1: date $2:pid $3.$4.$5.$6:ip
111 my $date=mkmysqldate($1);
112 my $ip=ipdot2ipnum($3,$4,$5,$6);
113 diff -Nur --no-dereference smeserver-smeadmin-1.6.old/root/usr/share/doc/smeserver-smeadmin/tables.sql smeserver-smeadmin-1.6/root/usr/share/doc/smeserver-smeadmin/tables.sql
114 --- smeserver-smeadmin-1.6.old/root/usr/share/doc/smeserver-smeadmin/tables.sql 2020-10-15 07:31:28.000000000 -0400
115 +++ smeserver-smeadmin-1.6/root/usr/share/doc/smeserver-smeadmin/tables.sql 2024-05-19 22:55:48.248000000 -0400
116 @@ -28,8 +28,8 @@
117 fin datetime,
118 pid_afpd int unsigned not null,
119 login varchar(10),
120 - volume_read int(20) unsigned,
121 - volume_write int(20) unsigned,
122 + volume_read bigint(20) unsigned,
123 + volume_write bigint(20) unsigned,
124 primary key (debut) );
125
126 -- Structure de la table dchpd
127 @@ -52,8 +52,8 @@
128 pid_proftpd int unsigned not null,
129 login varchar(10),
130 connecte bool,
131 - volume_in int(20) unsigned,
132 - volume_out int(20) unsigned,
133 + volume_in bigint(20) unsigned,
134 + volume_out bigint(20) unsigned,
135 primary key (debut) );
136
137 -- Structure de la table pppoe
138 @@ -65,8 +65,8 @@
139 pid_pppd int unsigned not null,
140 ip int unsigned not null,
141 peer int unsigned not null,
142 - volume_in int(20) unsigned,
143 - volume_out int(20) unsigned,
144 + volume_in bigint(20) unsigned,
145 + volume_out bigint(20) unsigned,
146 primary key (debut) );
147
148 -- Structure de la table ssh
149 @@ -87,8 +87,8 @@
150 ip int unsigned,
151 vpn_clt int unsigned,
152 vpn_srv int unsigned not null,
153 - volume_in int unsigned,
154 - volume_out int unsigned,
155 + volume_in bigint unsigned,
156 + volume_out bigint unsigned,
157 login varchar(10),
158 pid_pptpd int(20) unsigned not null,
159 pid_pppd int(20) unsigned,
160 diff -Nur --no-dereference smeserver-smeadmin-1.6.old/root/usr/share/doc/smeserver-smeadmin/tables-update.sql smeserver-smeadmin-1.6/root/usr/share/doc/smeserver-smeadmin/tables-update.sql
161 --- smeserver-smeadmin-1.6.old/root/usr/share/doc/smeserver-smeadmin/tables-update.sql 2020-10-15 07:31:28.000000000 -0400
162 +++ smeserver-smeadmin-1.6/root/usr/share/doc/smeserver-smeadmin/tables-update.sql 2024-05-19 22:58:13.446000000 -0400
163 @@ -5,15 +5,15 @@
164 ALTER TABLE `pppoe` CHANGE `ip` `ip` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'
165 ;
166 -- Update size of some fields
167 -ALTER TABLE `pppoe` CHANGE `volume_in` `volume_in` INT( 20 ) UNSIGNED NULL DEFAULT NULL ,
168 -CHANGE `volume_out` `volume_out` INT( 20 ) UNSIGNED NULL DEFAULT NULL ;
169 +ALTER TABLE `pppoe` CHANGE `volume_in` `volume_in` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
170 +CHANGE `volume_out` `volume_out` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ;
171
172 -ALTER TABLE `vpn` CHANGE `volume_in` `volume_in` INT( 20 ) UNSIGNED NULL DEFAULT NULL ,
173 -CHANGE `volume_out` `volume_out` INT( 20 ) UNSIGNED NULL DEFAULT NULL ;
174 +ALTER TABLE `vpn` CHANGE `volume_in` `volume_in` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
175 +CHANGE `volume_out` `volume_out` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ;
176
177 -ALTER TABLE `ftp` CHANGE `volume_in` `volume_in` INT( 20 ) UNSIGNED NULL DEFAULT NULL ,
178 -CHANGE `volume_out` `volume_out` INT( 20 ) UNSIGNED NULL DEFAULT NULL ;
179 +ALTER TABLE `ftp` CHANGE `volume_in` `volume_in` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
180 +CHANGE `volume_out` `volume_out` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ;
181
182 ALTER TABLE `afp` CHANGE `volume_write` `volume_write` INT( 20 ) UNSIGNED NULL DEFAULT NULL ,
183 -CHANGE `volume_read` `volume_read` INT( 20 ) UNSIGNED NULL DEFAULT NULL ;
184 +CHANGE `volume_read` `volume_read` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ;
185

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed