summaryrefslogtreecommitdiffstats
path: root/nixos/modules
diff options
context:
space:
mode:
authorThomas Gerbet <thomas@gerbet.me>2023-02-02 00:11:56 +0100
committerGitHub <noreply@github.com>2023-02-02 00:11:56 +0100
commit34f5d8cd2408228aac02861acc0995b7dfd23272 (patch)
treedfd25d4998585776575a2cd1cd996fe3bdf78f98 /nixos/modules
parente5675cee8179e940e96bcba2eeb1501a1cbc970f (diff)
parent9f17e032e7e7c34ddf8c04472bee9d627951fc44 (diff)
Merge pull request #213534 from drupol/add-prometheus-shelly-exporter
prometheus-shelly-exporter: init at 1.0.0
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix1
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/shelly.nix27
2 files changed, 28 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
index 23cac6793cc6..fd40dce1410c 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -64,6 +64,7 @@ let
"rspamd"
"rtl_433"
"script"
+ "shelly"
"snmp"
"smartctl"
"smokeping"
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/shelly.nix b/nixos/modules/services/monitoring/prometheus/exporters/shelly.nix
new file mode 100644
index 000000000000..b9cfd1b1e84a
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/shelly.nix
@@ -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}
+ '';
+ };
+ };
+}