|
|
|
@ -6,6 +6,7 @@ package Lemonldap::NG::Handler::Lib::Status; |
|
|
|
|
use strict; |
|
|
|
|
use POSIX qw(setuid setgid); |
|
|
|
|
use JSON qw(to_json); |
|
|
|
|
use IO::Select; |
|
|
|
|
|
|
|
|
|
our $VERSION = '2.0.0'; |
|
|
|
|
|
|
|
|
@ -115,8 +116,15 @@ eval { |
|
|
|
|
# - display results |
|
|
|
|
sub run { |
|
|
|
|
$| = 1; |
|
|
|
|
my ( $lastMn, $mn, $count, $cache ); |
|
|
|
|
while (<STDIN>) { |
|
|
|
|
my ( $lastMn, $mn, $count, $cache, @ready ); |
|
|
|
|
my $sel = IO::Select->new; |
|
|
|
|
$sel->add( \*STDIN ); |
|
|
|
|
while ( @ready = $sel->can_read ) { |
|
|
|
|
foreach my $fh (@ready) { |
|
|
|
|
if($fh == \*STDIN and $fh->eof) { |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
$_ = $fh->getline or next; |
|
|
|
|
$mn = int( time / 60 ) - $start + 1; |
|
|
|
|
|
|
|
|
|
# Cleaning activity array |
|
|
|
@ -171,7 +179,7 @@ sub run { |
|
|
|
|
# $args contains parameters passed to url status page (a=1 for example |
|
|
|
|
# if request is http://test.example.com/status?a=1). To be used |
|
|
|
|
# later... |
|
|
|
|
elsif (/^STATUS(?:\s+(\S+))?$/) { |
|
|
|
|
elsif (/^STATUS\s*(\S+)?$/) { |
|
|
|
|
my $tmp = $1; |
|
|
|
|
my $args = {}; |
|
|
|
|
%$args = split( /[=&]/, $tmp ) if ($tmp); |
|
|
|
@ -203,8 +211,9 @@ sub run { |
|
|
|
|
|
|
|
|
|
# Raw values (Dump) |
|
|
|
|
elsif ( $args->{'dump'} ) { |
|
|
|
|
require Data::Dumper; |
|
|
|
|
print "<div id=\"dump\"><pre>\n"; |
|
|
|
|
print Dumper( $status, $activity, $count ); |
|
|
|
|
print Data::Dumper::Dumper( $status, $activity, $count ); |
|
|
|
|
print "</pre></div>\n"; |
|
|
|
|
&end; |
|
|
|
|
} |
|
|
|
@ -225,7 +234,8 @@ sub run { |
|
|
|
|
print "\n</pre></div>\n"; |
|
|
|
|
|
|
|
|
|
# Users connected |
|
|
|
|
print "<div id=\"users\"><p>\nTotal users : $u\n</p></div>\n"; |
|
|
|
|
print |
|
|
|
|
"<div id=\"users\"><p>\nTotal users : $u\n</p></div>\n"; |
|
|
|
|
|
|
|
|
|
# Local cache |
|
|
|
|
if ($cache) { |
|
|
|
@ -249,12 +259,14 @@ sub run { |
|
|
|
|
print |
|
|
|
|
"<h2>Virtual Host activity</h2>\n<div id=\"vhost\"><pre>\n"; |
|
|
|
|
foreach ( |
|
|
|
|
sort { $count->{vhost}->{$b} <=> $count->{vhost}->{$a} } |
|
|
|
|
sort { |
|
|
|
|
$count->{vhost}->{$b} <=> $count->{vhost}->{$a} |
|
|
|
|
} |
|
|
|
|
keys %{ $count->{vhost} } |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
print |
|
|
|
|
sprintf( "%-40s : %6d\n", $_, $count->{vhost}->{$_} ); |
|
|
|
|
print sprintf( "%-40s : %6d\n", |
|
|
|
|
$_, $count->{vhost}->{$_} ); |
|
|
|
|
} |
|
|
|
|
print "\n</pre></div>\n"; |
|
|
|
|
|
|
|
|
@ -269,8 +281,8 @@ sub run { |
|
|
|
|
last if ( $i == $args->{top} ); |
|
|
|
|
last unless ( $count->{uri}->{$_} ); |
|
|
|
|
$i++; |
|
|
|
|
print |
|
|
|
|
sprintf( "%-80s : %6d\n", $_, $count->{uri}->{$_} ); |
|
|
|
|
print sprintf( "%-80s : %6d\n", |
|
|
|
|
$_, $count->{uri}->{$_} ); |
|
|
|
|
} |
|
|
|
|
print "\n</pre></div>\n"; |
|
|
|
|
|
|
|
|
@ -279,7 +291,7 @@ sub run { |
|
|
|
|
"<table class=\"topByCat\"><tr><th style=\"width:20%\">Code</th><th>Top</th></tr>\n"; |
|
|
|
|
foreach my $cat ( split /,/, $args->{categories} ) { |
|
|
|
|
print |
|
|
|
|
"<tr><td>$cat</td><td nowrap>\n<div id=\"$cat\">\n"; |
|
|
|
|
"<tr><td>$cat</td><td nowrap>\n<div id=\"$cat\">\n"; |
|
|
|
|
topByCat( $cat, $args->{top} ); |
|
|
|
|
print "</div>\n</td></tr>"; |
|
|
|
|
} |
|
|
|
@ -293,6 +305,7 @@ sub run { |
|
|
|
|
print STDERR "Status: Unknown command line : $_"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
## @rfn private string timeUp(int d) |
|
|
|
|