LEMONLDAP::NG : little bug in Simple.pm : previous $datas was used for new users in status collect
Uptime displayed now in Status.pm
This commit is contained in:
parent
a3297e2dbb
commit
851d0d0caa
|
@ -482,9 +482,8 @@ sub forgeHeadersInit {
|
|||
}
|
||||
|
||||
sub updateStatus {
|
||||
my ( $class, $url, $action ) = @_;
|
||||
print $statusPipe ( $datas->{$whatToTrace} ? $datas->{$whatToTrace} : '' )
|
||||
. " => "
|
||||
my ( $class, $user, $url, $action ) = @_;
|
||||
print $statusPipe "$user => "
|
||||
. $apacheRequest->hostname
|
||||
. "$url $action\n"
|
||||
if ($statusPipe);
|
||||
|
@ -508,12 +507,12 @@ sub grant {
|
|||
sub forbidden {
|
||||
my $class = shift;
|
||||
if ( $datas->{_logout} ) {
|
||||
$class->updateStatus( $_[0], 'LOGOUT' );
|
||||
$class->updateStatus( $datas->{$whatToTrace}, $_[0], 'LOGOUT' );
|
||||
my $u = $datas->{_logout};
|
||||
$class->localUnlog;
|
||||
return $class->goToPortal( $u, 'logout=1' );
|
||||
}
|
||||
$class->updateStatus( $_[0], 'REJECT' );
|
||||
$class->updateStatus( $datas->{$whatToTrace}, $_[0], 'REJECT' );
|
||||
$class->logForbidden(@_);
|
||||
return FORBIDDEN;
|
||||
}
|
||||
|
@ -593,7 +592,7 @@ sub run ($$) {
|
|||
my $id;
|
||||
unless ( $id = $class->fetchId ) {
|
||||
$class->lmLog( "$class: No cookie found", 'info' );
|
||||
$class->updateStatus( $apacheRequest->uri, 'REDIRECT' );
|
||||
$class->updateStatus( $apacheRequest->connection->remote_ip, $apacheRequest->uri, 'REDIRECT' );
|
||||
return $class->goToPortal($uri);
|
||||
}
|
||||
|
||||
|
@ -613,7 +612,7 @@ sub run ($$) {
|
|||
# The cookie isn't yet available
|
||||
$class->lmLog( "The cookie $id isn't yet available: $@",
|
||||
'info' );
|
||||
$class->updateStatus( $apacheRequest->uri, 'EXPIRED' );
|
||||
$class->updateStatus( $apacheRequest->connection->remote_ip, $apacheRequest->uri, 'EXPIRED' );
|
||||
return $class->goToPortal($uri);
|
||||
}
|
||||
$datas->{$_} = $h{$_} foreach ( keys %h );
|
||||
|
@ -632,7 +631,7 @@ sub run ($$) {
|
|||
|
||||
# AUTHORIZATION
|
||||
return $class->forbidden($uri) unless ( $class->grant($uri) );
|
||||
$class->updateStatus( $apacheRequest->uri, 'OK' );
|
||||
$class->updateStatus( $datas->{$whatToTrace}, $apacheRequest->uri, 'OK' );
|
||||
$class->lmLog(
|
||||
"User "
|
||||
. $datas->{$whatToTrace}
|
||||
|
@ -695,7 +694,7 @@ sub unlog ($$) {
|
|||
my $class;
|
||||
( $class, $apacheRequest ) = @_;
|
||||
$class->localUnlog;
|
||||
$class->updateStatus( $apacheRequest->uri, 'LOGOUT' );
|
||||
$class->updateStatus( $apacheRequest->connection->remote_ip, $apacheRequest->uri, 'LOGOUT' );
|
||||
return $class->goToPortal( '/', 'logout=1' );
|
||||
}
|
||||
|
||||
|
@ -714,7 +713,7 @@ sub redirectFilter {
|
|||
}
|
||||
while ( $f->read( my $buffer, 1024 ) ) {
|
||||
}
|
||||
$class->updateStatus( 'filter', 'REDIRECT' );
|
||||
$class->updateStatus( ( $datas->{$whatToTrace} ? $datas->{$whatToTrace} : $f->r->connection->remote_ip ), 'filter', 'REDIRECT' );
|
||||
return REDIRECT;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,9 +87,9 @@ sub run {
|
|||
# if request is http://test.example.com/status?a=1). To be used
|
||||
# later...
|
||||
elsif (/^STATUS(?:\s+(\S+))?$/) {
|
||||
my $tmp = $1;
|
||||
my $tmp = $1;
|
||||
my $args = {};
|
||||
%$args = split (/[=&]/,$tmp) if($tmp);
|
||||
%$args = split( /[=&]/, $tmp ) if ($tmp);
|
||||
&head;
|
||||
#print Dumper($args),&end;next;
|
||||
my ( $c, $m, $u );
|
||||
|
@ -136,38 +136,55 @@ sub run {
|
|||
$args->{categories} ||= 'REJECT,PORTAL_FIRSTACCESS,LOGOUT,OK';
|
||||
# General
|
||||
print "<h2>Top used URI</h2>\n<div id=\"uri\"><pre>\n";
|
||||
foreach my $uri (keys %{$status->{uri}}) {
|
||||
$count->{$uri} += $_ foreach (values %{$status->{uri}->{$uri}});
|
||||
foreach my $uri ( keys %{ $status->{uri} } ) {
|
||||
$count->{$uri} += $_
|
||||
foreach ( values %{ $status->{uri}->{$uri} } );
|
||||
}
|
||||
my $i=0;
|
||||
foreach (sort {$count->{$b} <=> $count->{$a}} keys %$count) {
|
||||
last if($i == $args->{top});
|
||||
last unless($count->{$_});
|
||||
my $i = 0;
|
||||
foreach ( sort { $count->{$b} <=> $count->{$a} } keys %$count )
|
||||
{
|
||||
last if ( $i == $args->{top} );
|
||||
last unless ( $count->{$_} );
|
||||
$i++;
|
||||
print sprintf( "%-80s : %4d\n", $_, $count->{$_} );
|
||||
}
|
||||
print "\n</pre></div>\n";
|
||||
# Top by category
|
||||
print "<table border=\"1\" width=\"100%\"><tr><th>Code</th><th>Top</ht></tr>\n";
|
||||
foreach my $cat (split /,/,$args->{categories}) {
|
||||
foreach my $cat ( split /,/, $args->{categories} ) {
|
||||
print "<tr><td><pre>$cat</pre></td><td nowrap>\n<div id=\"$cat\">\n";
|
||||
topByCat($cat,$args->{top});
|
||||
topByCat( $cat, $args->{top} );
|
||||
print "</div>\n</td></tr>";
|
||||
}
|
||||
print '</table>';
|
||||
print "</table>\n";
|
||||
}
|
||||
print "<div id=\"up\"><p>\nServer up for : "
|
||||
. &timeUp($mn)
|
||||
. "\n</p></div>\n";
|
||||
&end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub timeUp {
|
||||
my $d = shift;
|
||||
my $mn = $d % 60;
|
||||
$d = ( $d - $mn ) / 60;
|
||||
my $h = $d % 24;
|
||||
$d = ( $a - $h ) / 24;
|
||||
return "$d\d $h\h $mn\mn";
|
||||
}
|
||||
|
||||
sub topByCat {
|
||||
my($cat,$max) = @_;
|
||||
my $i=0;
|
||||
my ( $cat, $max ) = @_;
|
||||
my $i = 0;
|
||||
print "<pre>\n";
|
||||
foreach (sort {$status->{uri}->{$b}->{$cat} <=> $status->{uri}->{$a}->{$cat}} keys %{$status->{uri}}) {
|
||||
last if($i == $max);
|
||||
last unless($status->{uri}->{$_}->{$cat});
|
||||
foreach (
|
||||
sort { $status->{uri}->{$b}->{$cat} <=> $status->{uri}->{$a}->{$cat} }
|
||||
keys %{ $status->{uri} } )
|
||||
{
|
||||
last if ( $i == $max );
|
||||
last unless ( $status->{uri}->{$_}->{$cat} );
|
||||
$i++;
|
||||
print sprintf( "%-80s : %4d\n", $_, $status->{uri}->{$_}->{$cat} );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user