Machine status page: Show disabled machines and some machine stats

This commit is contained in:
Eelco Dolstra 2015-09-09 16:51:20 +02:00
parent 6075ac6fed
commit c1dd3fe4be
2 changed files with 24 additions and 4 deletions

View file

@ -9,6 +9,7 @@ use Digest::SHA1 qw(sha1_hex);
use Nix::Store; use Nix::Store;
use Nix::Config; use Nix::Config;
use Encode; use Encode;
use JSON;
# Put this controller at top-level. # Put this controller at top-level.
__PACKAGE__->config->{namespace} = ''; __PACKAGE__->config->{namespace} = '';
@ -109,8 +110,19 @@ sub machines :Local Args(0) {
my $machines = getMachines; my $machines = getMachines;
# Add entry for localhost. # Add entry for localhost.
${$machines}{''} //= {}; $machines->{''} //= {};
delete ${$machines}{'localhost'}; 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->{machines} = $machines;
$c->stash->{steps} = [ $c->model('DB::BuildSteps')->search( $c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(

View file

@ -1,5 +1,6 @@
[% WRAPPER layout.tt title="Machine status" %] [% WRAPPER layout.tt title="Machine status" %]
[% PROCESS common.tt %] [% PROCESS common.tt %]
[% USE format %]
<table class="table table-condensed table-striped"> <table class="table table-condensed table-striped">
<thead> <thead>
@ -17,9 +18,16 @@
<thead> <thead>
<tr> <tr>
<th colspan="6"> <th colspan="6">
<tt>[% name %]</tt> <tt [% IF m.value.disabled %]style="text-decoration: line-through;"[% END %]>[% name %]</tt>
[% IF m.value.systemTypes %] [% IF m.value.systemTypes %]
([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %]<tt>[% system %]</tt>[% END %]) <span class="muted" style="font-weight: normal;">
([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %]<tt>[% system %]</tt>[% END %])
</span>
[% END %]
[% IF m.value.nrStepsDone %]
<span class="muted" style="font-weight: normal;">
([% m.value.nrStepsDone %] steps done, [% f = format("%.1f"); f(m.value.avgStepBuildTime) %] s/step)
</span>
[% END %] [% END %]
</th> </th>
</tr> </tr>