Merge pull request #188754 from snaar/prometheus-ipmi

nixos/services.prometheus.exporters.ipmi: new module along with underlying ipmi_exporter package

authored by

Ivv and committed by
GitHub
ac5e7351 4aacfbe1

+123
+8
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
··· 275 </listitem> 276 <listitem> 277 <para> 278 <link xlink:href="https://writefreely.org">WriteFreely</link>, 279 a simple blogging platform with ActivityPub support. Available 280 as
··· 275 </listitem> 276 <listitem> 277 <para> 278 + <link xlink:href="https://github.com/prometheus-community/ipmi_exporter">Prometheus 279 + IPMI exporter</link>, an IPMI exporter for Prometheus. 280 + Available as 281 + <link linkend="opt-services.prometheus.exporters.ipmi.enable">services.prometheus.exporters.ipmi</link>. 282 + </para> 283 + </listitem> 284 + <listitem> 285 + <para> 286 <link xlink:href="https://writefreely.org">WriteFreely</link>, 287 a simple blogging platform with ActivityPub support. Available 288 as
+2
nixos/doc/manual/release-notes/rl-2211.section.md
··· 97 - [Patroni](https://github.com/zalando/patroni), a template for PostgreSQL HA with ZooKeeper, etcd or Consul. 98 Available as [services.patroni](options.html#opt-services.patroni.enable). 99 100 - [WriteFreely](https://writefreely.org), a simple blogging platform with ActivityPub support. Available as [services.writefreely](options.html#opt-services.writefreely.enable). 101 102 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
··· 97 - [Patroni](https://github.com/zalando/patroni), a template for PostgreSQL HA with ZooKeeper, etcd or Consul. 98 Available as [services.patroni](options.html#opt-services.patroni.enable). 99 100 + - [Prometheus IPMI exporter](https://github.com/prometheus-community/ipmi_exporter), an IPMI exporter for Prometheus. Available as [services.prometheus.exporters.ipmi](#opt-services.prometheus.exporters.ipmi.enable). 101 + 102 - [WriteFreely](https://writefreely.org), a simple blogging platform with ActivityPub support. Available as [services.writefreely](options.html#opt-services.writefreely.enable). 103 104 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+17
nixos/modules/services/monitoring/prometheus/exporters.nix
··· 36 "fastly" 37 "fritzbox" 38 "influxdb" 39 "json" 40 "jitsi" 41 "kea" ··· 243 244 config = mkMerge ([{ 245 assertions = [ { 246 assertion = cfg.snmp.enable -> ( 247 (cfg.snmp.configurationPath == null) != (cfg.snmp.configuration == null) 248 );
··· 36 "fastly" 37 "fritzbox" 38 "influxdb" 39 + "ipmi" 40 "json" 41 "jitsi" 42 "kea" ··· 244 245 config = mkMerge ([{ 246 assertions = [ { 247 + assertion = cfg.ipmi.enable -> (cfg.ipmi.configFile != null) -> ( 248 + !(lib.hasPrefix "/tmp/" cfg.ipmi.configFile) 249 + ); 250 + message = '' 251 + Config file specified in `services.prometheus.exporters.ipmi.configFile' must 252 + not reside within /tmp - it won't be visible to the systemd service. 253 + ''; 254 + } { 255 + assertion = cfg.ipmi.enable -> (cfg.ipmi.webConfigFile != null) -> ( 256 + !(lib.hasPrefix "/tmp/" cfg.ipmi.webConfigFile) 257 + ); 258 + message = '' 259 + Config file specified in `services.prometheus.exporters.ipmi.webConfigFile' must 260 + not reside within /tmp - it won't be visible to the systemd service. 261 + ''; 262 + } { 263 assertion = cfg.snmp.enable -> ( 264 (cfg.snmp.configurationPath == null) != (cfg.snmp.configuration == null) 265 );
+41
nixos/modules/services/monitoring/prometheus/exporters/ipmi.nix
···
··· 1 + { config, lib, pkgs, options }: 2 + 3 + with lib; 4 + 5 + let 6 + logPrefix = "services.prometheus.exporter.ipmi"; 7 + cfg = config.services.prometheus.exporters.ipmi; 8 + in { 9 + port = 9290; 10 + 11 + extraOpts = { 12 + configFile = mkOption { 13 + type = types.nullOr types.path; 14 + default = null; 15 + description = lib.mdDoc '' 16 + Path to configuration file. 17 + ''; 18 + }; 19 + 20 + webConfigFile = mkOption { 21 + type = types.nullOr types.path; 22 + default = null; 23 + description = lib.mdDoc '' 24 + Path to configuration file that can enable TLS or authentication. 25 + ''; 26 + }; 27 + }; 28 + 29 + serviceOpts.serviceConfig = { 30 + ExecStart = with cfg; concatStringsSep " " ([ 31 + "${pkgs.prometheus-ipmi-exporter}/bin/ipmi_exporter" 32 + "--web.listen-address ${listenAddress}:${toString port}" 33 + ] ++ optionals (cfg.webConfigFile != null) [ 34 + "--web.config.file ${escapeShellArg cfg.webConfigFile}" 35 + ] ++ optionals (cfg.configFile != null) [ 36 + "--config.file ${escapeShellArg cfg.configFile}" 37 + ] ++ extraFlags); 38 + 39 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 40 + }; 41 + }
+13
nixos/tests/prometheus-exporters.nix
··· 307 ''; 308 }; 309 310 jitsi = { 311 exporterConfig = { 312 enable = true;
··· 307 ''; 308 }; 309 310 + ipmi = { 311 + exporterConfig = { 312 + enable = true; 313 + }; 314 + exporterTest = '' 315 + wait_for_unit("prometheus-ipmi-exporter.service") 316 + wait_for_open_port(9290) 317 + succeed( 318 + "curl -sSf http://localhost:9290/metrics | grep 'ipmi_scrape_duration_seconds'" 319 + ) 320 + ''; 321 + }; 322 + 323 jitsi = { 324 exporterConfig = { 325 enable = true;
+41
pkgs/servers/monitoring/prometheus/ipmi-exporter.nix
···
··· 1 + { lib, buildGoModule, fetchFromGitHub, nixosTests, makeWrapper, freeipmi }: 2 + 3 + buildGoModule rec { 4 + pname = "ipmi_exporter"; 5 + version = "1.6.1"; 6 + 7 + src = fetchFromGitHub { 8 + owner = "prometheus-community"; 9 + repo = "ipmi_exporter"; 10 + rev = "v${version}"; 11 + hash = "sha256-hifG1lpFUVLoy7Ol3N6h+s+hZjnQxja5svpY4lFFsxw="; 12 + }; 13 + 14 + vendorHash = "sha256-UuPZmxoKVj7FusOS6H1gn6SAzQIZAKyX+m+QS657yXw="; 15 + 16 + nativeBuildInputs = [ makeWrapper ]; 17 + 18 + postInstall = '' 19 + wrapProgram $out/bin/ipmi_exporter --prefix PATH : ${lib.makeBinPath [ freeipmi ]} 20 + ''; 21 + 22 + passthru.tests = { inherit (nixosTests.prometheus-exporters) ipmi; }; 23 + 24 + ldflags = [ 25 + "-s" 26 + "-w" 27 + "-X github.com/prometheus/common/version.Version=${version}" 28 + "-X github.com/prometheus/common/version.Revision=0000000" 29 + "-X github.com/prometheus/common/version.Branch=unknown" 30 + "-X github.com/prometheus/common/version.BuildUser=nix@nixpkgs" 31 + "-X github.com/prometheus/common/version.BuildDate=unknown" 32 + ]; 33 + 34 + meta = with lib; { 35 + description = "An IPMI exporter for Prometheus"; 36 + homepage = "https://github.com/prometheus-community/ipmi_exporter"; 37 + changelog = "https://github.com/prometheus-community/ipmi_exporter/blob/${src.rev}/CHANGELOG.md"; 38 + license = licenses.mit; 39 + maintainers = with maintainers; [ snaar ]; 40 + }; 41 + }
+1
pkgs/top-level/all-packages.nix
··· 23415 prometheus-gitlab-ci-pipelines-exporter = callPackage ../servers/monitoring/prometheus/gitlab-ci-pipelines-exporter.nix { }; 23416 prometheus-haproxy-exporter = callPackage ../servers/monitoring/prometheus/haproxy-exporter.nix { }; 23417 prometheus-influxdb-exporter = callPackage ../servers/monitoring/prometheus/influxdb-exporter.nix { }; 23418 prometheus-jitsi-exporter = callPackage ../servers/monitoring/prometheus/jitsi-exporter.nix { }; 23419 prometheus-jmx-httpserver = callPackage ../servers/monitoring/prometheus/jmx-httpserver.nix { }; 23420 prometheus-json-exporter = callPackage ../servers/monitoring/prometheus/json-exporter.nix { };
··· 23415 prometheus-gitlab-ci-pipelines-exporter = callPackage ../servers/monitoring/prometheus/gitlab-ci-pipelines-exporter.nix { }; 23416 prometheus-haproxy-exporter = callPackage ../servers/monitoring/prometheus/haproxy-exporter.nix { }; 23417 prometheus-influxdb-exporter = callPackage ../servers/monitoring/prometheus/influxdb-exporter.nix { }; 23418 + prometheus-ipmi-exporter = callPackage ../servers/monitoring/prometheus/ipmi-exporter.nix { }; 23419 prometheus-jitsi-exporter = callPackage ../servers/monitoring/prometheus/jitsi-exporter.nix { }; 23420 prometheus-jmx-httpserver = callPackage ../servers/monitoring/prometheus/jmx-httpserver.nix { }; 23421 prometheus-json-exporter = callPackage ../servers/monitoring/prometheus/json-exporter.nix { };