From c1dd3fe4be4f4653bc42750def824aa39dafaf7c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 9 Sep 2015 16:51:20 +0200 Subject: [PATCH] Machine status page: Show disabled machines and some machine stats --- src/lib/Hydra/Controller/Root.pm | 16 ++++++++++++++-- src/root/machine-status.tt | 12 ++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 8c20c40c..14d22cb5 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -9,6 +9,7 @@ use Digest::SHA1 qw(sha1_hex); use Nix::Store; use Nix::Config; use Encode; +use JSON; # Put this controller at top-level. __PACKAGE__->config->{namespace} = ''; @@ -109,8 +110,19 @@ sub machines :Local Args(0) { my $machines = getMachines; # Add entry for localhost. - ${$machines}{''} //= {}; - delete ${$machines}{'localhost'}; + $machines->{''} //= {}; + delete $machines->{'localhost'}; + + my $status = $c->model('DB::SystemStatus')->find("queue-runner"); + if ($status) { + my $ms = decode_json($status->status)->{"machines"}; + foreach my $name (keys %{$ms}) { + $name = "" if $name eq "localhost"; + $machines->{$name} //= {disabled => 1}; + $machines->{$name}->{nrStepsDone} = $ms->{$name}->{nrStepsDone}; + $machines->{$name}->{avgStepBuildTime} = $ms->{$name}->{avgStepBuildTime} // 0; + } + } $c->stash->{machines} = $machines; $c->stash->{steps} = [ $c->model('DB::BuildSteps')->search( diff --git a/src/root/machine-status.tt b/src/root/machine-status.tt index 64290d36..8473d0b9 100644 --- a/src/root/machine-status.tt +++ b/src/root/machine-status.tt @@ -1,5 +1,6 @@ [% WRAPPER layout.tt title="Machine status" %] [% PROCESS common.tt %] +[% USE format %] @@ -17,9 +18,16 @@
- [% name %] + [% name %] [% IF m.value.systemTypes %] - ([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %][% system %][% END %]) + + ([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %][% system %][% END %]) + + [% END %] + [% IF m.value.nrStepsDone %] + + ([% m.value.nrStepsDone %] steps done, [% f = format("%.1f"); f(m.value.avgStepBuildTime) %] s/step) + [% END %]