Merge pull request #201817 from jhh/nut-exporter

authored by Sandro and committed by GitHub 068e7cb3 cee75d23

+80
+6
maintainers/maintainer-list.nix
··· 6557 githubId = 6445082; 6558 name = "Joseph Lukasik"; 6559 }; 6560 jhhuh = { 6561 email = "jhhuh.note@gmail.com"; 6562 github = "jhhuh";
··· 6557 githubId = 6445082; 6558 name = "Joseph Lukasik"; 6559 }; 6560 + jhh = { 6561 + email = "jeff@j3ff.io"; 6562 + github = "jhh"; 6563 + githubId = 14412; 6564 + name = "Jeff Hutchison"; 6565 + }; 6566 jhhuh = { 6567 email = "jhhuh.note@gmail.com"; 6568 github = "jhhuh";
+1
nixos/modules/services/monitoring/prometheus/exporters.nix
··· 51 "nginx" 52 "nginxlog" 53 "node" 54 "openldap" 55 "openvpn" 56 "pihole"
··· 51 "nginx" 52 "nginxlog" 53 "node" 54 + "nut" 55 "openldap" 56 "openvpn" 57 "pihole"
+50
nixos/modules/services/monitoring/prometheus/exporters/nut.nix
···
··· 1 + { config, lib, pkgs, options }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.prometheus.exporters.nut; 7 + in 8 + { 9 + port = 9199; 10 + extraOpts = { 11 + nutServer = mkOption { 12 + type = types.str; 13 + default = "127.0.0.1"; 14 + description = lib.mdDoc '' 15 + Hostname or address of the NUT server 16 + ''; 17 + }; 18 + nutUser = mkOption { 19 + type = types.str; 20 + default = ""; 21 + example = "nut"; 22 + description = lib.mdDoc '' 23 + The user to log in into NUT server. If set, passwordPath should 24 + also be set. 25 + 26 + Default NUT configs usually permit reading variables without 27 + authentication. 28 + ''; 29 + }; 30 + passwordPath = mkOption { 31 + type = types.nullOr types.path; 32 + default = null; 33 + apply = final: if final == null then null else toString final; 34 + description = lib.mdDoc '' 35 + A run-time path to the nutUser password file, which should be 36 + provisioned outside of Nix store. 37 + ''; 38 + }; 39 + }; 40 + serviceOpts = { 41 + script = '' 42 + ${optionalString (cfg.passwordPath != null) 43 + "export NUT_EXPORTER_PASSWORD=$(cat ${toString cfg.passwordPath})"} 44 + ${pkgs.prometheus-nut-exporter}/bin/nut_exporter \ 45 + --nut.server=${cfg.nutServer} \ 46 + --web.listen-address="${cfg.listenAddress}:${toString cfg.port}" \ 47 + ${optionalString (cfg.nutUser != "") "--nut.username=${cfg.nutUser}"} 48 + ''; 49 + }; 50 + }
+22
pkgs/servers/monitoring/prometheus/nut-exporter.nix
···
··· 1 + { lib, buildGoModule, fetchFromGitHub }: 2 + 3 + buildGoModule rec { 4 + pname = "nut-exporter"; 5 + version = "2.4.2"; 6 + 7 + src = fetchFromGitHub { 8 + owner = "DRuggeri"; 9 + repo = "nut_exporter"; 10 + rev = "v${version}"; 11 + sha256 = "sha256-fymVx6FJGII2PmWXVfeCRTxfO+35bmyn/9iL0iPuBgo="; 12 + }; 13 + 14 + vendorSha256 = "sha256-ji8JlEYChPBakt5y6+zcm1l04VzZ0/fjfGFJ9p+1KHE="; 15 + 16 + meta = with lib; { 17 + description = "Prometheus exporter for Network UPS Tools"; 18 + homepage = "https://github.com/DRuggeri/nut_exporter"; 19 + license = licenses.asl20; 20 + maintainers = with maintainers; [ jhh ]; 21 + }; 22 + }
+1
pkgs/top-level/all-packages.nix
··· 24518 prometheus-node-exporter = callPackage ../servers/monitoring/prometheus/node-exporter.nix { 24519 inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit; 24520 }; 24521 prometheus-openldap-exporter = callPackage ../servers/monitoring/prometheus/openldap-exporter.nix { 24522 buildGoModule = buildGo118Module; # nixosTests.prometheus-exporter.ldap fails with 1.19 24523 };
··· 24518 prometheus-node-exporter = callPackage ../servers/monitoring/prometheus/node-exporter.nix { 24519 inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit; 24520 }; 24521 + prometheus-nut-exporter = callPackage ../servers/monitoring/prometheus/nut-exporter.nix { }; 24522 prometheus-openldap-exporter = callPackage ../servers/monitoring/prometheus/openldap-exporter.nix { 24523 buildGoModule = buildGo118Module; # nixosTests.prometheus-exporter.ldap fails with 1.19 24524 };