diff --git a/TODO-2.0.md b/TODO-2.0.md
index 1d8699d50..4751ee07b 100644
--- a/TODO-2.0.md
+++ b/TODO-2.0.md
@@ -4,7 +4,6 @@
* Calendar in notifications explorer
* login history
* Test for Zero
-* updateStatus( Main, SOAP server )
* replace SOAP by REST for notification creation
* "mail" in UserDB/*
* checkLogins in SAML
diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm
index fe0f853a8..c76cb1f7a 100644
--- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm
+++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/Status.pm
@@ -5,6 +5,7 @@ package Lemonldap::NG::Handler::Lib::Status;
use strict;
use POSIX qw(setuid setgid);
+use JSON qw(to_json);
use Data::Dumper;
our $VERSION = '2.0.0';
@@ -173,7 +174,7 @@ sub run {
my $tmp = $1;
my $args = {};
%$args = split( /[=&]/, $tmp ) if ($tmp);
- &head;
+ &head unless ( $args->{json} );
my ( $c, $m, $u );
foreach my $user ( keys %{ $status->{user} } ) {
@@ -194,8 +195,13 @@ sub run {
$m->{$_} = int( $m->{$_} ) if ( $m->{$_} > 99 );
}
+ # JSON values
+ if ( $args->{json} ) {
+ print to_json( { average => $m, total => $c } ) . "\nEND\n";
+ }
+
# Raw values (Dump)
- if ( $args->{'dump'} ) {
+ elsif ( $args->{'dump'} ) {
print "
\n";
print Dumper( $status, $activity, $count );
print "
\n";
diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
index 0e94ccc15..9067abcfe 100644
--- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
+++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
@@ -153,6 +153,11 @@ sub do {
my $err = $req->error( $self->process($req) );
# 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 ) {
return $req->response;
}
diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/Status.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/Status.pm
index 34a170f06..34f1ae20b 100644
--- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/Status.pm
+++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/Status.pm
@@ -7,6 +7,7 @@ package Lemonldap::NG::Portal::Plugins::Status;
use strict;
use Mouse;
+use JSON qw(from_json);
use MIME::Base64;
our $VERSION = '2.0.0';
@@ -25,6 +26,29 @@ sub init {
sub status {
my ( $self, $req ) = @_;
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)) {
if ( $self->conf->{"${type}Storage"} ) {
my %modOpts = (
@@ -38,7 +62,7 @@ sub status {
);
if (%$sessions) {
my @s = keys %$sessions;
- $res->{$type} = @s;
+ $res->{storage}->{$type} = @s;
}
}
}