prometheus-shelly-exporter: add NixOS module
This commit is contained in:
parent
79ce805761
commit
9f17e032e7
3 changed files with 42 additions and 0 deletions
|
@ -64,6 +64,7 @@ let
|
|||
"rspamd"
|
||||
"rtl_433"
|
||||
"script"
|
||||
"shelly"
|
||||
"snmp"
|
||||
"smartctl"
|
||||
"smokeping"
|
||||
|
|
|
@ -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}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue