Merge pull request #213534 from drupol/add-prometheus-shelly-exporter

prometheus-shelly-exporter: init at 1.0.0
This commit is contained in:
Thomas Gerbet 2023-02-02 00:11:56 +01:00 committed by GitHub
commit 34f5d8cd24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 67 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;

View File

@ -0,0 +1,24 @@
{ lib, buildGoModule, fetchFromGitHub, nixosTests }:
buildGoModule rec {
pname = "shelly_exporter";
version = "1.0.0";
src = fetchFromGitHub {
owner = "aexel90";
repo = pname;
rev = "v${version}";
sha256 = "sha256-L0TuBDq5eEahQvzqd1WuvmXuQbbblCM+Nvj15IybnVo=";
};
vendorSha256 = "sha256-BCrge2xLT4b4wpYA+zcsH64a/nfV8+HeZF7L49p2gEw=";
passthru.tests = { inherit (nixosTests.prometheus-exporters) shelly; };
meta = with lib; {
description = "Shelly humidity sensor exporter for prometheus";
homepage = "https://github.com/aexel90/shelly_exporter";
license = licenses.asl20;
maintainers = with maintainers; [drupol];
};
}

View File

@ -25094,6 +25094,7 @@ with pkgs;
prometheus-rtl_433-exporter = callPackage ../servers/monitoring/prometheus/rtl_433-exporter.nix { };
prometheus-sachet = callPackage ../servers/monitoring/prometheus/sachet.nix { };
prometheus-script-exporter = callPackage ../servers/monitoring/prometheus/script-exporter.nix { };
prometheus-shelly-exporter = callPackage ../servers/monitoring/prometheus/shelly-exporter.nix { };
prometheus-smartctl-exporter = callPackage ../servers/monitoring/prometheus/smartctl-exporter { };
prometheus-smokeping-prober = callPackage ../servers/monitoring/prometheus/smokeping-prober.nix { };
prometheus-snmp-exporter = callPackage ../servers/monitoring/prometheus/snmp-exporter.nix { };