prometheus-klipper-exporter: init at v0.11.2 (#348187)

This commit is contained in:
Ramses 2024-10-23 09:48:17 +02:00 committed by GitHub
commit f73e31408d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 90 additions and 0 deletions

View File

@ -50,6 +50,7 @@ let
"junos-czerwonk"
"kea"
"keylight"
"klipper"
"knot"
"lnd"
"mail"

View File

@ -0,0 +1,55 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.prometheus.exporters.klipper;
inherit (lib)
mkOption
mkMerge
mkIf
types
concatStringsSep
any
optionalString
;
moonraker = config.services.moonraker;
in
{
port = 9101;
extraOpts = {
package = lib.mkPackageOption pkgs "prometheus-klipper-exporter" { };
moonrakerApiKey = mkOption {
type = types.str;
default = "";
description = ''
API Key to authenticate with the Moonraker APIs.
Only needed if the host running the exporter is not a trusted client to Moonraker.
'';
};
};
serviceOpts = mkMerge (
[
{
serviceConfig = {
ExecStart = concatStringsSep " " [
"${cfg.package}/bin/prometheus-klipper-exporter"
(optionalString (cfg.moonrakerApiKey != "") "--moonraker.apikey ${cfg.moonrakerApiKey}")
"--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
"${concatStringsSep " " cfg.extraFlags}"
];
};
}
]
++ [
(mkIf config.services.moonraker.enable {
after = [ "moonraker.service" ];
requires = [ "moonraker.service" ];
})
]
);
}

View File

@ -0,0 +1,34 @@
{
lib,
buildGoModule,
fetchFromGitHub,
nixosTests,
}:
buildGoModule rec {
pname = "prometheus-klipper-exporter";
version = "0.11.2";
src = fetchFromGitHub {
owner = "scross01";
repo = "prometheus-klipper-exporter";
rev = "v${version}";
sha256 = "sha256-ow7bzgaY4pYccslITlkNBKfZBJv9uwPk25I1Y3bnjbU=";
};
vendorHash = "sha256-0nbLHZ2WMLMK0zKZuUYz355K01Xspn9svmlFCtQjed0=";
doCheck = true;
passthru.tests = {
inherit (nixosTests.prometheus-exporters) process;
};
meta = with lib; {
description = " Prometheus Exporter for Klipper ";
homepage = "https://github.com/scross01/prometheus-klipper-exporter";
license = licenses.mit;
maintainers = with maintainers; [ wulfsta ];
platforms = platforms.linux;
};
}