Handler: add some CSS styles to status page
This commit is contained in:
parent
b87c0a520b
commit
86a92b5a32
@ -6,6 +6,7 @@ package Lemonldap::NG::Handler::Status;
|
|||||||
use strict;
|
use strict;
|
||||||
use POSIX;
|
use POSIX;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
#inherits Cache::Cache
|
#inherits Cache::Cache
|
||||||
|
|
||||||
our $VERSION = "0.21";
|
our $VERSION = "0.21";
|
||||||
@ -15,6 +16,8 @@ our $activity = [];
|
|||||||
our $start = int( time / 60 );
|
our $start = int( time / 60 );
|
||||||
use constant MN_COUNT => 5;
|
use constant MN_COUNT => 5;
|
||||||
|
|
||||||
|
our $page_title = 'Lemonldap::NG statistics';
|
||||||
|
|
||||||
## @fn private hashRef portalTab()
|
## @fn private hashRef portalTab()
|
||||||
# @return Constant hash used to convert error codes into string.
|
# @return Constant hash used to convert error codes into string.
|
||||||
sub portalTab {
|
sub portalTab {
|
||||||
@ -112,7 +115,6 @@ sub run {
|
|||||||
%$args = split( /[=&]/, $tmp ) if ($tmp);
|
%$args = split( /[=&]/, $tmp ) if ($tmp);
|
||||||
&head;
|
&head;
|
||||||
|
|
||||||
#print Dumper($args),&end;next;
|
|
||||||
my ( $c, $m, $u );
|
my ( $c, $m, $u );
|
||||||
while ( my ( $user, $v ) = each( %{ $status->{user} } ) ) {
|
while ( my ( $user, $v ) = each( %{ $status->{user} } ) ) {
|
||||||
$u++ unless ( $user =~ /^\d+\.\d+\.\d+\.\d+$/ );
|
$u++ unless ( $user =~ /^\d+\.\d+\.\d+\.\d+$/ );
|
||||||
@ -130,11 +132,15 @@ sub run {
|
|||||||
$m->{$_} = sprintf( "%.2f", $m->{$_} / MN_COUNT );
|
$m->{$_} = sprintf( "%.2f", $m->{$_} / MN_COUNT );
|
||||||
$m->{$_} = int( $m->{$_} ) if ( $m->{$_} > 99 );
|
$m->{$_} = int( $m->{$_} ) if ( $m->{$_} > 99 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Raw values (Dump)
|
||||||
if ( $args->{'dump'} ) {
|
if ( $args->{'dump'} ) {
|
||||||
print "<div id=\"dump\"><pre>\n";
|
print "<div id=\"dump\"><pre>\n";
|
||||||
print Dumper( $status, $activity, $count );
|
print Dumper( $status, $activity, $count );
|
||||||
print "</pre></div>\n";
|
print "</pre></div>\n";
|
||||||
|
&end;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
# Total requests
|
# Total requests
|
||||||
print "<h2>Total</h2>\n<div id=\"total\"><pre>\n";
|
print "<h2>Total</h2>\n<div id=\"total\"><pre>\n";
|
||||||
@ -155,24 +161,32 @@ sub run {
|
|||||||
|
|
||||||
# Local cache
|
# Local cache
|
||||||
my @t =
|
my @t =
|
||||||
$refLocalStorage->get_keys( $localStorageOptions->{namespace} );
|
$refLocalStorage->get_keys(
|
||||||
|
$localStorageOptions->{namespace} );
|
||||||
print "<div id=\"cache\"><p>\nLocal Cache : " . @t
|
print "<div id=\"cache\"><p>\nLocal Cache : " . @t
|
||||||
. " objects\n</p></div>\n";
|
. " objects\n</p></div>\n";
|
||||||
|
|
||||||
|
# Uptime
|
||||||
|
print "<div id=\"up\"><p>\nServer up for : "
|
||||||
|
. &timeUp($mn)
|
||||||
|
. "\n</p></div>\n";
|
||||||
|
|
||||||
# Top uri
|
# Top uri
|
||||||
if ( $args->{top} ) {
|
if ( $args->{top} ) {
|
||||||
print "<hr/>\n";
|
print "<hr/>\n";
|
||||||
$args->{categories} ||= 'REJECT,PORTAL_FIRSTACCESS,LOGOUT,OK';
|
$args->{categories} ||=
|
||||||
|
'REJECT,PORTAL_FIRSTACCESS,LOGOUT,OK';
|
||||||
|
|
||||||
# Vhost activity
|
# Vhost activity
|
||||||
print
|
print
|
||||||
"<h2>Virtual Host activity</h2>\n<div id=\"vhost\"><pre>\n";
|
"<h2>Virtual Host activity</h2>\n<div id=\"vhost\"><pre>\n";
|
||||||
foreach (
|
foreach (
|
||||||
sort { $count->{vhost}->{$b} <=> $count->{vhost}->{$a} }
|
sort { $count->{vhost}->{$b} <=> $count->{vhost}->{$a} }
|
||||||
keys %{ $count->{vhost} }
|
keys %{ $count->{vhost} }
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
print sprintf( "%-40s : %6d\n", $_, $count->{vhost}->{$_} );
|
print
|
||||||
|
sprintf( "%-40s : %6d\n", $_, $count->{vhost}->{$_} );
|
||||||
}
|
}
|
||||||
print "\n</pre></div>\n";
|
print "\n</pre></div>\n";
|
||||||
|
|
||||||
@ -187,27 +201,27 @@ sub run {
|
|||||||
last if ( $i == $args->{top} );
|
last if ( $i == $args->{top} );
|
||||||
last unless ( $count->{uri}->{$_} );
|
last unless ( $count->{uri}->{$_} );
|
||||||
$i++;
|
$i++;
|
||||||
print sprintf( "%-80s : %6d\n", $_, $count->{uri}->{$_} );
|
print
|
||||||
|
sprintf( "%-80s : %6d\n", $_, $count->{uri}->{$_} );
|
||||||
}
|
}
|
||||||
print "\n</pre></div>\n";
|
print "\n</pre></div>\n";
|
||||||
|
|
||||||
# Top by category
|
# Top by category
|
||||||
print
|
print
|
||||||
"<table border=\"1\" width=\"100%\"><tr><th>Code</th><th>Top</ht></tr>\n";
|
"<table class=\"topByCat\"><tr><th style=\"width:20%\">Code</th><th>Top</th></tr>\n";
|
||||||
foreach my $cat ( split /,/, $args->{categories} ) {
|
foreach my $cat ( split /,/, $args->{categories} ) {
|
||||||
print
|
print
|
||||||
"<tr><td><pre>$cat</pre></td><td nowrap>\n<div id=\"$cat\">\n";
|
"<tr><td>$cat</td><td nowrap>\n<div id=\"$cat\">\n";
|
||||||
topByCat( $cat, $args->{top} );
|
topByCat( $cat, $args->{top} );
|
||||||
print "</div>\n</td></tr>";
|
print "</div>\n</td></tr>";
|
||||||
}
|
}
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
}
|
}
|
||||||
print "<div id=\"up\"><p>\nServer up for : "
|
|
||||||
. &timeUp($mn)
|
|
||||||
. "\n</p></div>\n";
|
|
||||||
&end;
|
&end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## @rfn private string timeUp(int d)
|
## @rfn private string timeUp(int d)
|
||||||
@ -253,11 +267,76 @@ sub head {
|
|||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
|
||||||
<head>
|
<head>
|
||||||
<title>Lemonldap::NG Status</title>
|
<title>$page_title</title>
|
||||||
|
<style type="text/css">
|
||||||
|
<!--
|
||||||
|
body{
|
||||||
|
background: #000;
|
||||||
|
color:#fff;
|
||||||
|
padding:10px 50px;
|
||||||
|
font-family:sans-serif;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
margin:5px 20px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
margin:30px 0 0 0;
|
||||||
|
padding:0 10px;
|
||||||
|
border-left:20px solid orange;
|
||||||
|
line-height:20px;
|
||||||
|
}
|
||||||
|
hr {
|
||||||
|
height:1px;
|
||||||
|
background-color:orange;
|
||||||
|
margin:10px 0;
|
||||||
|
border:0;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color:orange;
|
||||||
|
text-decoration:none;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
#footer {
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
#footer a {
|
||||||
|
margin-left:10px;
|
||||||
|
padding:5px;
|
||||||
|
border-bottom:1px solid #fff;
|
||||||
|
}
|
||||||
|
#footer a:hover {
|
||||||
|
border-color:orange;
|
||||||
|
}
|
||||||
|
table.topByCat {
|
||||||
|
table-layout:fixed;
|
||||||
|
border-collapse:collapse;
|
||||||
|
border:1px solid #fff;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
table.topByCat td, table.topByCat th {
|
||||||
|
padding:5px;
|
||||||
|
border:1px solid #fff;
|
||||||
|
}
|
||||||
|
table.topByCat th {
|
||||||
|
color:orange;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
-->
|
||||||
|
</style>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Lemonldap::NG Status</h1>
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td style="width:30px;height:30px;background:orange;"> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td rowspan=2><h1>$page_title</h1></td>
|
||||||
|
</tr>
|
||||||
|
</tr>
|
||||||
|
<td> </td>
|
||||||
|
<td style="width:30px;height:30px;background:orange;"> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,18 +345,23 @@ EOF
|
|||||||
sub end {
|
sub end {
|
||||||
print <<"EOF";
|
print <<"EOF";
|
||||||
<hr/>
|
<hr/>
|
||||||
|
<div id="footer">
|
||||||
<script type="text/javascript" language="Javascript">
|
<script type="text/javascript" language="Javascript">
|
||||||
//<!--
|
//<!--
|
||||||
var a = document.location.href;
|
var a = document.location.href;
|
||||||
a=a.replace(/\\?.*\$/,'');
|
a=a.replace(/\\?.*\$/,'');
|
||||||
|
document.write('<a href="'+a+'">Standard view</a>');
|
||||||
document.write('<a href="'+a+'?top=10&categories=REJECT,PORTAL_FIRSTACCESS,LOGOUT,OK">Top 10</a>');
|
document.write('<a href="'+a+'?top=10&categories=REJECT,PORTAL_FIRSTACCESS,LOGOUT,OK">Top 10</a>');
|
||||||
|
document.write('<a href="'+a+'?dump=1">Raw results</a>');
|
||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
END
|
END
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
@ -310,7 +394,7 @@ Create your own package (example using a central configuration database):
|
|||||||
dbiUser => "lemonldap",
|
dbiUser => "lemonldap",
|
||||||
dbiPassword => "password",
|
dbiPassword => "password",
|
||||||
}
|
}
|
||||||
# ... See Lemonldap::N::Handler
|
# ... See Lemonldap::NG::Handler
|
||||||
} );
|
} );
|
||||||
|
|
||||||
=head2 Configure Apache
|
=head2 Configure Apache
|
||||||
|
Loading…
Reference in New Issue
Block a user