Merge pull request #201817 from jhh/nut-exporter
This commit is contained in:
commit
068e7cb340
|
@ -6557,6 +6557,12 @@
|
||||||
githubId = 6445082;
|
githubId = 6445082;
|
||||||
name = "Joseph Lukasik";
|
name = "Joseph Lukasik";
|
||||||
};
|
};
|
||||||
|
jhh = {
|
||||||
|
email = "jeff@j3ff.io";
|
||||||
|
github = "jhh";
|
||||||
|
githubId = 14412;
|
||||||
|
name = "Jeff Hutchison";
|
||||||
|
};
|
||||||
jhhuh = {
|
jhhuh = {
|
||||||
email = "jhhuh.note@gmail.com";
|
email = "jhhuh.note@gmail.com";
|
||||||
github = "jhhuh";
|
github = "jhhuh";
|
||||||
|
|
|
@ -51,6 +51,7 @@ let
|
||||||
"nginx"
|
"nginx"
|
||||||
"nginxlog"
|
"nginxlog"
|
||||||
"node"
|
"node"
|
||||||
|
"nut"
|
||||||
"openldap"
|
"openldap"
|
||||||
"openvpn"
|
"openvpn"
|
||||||
"pihole"
|
"pihole"
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
{ config, lib, pkgs, options }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.prometheus.exporters.nut;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
port = 9199;
|
||||||
|
extraOpts = {
|
||||||
|
nutServer = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Hostname or address of the NUT server
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
nutUser = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
example = "nut";
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
The user to log in into NUT server. If set, passwordPath should
|
||||||
|
also be set.
|
||||||
|
|
||||||
|
Default NUT configs usually permit reading variables without
|
||||||
|
authentication.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
passwordPath = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
default = null;
|
||||||
|
apply = final: if final == null then null else toString final;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
A run-time path to the nutUser password file, which should be
|
||||||
|
provisioned outside of Nix store.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
serviceOpts = {
|
||||||
|
script = ''
|
||||||
|
${optionalString (cfg.passwordPath != null)
|
||||||
|
"export NUT_EXPORTER_PASSWORD=$(cat ${toString cfg.passwordPath})"}
|
||||||
|
${pkgs.prometheus-nut-exporter}/bin/nut_exporter \
|
||||||
|
--nut.server=${cfg.nutServer} \
|
||||||
|
--web.listen-address="${cfg.listenAddress}:${toString cfg.port}" \
|
||||||
|
${optionalString (cfg.nutUser != "") "--nut.username=${cfg.nutUser}"}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
22
pkgs/servers/monitoring/prometheus/nut-exporter.nix
Normal file
22
pkgs/servers/monitoring/prometheus/nut-exporter.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{ lib, buildGoModule, fetchFromGitHub }:
|
||||||
|
|
||||||
|
buildGoModule rec {
|
||||||
|
pname = "nut-exporter";
|
||||||
|
version = "2.4.2";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "DRuggeri";
|
||||||
|
repo = "nut_exporter";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "sha256-fymVx6FJGII2PmWXVfeCRTxfO+35bmyn/9iL0iPuBgo=";
|
||||||
|
};
|
||||||
|
|
||||||
|
vendorSha256 = "sha256-ji8JlEYChPBakt5y6+zcm1l04VzZ0/fjfGFJ9p+1KHE=";
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Prometheus exporter for Network UPS Tools";
|
||||||
|
homepage = "https://github.com/DRuggeri/nut_exporter";
|
||||||
|
license = licenses.asl20;
|
||||||
|
maintainers = with maintainers; [ jhh ];
|
||||||
|
};
|
||||||
|
}
|
|
@ -24518,6 +24518,7 @@ with pkgs;
|
||||||
prometheus-node-exporter = callPackage ../servers/monitoring/prometheus/node-exporter.nix {
|
prometheus-node-exporter = callPackage ../servers/monitoring/prometheus/node-exporter.nix {
|
||||||
inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit;
|
inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit;
|
||||||
};
|
};
|
||||||
|
prometheus-nut-exporter = callPackage ../servers/monitoring/prometheus/nut-exporter.nix { };
|
||||||
prometheus-openldap-exporter = callPackage ../servers/monitoring/prometheus/openldap-exporter.nix {
|
prometheus-openldap-exporter = callPackage ../servers/monitoring/prometheus/openldap-exporter.nix {
|
||||||
buildGoModule = buildGo118Module; # nixosTests.prometheus-exporter.ldap fails with 1.19
|
buildGoModule = buildGo118Module; # nixosTests.prometheus-exporter.ldap fails with 1.19
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue