mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
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"
|
"rspamd"
|
||||||
"rtl_433"
|
"rtl_433"
|
||||||
"script"
|
"script"
|
||||||
|
"shelly"
|
||||||
"snmp"
|
"snmp"
|
||||||
"smartctl"
|
"smartctl"
|
||||||
"smokeping"
|
"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 = {
|
script = {
|
||||||
exporterConfig = {
|
exporterConfig = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue