/[smecontribs]/rpms/smeserver-sme8admin/contribs8/smeserver-sme8admin-1.3-newsql.patch
ViewVC logotype

Annotation of /rpms/smeserver-sme8admin/contribs8/smeserver-sme8admin-1.3-newsql.patch

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


Revision 1.1 - (hide annotations) (download)
Mon Dec 30 06:47:01 2013 UTC (10 years, 10 months ago) by unnilennium
Branch: MAIN
CVS Tags: smeserver-sme8admin-1_3-4_el5_sme, HEAD
* Sun Dec 15 2013 JP Pialasse <test@pialasse.com> 1.3-4.sme
- fix obsolete missing [SME: 7109]
- fix pppoe and vpn loging [SME: 8061]
- added monthly ppoe log
- fix stop on mysql error too many connections [SME: 7683]

1 unnilennium 1.1 diff -up smeserver-sme8admin-1.3/root/etc/e-smith/web/functions/sme8admin.newsql smeserver-sme8admin-1.3/root/etc/e-smith/web/functions/sme8admin
2     --- smeserver-sme8admin-1.3/root/etc/e-smith/web/functions/sme8admin.newsql 2012-06-16 13:05:55.000000000 -0400
3     +++ smeserver-sme8admin-1.3/root/etc/e-smith/web/functions/sme8admin 2013-12-30 00:27:53.000000000 -0500
4     @@ -1044,6 +1044,106 @@ sub showDhcpd
5     #details du service pppoe
6     sub showPppoe
7     {
8     +# get first db entry
9     +my $requete="SELECT substr(debut,1,4), substr(debut,6,2) FROM pppoe ORDER BY debut ASC LIMIT 1";
10     +
11     + #connexion a la base de donnees mySQL
12     + connectBD();
13     + #recuperation des donnees
14     + my $rq=$bd->prepare($requete) or print $q->p(sprintf(gettext("MySQL error : Impossible to prepare SQL query \"%s\" : %s\n"),$requete,$bd->errstr));
15     + $rq->execute or print $q->p(sprintf(gettext("MySQL error : Can't execute query : %s\n"),$rq->errstr));
16     +
17     + my @debut = $rq->fetchrow_array();
18     +# get first db entry
19     +my $requete="SELECT substr(fin,1,4), substr(fin,6,2) FROM pppoe ORDER BY debut DESC LIMIT 1";
20     +
21     + #connexion a la base de donnees mySQL
22     + connectBD();
23     + #recuperation des donnees
24     + my $rq=$bd->prepare($requete) or print $q->p(sprintf(gettext("MySQL error : Impossible to prepare SQL query \"%s\" : %s\n"),$requete,$bd->errstr));
25     + $rq->execute or print $q->p(sprintf(gettext("MySQL error : Can't execute query : %s\n"),$rq->errstr));
26     +
27     + my @fin = $rq->fetchrow_array();
28     +
29     + my $end_yymm = $debut[0].$debut[1];
30     + my $yymm = $fin[0].$fin[1];
31     + my $startMonth = $debut[1];
32     + my $startYear = $debut[0];
33     + my $endMonth;
34     + my $endYear;
35     + my $preMonth;
36     + my $preYear;
37     + my $i=0;
38     +
39     +print $q->p(gettext("Traffic by Month"));
40     + print $q->start_table({-border=>'1'}),
41     + $q->start_Tr;
42     + print $q->th(gettext("year-month"));
43     + print $q->th(gettext("IN (GB)"));
44     + print $q->th(gettext("OUT (GB)"));
45     + print $q->th(gettext("TOTAL (GB)"));
46     + $q->end_Tr;
47     +
48     + while ($end_yymm < $yymm) {
49     +
50     + if ($startMonth eq '12') {
51     + $endMonth = 1;
52     + $endYear = $startYear + 1;
53     + } else {
54     + $endMonth = $startMonth + 1;
55     + $endYear = $startYear;
56     + }
57     + ## Now that you have the end year and month incremented setup the end_yymm variable again to be picked up in the while statement:
58     + $end_yymm = $startYear . ${\(length($startMonth) == 1 ? '0' : '')} . $startMonth;
59     +
60     + if ($startMonth eq '1') {
61     + $preMonth=12;
62     + $preYear=$startYear-1;
63     + }
64     + else {
65     + $preMonth=$startMonth-1;
66     + $preYear= $startYear;
67     + }
68     + # ...... carry on with the rest of your code
69     +# print "**$end_yymm<br>\n";
70     +
71     + $requete="SELECT substring(`fin`,1,7) as 'month',
72     +round(SUM(`volume_in`)/1024/1024/1024,3) as 'In (Go)' ,
73     +round(SUM(`volume_out`) /1024/1024/1024,3) as 'Out (Go)' ,
74     +round(SUM(`volume_in` + `volume_out`)/1024/1024/1024,3) as 'Total (Go)' ,
75     +SUM(TIME_TO_SEC(`duree`))/3600/24 as 'duree'
76     +FROM `pppoe` WHERE
77     +# mois
78     +(`debut`> '$startYear-$startMonth-01 00:00:00' and `fin`< '$endYear-$endMonth-01 00:00:00')
79     +# bordure
80     +or ( `debut`> '$preYear-$preMonth-01 00:00:00' and `debut`< '$startYear-$startMonth-01 00:00:00' and `fin`> '$startYear-$startMonth-01 00:00:00')
81     +or ( `debut`< '$endYear-$endMonth-01 00:00:00' and `fin`> '$endYear-$endMonth-01 00:00:00' and `fin`< '$endYear-$endMonth-28 00:00:00')";
82     +
83     + my $rq=$bd->prepare($requete) or print $q->p(sprintf(gettext("MySQL error : Impossible to prepare SQL query \"%s\" : %s\n"),$requete,$bd->errstr));
84     + $rq->execute or print $q->p(sprintf(gettext("MySQL error : Can't execute query : %s\n"),$rq->errstr));
85     +
86     +my @ligne = $rq->fetchrow_array();
87     +print $q->start_Tr;
88     + print $q->td("$startYear-". ${\(length($startMonth) == 1 ? '0' : '')} ."$startMonth");
89     + print $q->td($ligne[1]);
90     + print $q->td($ligne[2]);
91     + print $q->td($ligne[3]);
92     + print $q->end_Tr;
93     +
94     + # get ready for next loop
95     + if ($startMonth eq '12') {
96     + $startMonth = 1;
97     + $startYear++;
98     + } else {
99     + $startMonth++
100     + }
101     +
102     + } # end the while loop
103     +print $q->end_table;
104     +
105     +deconnectBD();
106     +
107     +
108     showDbData( [
109     [gettext("Start"),],
110     [gettext("End"),],
111     @@ -1147,7 +1247,7 @@ sub showDbData
112     print $q->table($q->Tr($q->td(gettext("Connections which lasted ")),
113     $q->td({bgcolor=>"#FF4444"},sprintf(gettext("more than %s hours are highlighted.\n"),$params{'LimitVpnDuration'}))));
114     }
115     - elsif ($q->param('service') eq 'pppoe')
116     + elsif ($q->param('service') eq 'wan'|| $q->param('service') eq 'pppoe' )
117     {
118     print $q->table($q->Tr($q->td(gettext("Connections which lasted ")),
119     $q->td({bgcolor=>"#FF4444"},sprintf(gettext("less than %s hours are highlighted.\n"),$params{'LimitPppoeDuration'})))),
120     @@ -1185,7 +1285,7 @@ sub showDbData
121     #si le nb d'heure > limite, surbrillance
122     print $q->start_Tr({bgcolor=>(($1 >= $params{'LimitVpnDuration'})?"#FF4444":"#FFFFFF")});
123     }
124     - elsif ($q->param('service') eq 'pppoe')
125     + elsif ($q->param('service') eq 'wan' || $q->param('service') eq 'pppoe')
126     {
127     #on interroge la bd pour voir si il y a eu une longue deconnexion
128     #(beaucoup plus simple que de parser les 2 dates et faire une difference, la on utilise la possibilite de calcul de diff de dates de MySQL)
129     diff -up smeserver-sme8admin-1.3/root/usr/bin/sme8admind.newsql smeserver-sme8admin-1.3/root/usr/bin/sme8admind
130     --- smeserver-sme8admin-1.3/root/usr/bin/sme8admind.newsql 2013-12-30 00:21:28.000000000 -0500
131     +++ smeserver-sme8admin-1.3/root/usr/bin/sme8admind 2013-12-30 00:22:54.000000000 -0500
132     @@ -292,8 +292,11 @@ sub connectBD
133     #DBI:mysql, deconnecte MOI
134     sub deconnectBD
135     {
136     - $bd->disconnect;
137     - if (!defined ($bd)) {print "MYSQL error $DBI::errstr\n";}
138     + if (defined ($bd)) {
139     + $bd->disconnect or
140     + warn "MYSQL error $DBI::errstr\n";}
141     + else
142     + { print "mysql : nothing to disconnect";}
143     }
144    
145     #----------------------------------------------------------------
146     @@ -424,6 +427,47 @@ sub tell_log {
147    
148     sub parse_logs {
149     connectBD();
150     + # ici on met a jour volume connexion meme si pas fini si pppoe et si pas trouvé de fin dans log
151     + my $smedb=esmith::ConfigDB->open;
152     + my $ppoeif = $smedb->get("ExternalInterface")->prop('Name');
153     + my $recBytes=`cat /proc/net/dev|grep $ppoeif|cut -d ':' -f2|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d ' ' -f1`;
154     + my $senBytes=`cat /proc/net/dev|grep $ppoeif|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d " " -f9`;
155     +
156     + #my $requete="SELECT pid_pppd FROM pppoe WHERE ORDER DESC LIMIT 1";
157     + #my $rq=$bd->prepare($requete) or print $q->p(sprintf(gettext("MySQL error : Impossible to prepare SQL query \"%s\" : %s\n"),$requete,$bd->errstr));
158     + #$rq->execute or print $q->p(sprintf(gettext("MySQL error : Can't execute query : %s\n"),$rq->errstr));
159     + #my $pidPppd = $rq->fetchrow_array();
160     + my $pidPppd=`cat /var/run/$ppoeif.pid`;
161     + print "the current pid for pppd is $pidPppd \n";
162     +
163     + my $reslt1=execute_sql_query("SELECT * FROM pppoe WHERE pid_pppd='$pidPppd'");
164     + #si on a trouve une ligne ==> update dans pppoe
165     + if ($reslt1 != "0E0") {
166     + my $requete1="UPDATE pppoe SET volume_out=$senBytes, volume_in=$recBytes, fin=now() where pid_pppd=$pidPppd ORDER BY debut DESC LIMIT 1;";
167     + #print "requete a executer : $requete1 \n";
168     + execute_sql_query($requete1);
169     + }
170     + # on fait de même pour les conenxions VPN
171     + foreach my $mypid (`ls /var/run/ppp[0-9]*.pid`){
172     + $mypid =~ /\/var\/run\/(ppp[0-9]*).pid/;
173     + my $vpnif = $1;
174     + $mypid = `cat $mypid`;
175     + if ($vpnif ne $ppoeif ) {
176     + my $recBytes=`cat /proc/net/dev|grep $vpnif|cut -d ':' -f2|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d ' ' -f1`;
177     + my $senBytes=`cat /proc/net/dev|grep $vpnif|tr -s ' '| sed -e 's/^[ \t]*//'|cut -d " " -f9`;
178     +
179     + my $reslt1=execute_sql_query("SELECT * FROM vpn WHERE pid_pppd='$mypid'");
180     +
181     + if ($reslt1 != "0E0") {
182     + my $requete1="UPDATE vpn SET volume_out=$senBytes, volume_in=$recBytes, fin=now() where pid_pppd=$mypid ORDER BY debut DESC LIMIT 1;";
183     + #print "requete a executer : $requete1 \n";
184     + execute_sql_query($requete1);
185     + }
186     + }
187     + }
188     +
189     +
190     +
191    
192     ($net_dhcp,$net_mail_in,$net_mail_out,$net_spam,$net_virus)=(0,0,0,0,0);
193     foreach my $nom (@logs) {
194     @@ -631,7 +675,7 @@ sub parse_logs {
195     if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName afpd\[(\d+)\]: login (\w+) \(uid \d+/o) {
196     #$1: date $2:pid $3:login
197     my $debut=mkmysqldate($1);
198     - #pourquoi cette bidouille sur la date ??
199     + #pourquoi cette bidouille sur la date ??
200     #pour retrouver la bonne cnx=>pid et la date du open session
201     #il doit avoir eu lieu au plus 10sec avant le login
202     execute_sql_query("UPDATE afp SET login='$3' where pid_afpd=$2 and debut > '$debut' - interval 10 second");
203     @@ -665,7 +709,7 @@ sub parse_logs {
204     #Jul 14 12:49:58 sas pppd[1878]: rcvd [IPCP ConfAck id=0x2 <addr 213.41.134.153>]
205     #Match: date hostname pppd[pid]: rcvd [IPCP ConfAck id=0xxx? <addr ip>]
206     #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)
207     - 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) {
208     + 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) {
209     #$1: date $2:pid $3.$4.$5.$6:ip
210     my $date=mkmysqldate($1);
211     my $ip=ipdot2ipnum($3,$4,$5,$6);
212     @@ -674,65 +718,107 @@ sub parse_logs {
213     }
214    
215     #PPPOE ip peer
216     - #Jul 14 12:49:58 sas pppd[1878]: sent [IPCP ConfAck id=0x1 <addr 62.4.16.234>]
217     + #Jul 14 12:49:58 sas pppd[1878]: sent [IPCP ConfAck id=0x1 <addr 62.12.16.234>]
218     #Match: date hostname pppd[pid]: sent [IPCP ConfAck id=0xxx? <addr ip>]
219     #if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: sent \[IPCP ConfAck id=0x\w+ <addr (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})>\]/o)
220     if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: remote IP address (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
221     #$1: date $2:pid $3.$4.$5.$6:ip
222     my $date=mkmysqldate($1);
223     my $ip=ipdot2ipnum($3,$4,$5,$6);
224     - execute_sql_query("UPDATE pppoe SET peer='$ip' where pid_pppd=$2 and debut > '$date' - interval 5 second");
225     + #faut faire un update, mais soit dans pppoe, soit dans vpn
226     + my $reslt=execute_sql_query("SELECT * FROM pppoe WHERE pid_pppd='$2' ORDER BY debut DESC LIMIT 1");
227     + my $requete="UPDATE ";
228     + #si on a trouve une ligne ==> update dans pppoe
229     + if ($reslt != "0E0") { $requete.="pppoe SET peer='$ip' where pid_pppd=$2 and debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1";}
230     + #sinon c une fin de cnx vpn; on fait un guess que deux connexions vpn ont pas eu lieu dans les memes 5 secondes...
231     + else { $requete.="vpn SET vpn_clt='$ip' where pid_pppd=$2 and debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1";}
232     + # $requete.="SET peer='$ip' where pid_pppd=$2 and debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1";
233     + execute_sql_query($requete);
234     next;
235     }
236    
237     - #VPN ip vpn_srv & pid_pptpd
238     - #Jun 25 15:43:31 test pptpd[636]: CTRL: local address = 192.168.2.1
239     - if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL: local address = (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
240     - #$1: date $2:pid $3.$4.$5.$6:ip
241     - my $date=mkmysqldate($1);
242     - my $ip=ipdot2ipnum($3,$4,$5,$6);
243     - execute_sql_query("INSERT INTO vpn VALUES ('$date',null,null,null,null,$ip,null,null,null,$2,null)");
244     - next;
245     - }
246     + 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) {
247     + #$1: date $2:pid $3.$4.$5.$6:ip
248     + my $date=mkmysqldate($1);
249     + my $ip=ipdot2ipnum($3,$4,$5,$6);
250     + #faut faire un update, mais soit dans pppoe, soit dans vpn
251     + my $reslt=execute_sql_query("SELECT * FROM vpn WHERE debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1");
252     + my $requete="UPDATE ";
253     + #si on a trouve une ligne ==> update dans vpn
254     + my $smedb=esmith::ConfigDB->open;
255     + my $localif = $smedb->get("LocalIP")->prop('type');
256     + print "IP IF local $localif - IP $3.$4.$5.$6 \n";
257     + if ($reslt != "0E0" && "$3.$4.$5.$6" eq $localif )
258     + { $requete.="vpn SET vpn_srv='$ip', pid_pppd=$2 WHERE pid_pppd IS NULL and debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1";
259     + execute_sql_query($requete);}
260     + next;
261     + }
262    
263     - #VPN ip vpn_clt
264     - #Jun 25 15:43:31 test pptpd[636]: CTRL: remote address = 192.168.2.250
265     - if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL: remote address = (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
266     - #$1: date $2:pid $3.$4.$5.$6:ip
267     - my $date=mkmysqldate($1);
268     - my $ip=ipdot2ipnum($3,$4,$5,$6);
269     - execute_sql_query("UPDATE vpn SET vpn_clt=$ip where pid_pptpd=$2 and debut > '$date' - interval 5 second");
270     - next;
271     - }
272     - #VPN ip client
273     - #Jun 25 15:43:31 test pptpd[636]: CTRL: Client 192.168.185.66 control connection started
274     - if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL: Client (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}) control connection started/o) {
275     - #$1: date $2:pid $3.$4.$5.$6:ip
276     - my $date=mkmysqldate($1);
277     - my $ip=ipdot2ipnum($3,$4,$5,$6);
278     - execute_sql_query("UPDATE vpn SET ip=$ip where pid_pptpd=$2 and debut > '$date' - interval 5 second");
279     - next;
280     - }
281    
282     - #VPN checkip pid_pppd
283     - #Jun 25 15:43:33 test pptpd[637]: CTRL (PPPD Launcher): local address = 192.168.2.1
284     - if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL \(PPPD Launcher\): local address = (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
285     - #$1: date $2:pid !!! PPPD !!! $3.$4.$5.$6:ip
286     + #VPN ip vpn_srv & pid_pptpd
287     + #old # Jun 25 15:43:31 test pptpd[636]: CTRL: local address = 192.168.2.1
288     + #old: #if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL: local address = (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
289     + #Dec 15 15:59:13 atlas pptpd[19918]: CTRL: Client 24.14.190.157 control connection started
290     + #Dec 15 15:59:13 atlas pptpd[19918]: CTRL: Starting call (launching pppd, opening GRE)
291     + #Dec 15 15:59:13 atlas pppd[19919]: Plugin radius.so loaded.
292     + #Dec 15 15:59:13 atlas pppd[19919]: RADIUS plugin initialized.
293     + #Dec 15 15:59:13 atlas pppd[19919]: pppd 2.4.4 started by root, uid 0
294     + #Dec 15 15:59:13 atlas pppd[19919]: Using interface ppp1
295     + #Dec 15 15:59:13 atlas pppd[19919]: Connect: ppp1 <--> /dev/pts/5
296     + #Dec 15 15:59:17 atlas pppd[19919]: MPPE 128-bit stateless compression enabled
297     + #Dec 15 15:59:18 atlas pppd[19919]: found interface br0 for proxy arp
298     + #Dec 15 15:59:18 atlas pppd[19919]: local IP address 192.168.12.1
299     + #Dec 15 15:59:18 atlas pppd[19919]: remote IP address 192.168.12.250
300     + #Dec 15 15:59:18 atlas esmith::event[19939]: Processing event: ip-up.pptpd ppp1 /dev/pts/5 460800 192.168.12.1 192.168.12.250 pptpd
301     + if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL: Client (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}) control connection started/o) {
302     + #$1: date $2:pid $3.$4.$5.$6:ip
303     my $date=mkmysqldate($1);
304     my $ip=ipdot2ipnum($3,$4,$5,$6);
305     - execute_sql_query("UPDATE vpn SET pid_pppd=$2 where vpn_srv=$ip and debut > '$date' - interval 5 second");
306     + execute_sql_query("INSERT INTO vpn VALUES ('$date',null,null,$ip,null,0,null,null,null,$2,null)");
307     next;
308     }
309    
310     - #Deprecated !!! Dans sme7, l'auth se fait via Radius, qui ne loggue rien par défaut => pas moyen de connaitre simplement le login
311     - #VPN login
312     - #Jun 25 15:43:36 test pppd[637]: CHAP peer authentication succeeded for rv
313     - if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: CHAP peer authentication succeeded for ([0-9a-z-]+)/o) {
314     - #$1: date $2:pid $3:login
315     - my $date=mkmysqldate($1);
316     - execute_sql_query("UPDATE vpn SET login='$3' where pid_pppd=$2 and debut > '$date' - interval 20 second");
317     - next;
318     - }
319     + ##VPN ip vpn_clt
320     + ##Jun 25 15:43:31 test pptpd[636]: CTRL: remote address = 192.168.2.250
321     + ##Dec 15 15:27:33 atlas pppd[15747]: remote IP address 192.168.12.250
322     + ##if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL: remote address = (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
323     + # #$1: date $2:pid $3.$4.$5.$6:ip
324     + # my $date=mkmysqldate($1);
325     + # my $ip=ipdot2ipnum($3,$4,$5,$6);
326     + # execute_sql_query("UPDATE vpn SET vpn_clt=$ip where pid_pptpd=$2 and debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1");
327     + # next;
328     + #}
329     +
330     + ##VPN ip client
331     + ##Jun 25 15:43:31 test pptpd[636]: CTRL: Client 192.168.185.66 control connection started
332     + #if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL: Client (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}) control connection started/o) {
333     + # #$1: date $2:pid $3.$4.$5.$6:ip
334     + # my $date=mkmysqldate($1);
335     + # my $ip=ipdot2ipnum($3,$4,$5,$6);
336     + # execute_sql_query("UPDATE vpn SET ip=$ip where pid_pptpd=$2 and debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1");
337     + # next;
338     + #}
339     +
340     + ##VPN checkip pid_pppd
341     + ##Jun 25 15:43:33 test pptpd[637]: CTRL (PPPD Launcher): local address = 192.168.2.1
342     + ## does not exist anymore
343     + #if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pptpd\[(\d+)\]: CTRL \(PPPD Launcher\): local address = (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/o) {
344     + # #$1: date $2:pid !!! PPPD !!! $3.$4.$5.$6:ip
345     + # my $date=mkmysqldate($1);
346     + # my $ip=ipdot2ipnum($3,$4,$5,$6);
347     + # execute_sql_query("UPDATE vpn SET pid_pppd=$2 where vpn_srv=$ip and debut > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1");
348     + # next;
349     + #}
350     +
351     + ##Deprecated !!! Dans sme7, l'auth se fait via Radius, qui ne loggue rien par défaut => pas moyen de connaitre simplement le login
352     + ##VPN login
353     + ##Jun 25 15:43:36 test pppd[637]: CHAP peer authentication succeeded for rv
354     + #if($l =~ /(\w{3}\s{1,2}\d{1,2} [0-9:]{8}) $SystemName pppd\[(\d+)\]: CHAP peer authentication succeeded for ([0-9a-z-]+)/o) {
355     + # #$1: date $2:pid $3:login
356     + # my $date=mkmysqldate($1);
357     + # execute_sql_query("UPDATE vpn SET login='$3' where pid_pppd=$2 and debut > '$date' - interval 20 second ORDER BY debut DESC LIMIT 1");
358     + # next;
359     + #}
360    
361     #PPPOE && VPN !!! temps de connexion
362     #Jul 15 12:49:58 sas pppd[1878]: Connect time 1440.0 minutes.
363     @@ -746,7 +832,7 @@ sub parse_logs {
364     if ($reslt != "0E0") { $requete.="pppoe ";}
365     #sinon c une fin de cnx vpn
366     else { $requete.="vpn ";}
367     - $requete.="SET duree=sec_to_time($3*60), fin='$date' where pid_pppd=$2";
368     + $requete.="SET duree=sec_to_time($3*60), fin='$date' where pid_pppd=$2 ORDER BY debut DESC LIMIT 1";
369     execute_sql_query($requete);
370     next;
371     }
372     @@ -764,8 +850,8 @@ sub parse_logs {
373     if ($reslt != "0E0") { $requete.="pppoe ";}
374     #sinon c une fin de cnx vpn
375     else { $requete.="vpn ";}
376     - $requete.="SET volume_out=$3, volume_in=$4 where pid_pppd=$2 and fin > '$date' - interval 5 second";
377     - execute_sql_query($requete);
378     + $requete.="SET volume_out=$3, volume_in=$4 where pid_pppd=$2 and fin > '$date' - interval 5 second ORDER BY debut DESC LIMIT 1";
379     +
380     next;
381     }
382     }
383     @@ -773,6 +859,8 @@ sub parse_logs {
384     # libération du fichier de log courant, enregistrement de la position
385     tell_log("$logdir$nom", $fh);
386     }
387     +
388     +
389     deconnectBD();
390     }
391    

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