From cfc67572759af9a25ee037e7f7d129b518ebdc88 Mon Sep 17 00:00:00 2001 From: Florian Sesser <florian@private.storage> Date: Mon, 5 Sep 2022 14:39:29 +0000 Subject: [PATCH] Monitoring: Count Tahoe's corruption advisories --- nixos/modules/monitoring/exporters/tahoe.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nixos/modules/monitoring/exporters/tahoe.nix b/nixos/modules/monitoring/exporters/tahoe.nix index 0f24bb6c..b04d69db 100644 --- a/nixos/modules/monitoring/exporters/tahoe.nix +++ b/nixos/modules/monitoring/exporters/tahoe.nix @@ -1,7 +1,7 @@ # Tahoe Prometheus metrics collector # -# Scope: Retrieves OpenMetrics from Tahoe and puts them -# where textfile collector can find them. +# Scope: Retrieve metrics from Tahoe and put them where Prometheus' +# node-exporter's textfile collector can find them. # # Usage: Import this to every server running Tahoe. # @@ -55,14 +55,17 @@ in { description = "Tahoe metrics gathering service"; after = [ "tahoe.storage.service" ]; startAt = cfg.interval; - path = [ pkgs.curl ]; + path = [ pkgs.coreutils pkgs.findutils pkgs.curl ]; restartIfChanged = false; # Save to a temp file and then move atomically so the # textfile collector won't read a partial file. # See https://github.com/prometheus/node_exporter#textfile-collector script = '' - curl --silent --show-error --fail-with-body --output "${cfg.outFile}.tmp" "${cfg.scrapeEndpoint}" + NUM_CORRUPTION_ADVISORIES=$(find /storage/corruption-advisories/ -type f | wc -l) + echo "tahoe_corruption_advisories_total $NUM_CORRUPTION_ADVISORIES" > "${cfg.outFile}.tmp" + + curl --silent --show-error --fail-with-body "${cfg.scrapeEndpoint}" >> "${cfg.outFile}.tmp" mv "${cfg.outFile}.tmp" "${cfg.outFile}" ''; }; -- GitLab