3
0
Fork 0
forked from mirrors/nixpkgs

prometheus-shelly-exporter: add NixOS module

This commit is contained in:
Pol Dellaiera 2023-01-30 18:58:42 +01:00
parent 79ce805761
commit 9f17e032e7
No known key found for this signature in database
GPG key ID: D476DFE9C67467CA
3 changed files with 42 additions and 0 deletions

View file

@ -64,6 +64,7 @@ let
"rspamd"
"rtl_433"
"script"
"shelly"
"snmp"
"smartctl"
"smokeping"

View file

@ -0,0 +1,27 @@
{ config, lib, pkgs, options }:
with lib;
let
cfg = config.services.prometheus.exporters.shelly;
in
{
port = 9784;
extraOpts = {
metrics-file = mkOption {
type = types.path;
description = lib.mdDoc ''
Path to the JSON file with the metric definitions
'';
};
};
serviceOpts = {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-shelly-exporter}/bin/shelly_exporter \
-metrics-file ${cfg.metrics-file} \
-listen-address ${cfg.listenAddress}:${toString cfg.port}
'';
};
};
}

View file

@ -1060,6 +1060,20 @@ let
'';
};
shelly = {
exporterConfig = {
enable = true;
metrics-file = "${pkgs.writeText "test.json" ''{}''}";
};
exporterTest = ''
wait_for_unit("prometheus-shelly-exporter.service")
wait_for_open_port(9784)
wait_until_succeeds(
"curl -sSf 'localhost:9784/metrics'"
)
'';
};
script = {
exporterConfig = {
enable = true;