diff options
author | Matt Layher <mdlayher@gmail.com> | 2020-06-10 13:12:43 -0400 |
---|---|---|
committer | Matt Layher <mdlayher@gmail.com> | 2020-06-10 13:12:43 -0400 |
commit | e77426822ff234a50bf959384e86d78c0cf9a240 (patch) | |
tree | 4a86587b700db5c184bde58288614c9d55622eda /nixos | |
parent | 51da4293f5fbcd7766bfc832ebf283b5e288e1b9 (diff) | |
download | nixlib-e77426822ff234a50bf959384e86d78c0cf9a240.tar nixlib-e77426822ff234a50bf959384e86d78c0cf9a240.tar.gz nixlib-e77426822ff234a50bf959384e86d78c0cf9a240.tar.bz2 nixlib-e77426822ff234a50bf959384e86d78c0cf9a240.tar.lz nixlib-e77426822ff234a50bf959384e86d78c0cf9a240.tar.xz nixlib-e77426822ff234a50bf959384e86d78c0cf9a240.tar.zst nixlib-e77426822ff234a50bf959384e86d78c0cf9a240.zip |
nixos/prometheus-keylight-exporter: new module
Signed-off-by: Matt Layher <mdlayher@gmail.com>
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/keylight.nix | 19 | ||||
-rw-r--r-- | nixos/tests/prometheus-exporters.nix | 19 |
3 files changed, 39 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index f9ad1457fc85..b62a68860da8 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -28,6 +28,7 @@ let "dovecot" "fritzbox" "json" + "keylight" "mail" "mikrotik" "minio" diff --git a/nixos/modules/services/monitoring/prometheus/exporters/keylight.nix b/nixos/modules/services/monitoring/prometheus/exporters/keylight.nix new file mode 100644 index 000000000000..dfa56343b871 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/keylight.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, options }: + +with lib; + +let + cfg = config.services.prometheus.exporters.keylight; +in +{ + port = 9288; + serviceOpts = { + serviceConfig = { + ExecStart = '' + ${pkgs.prometheus-keylight-exporter}/bin/keylight_exporter \ + -metrics.addr ${cfg.listenAddress}:${toString cfg.port} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + }; + }; +} diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index 4fc3668cfafb..e2221352dcfe 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -202,6 +202,25 @@ let ''; }; + keylight = { + # A hardware device is required to properly test this exporter, so just + # perform a couple of basic sanity checks that the exporter is running + # and requires a target, but cannot reach a specified target. + exporterConfig = { + enable = true; + }; + exporterTest = '' + wait_for_unit("prometheus-keylight-exporter.service") + wait_for_open_port(9288) + succeed( + "curl -sS --write-out '%{http_code}' -o /dev/null http://localhost:9288/metrics | grep -q '400'" + ) + succeed( + "curl -sS --write-out '%{http_code}' -o /dev/null http://localhost:9288/metrics?target=nosuchdevice | grep -q '500'" + ) + ''; + }; + mail = { exporterConfig = { enable = true; |