Update portal status (#595)
This commit is contained in:
parent
3e4554ee45
commit
a70842603a
|
@ -4,7 +4,6 @@
|
||||||
* Calendar in notifications explorer
|
* Calendar in notifications explorer
|
||||||
* login history
|
* login history
|
||||||
* Test for Zero
|
* Test for Zero
|
||||||
* updateStatus( Main, SOAP server )
|
|
||||||
* replace SOAP by REST for notification creation
|
* replace SOAP by REST for notification creation
|
||||||
* "mail" in UserDB/*
|
* "mail" in UserDB/*
|
||||||
* checkLogins in SAML
|
* checkLogins in SAML
|
||||||
|
|
|
@ -5,6 +5,7 @@ package Lemonldap::NG::Handler::Lib::Status;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use POSIX qw(setuid setgid);
|
use POSIX qw(setuid setgid);
|
||||||
|
use JSON qw(to_json);
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
our $VERSION = '2.0.0';
|
our $VERSION = '2.0.0';
|
||||||
|
@ -173,7 +174,7 @@ sub run {
|
||||||
my $tmp = $1;
|
my $tmp = $1;
|
||||||
my $args = {};
|
my $args = {};
|
||||||
%$args = split( /[=&]/, $tmp ) if ($tmp);
|
%$args = split( /[=&]/, $tmp ) if ($tmp);
|
||||||
&head;
|
&head unless ( $args->{json} );
|
||||||
|
|
||||||
my ( $c, $m, $u );
|
my ( $c, $m, $u );
|
||||||
foreach my $user ( keys %{ $status->{user} } ) {
|
foreach my $user ( keys %{ $status->{user} } ) {
|
||||||
|
@ -194,8 +195,13 @@ sub run {
|
||||||
$m->{$_} = int( $m->{$_} ) if ( $m->{$_} > 99 );
|
$m->{$_} = int( $m->{$_} ) if ( $m->{$_} > 99 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# JSON values
|
||||||
|
if ( $args->{json} ) {
|
||||||
|
print to_json( { average => $m, total => $c } ) . "\nEND\n";
|
||||||
|
}
|
||||||
|
|
||||||
# Raw values (Dump)
|
# Raw values (Dump)
|
||||||
if ( $args->{'dump'} ) {
|
elsif ( $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";
|
||||||
|
|
|
@ -153,6 +153,11 @@ sub do {
|
||||||
my $err = $req->error( $self->process($req) );
|
my $err = $req->error( $self->process($req) );
|
||||||
|
|
||||||
# TODO: updateStatus
|
# TODO: updateStatus
|
||||||
|
if ( my $p = $self->HANDLER->tsv->{statusPipe} ) {
|
||||||
|
print $p ( $req->user ? $req->user : $req->address ) . ' => '
|
||||||
|
. $req->uri
|
||||||
|
. " $err\n";
|
||||||
|
}
|
||||||
if ( $err == PE_SENDRESPONSE ) {
|
if ( $err == PE_SENDRESPONSE ) {
|
||||||
return $req->response;
|
return $req->response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ package Lemonldap::NG::Portal::Plugins::Status;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Mouse;
|
use Mouse;
|
||||||
|
use JSON qw(from_json);
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
|
|
||||||
our $VERSION = '2.0.0';
|
our $VERSION = '2.0.0';
|
||||||
|
@ -25,6 +26,29 @@ sub init {
|
||||||
sub status {
|
sub status {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
my $res = {};
|
my $res = {};
|
||||||
|
if ( my $p = $self->p->HANDLER->tsv->{statusPipe} ) {
|
||||||
|
print $p "STATUS json=1\n";
|
||||||
|
my $buf;
|
||||||
|
$p = $self->p->HANDLER->tsv->{statusOut};
|
||||||
|
while (<$p>) {
|
||||||
|
last if (/^END$/);
|
||||||
|
$buf .= $_;
|
||||||
|
}
|
||||||
|
if ($buf) {
|
||||||
|
eval { $res = from_json($buf) };
|
||||||
|
if ($@) {
|
||||||
|
$self->logger->error("JSON error: $@");
|
||||||
|
$self->logger->error("JSON: $buf");
|
||||||
|
}
|
||||||
|
foreach (qw(total average)) {
|
||||||
|
if ( $res->{$_} ) {
|
||||||
|
foreach my $k ( keys %{ $res->{$_} } ) {
|
||||||
|
delete $res->{$_}->{$k} unless ( $k =~ /^PORTAL/ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach my $type (qw(global persistent cas saml oidc)) {
|
foreach my $type (qw(global persistent cas saml oidc)) {
|
||||||
if ( $self->conf->{"${type}Storage"} ) {
|
if ( $self->conf->{"${type}Storage"} ) {
|
||||||
my %modOpts = (
|
my %modOpts = (
|
||||||
|
@ -38,7 +62,7 @@ sub status {
|
||||||
);
|
);
|
||||||
if (%$sessions) {
|
if (%$sessions) {
|
||||||
my @s = keys %$sessions;
|
my @s = keys %$sessions;
|
||||||
$res->{$type} = @s;
|
$res->{storage}->{$type} = @s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user