This is currently done by a separate program that periodically calls "hydra-queue-runner –status". Eventually, I'll do this in the queue runner directly.
Fixes #220.
DODOGD7MRCMRVGX23RPY2243WG54HCMCEZ6DCHOGID3GBQB66CXQC
NetStatsd = buildPerlPackage {
name = "Net-Statsd-0.11";
src = fetchurl {
url = mirror://cpan/authors/id/C/CO/COSIMO/Net-Statsd-0.11.tar.gz;
sha256 = "0f56c95846c7e65e6d32cec13ab9df65716429141f106d2dc587f1de1e09e163";
};
meta = {
description = "Sends statistics to the stats daemon over UDP";
license = "perl";
};
};
#! /run/current-system/sw/bin/perl
use strict;
use utf8;
use Net::Statsd;
use JSON;
STDERR->autoflush(1);
binmode STDERR, ":encoding(utf8)";
sub gauge {
my ($name, $val) = @_;
die unless defined $val;
Net::Statsd::gauge($name, $val);
}
sub sendQueueRunnerStats {
my $s = `hydra-queue-runner --status`;
die "cannot get queue runner stats\n" if $? != 0;
my $json = decode_json($s) or die "cannot decode queue runner status";
return if $json->{status} ne "up";
gauge("hydra.queue.steps.active", $json->{nrActiveSteps});
gauge("hydra.queue.steps.building", $json->{nrStepsBuilding});
gauge("hydra.queue.steps.runnable", $json->{nrRunnableSteps});
gauge("hydra.queue.steps.unfinished", $json->{nrUnfinishedSteps});
gauge("hydra.queue.steps.finished", $json->{nrStepsDone});
gauge("hydra.queue.steps.retries", $json->{nrRetries});
gauge("hydra.queue.steps.max_retries", $json->{maxNrRetries});
if ($json->{nrStepsDone}) {
gauge("hydra.queue.steps.avg_total_time", $json->{avgStepTime});
gauge("hydra.queue.steps.avg_build_time", $json->{avgStepBuildTime});
}
gauge("hydra.queue.builds.read", $json->{nrBuildsRead});
gauge("hydra.queue.builds.unfinished", $json->{nrQueuedBuilds});
gauge("hydra.queue.builds.finished", $json->{nrBuildsDone});
gauge("hydra.queue.checks", $json->{nrQueueWakeups});
}
while (1) {
eval { sendQueueRunnerStats(); };
if ($@) { warn "$@"; }
sleep(30);
}