diff --git a/nixos/modules/monitoring/exporters/megacli2prom.nix b/nixos/modules/monitoring/exporters/megacli2prom.nix index b364088aa148a2faa58a6ac34980120f8d7bf9d0..a38f1ccc18b59073ff835e50babeb565f79a20b8 100644 --- a/nixos/modules/monitoring/exporters/megacli2prom.nix +++ b/nixos/modules/monitoring/exporters/megacli2prom.nix @@ -42,7 +42,13 @@ in { wantedBy = [ "multi-user.target" ]; startAt = cfg.interval; path = [ pkgs.megacli ]; - script = "${ourpkgs.megacli2prom}/bin/megacli2prom > ${cfg.outFile}"; + # 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 = '' + "${ourpkgs.megacli2prom}/bin/megacli2prom" > "${cfg.outFile}.tmp" + mv "${cfg.outFile}.tmp" "${cfg.outFile}" + ''; }; }; } diff --git a/nixos/modules/monitoring/exporters/tahoe.nix b/nixos/modules/monitoring/exporters/tahoe.nix index f63c21e3b0861c9ddeb94a3b4784a8d8a78d9377..9b46adc3b551182d39d03b55a74dccf2b0e565e5 100644 --- a/nixos/modules/monitoring/exporters/tahoe.nix +++ b/nixos/modules/monitoring/exporters/tahoe.nix @@ -46,8 +46,8 @@ in { startAt = cfg.interval; path = [ pkgs.curl ]; - # Curl to a temp file and then move atomically so textfile collector - # won't read a partial file. + # 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}"