Merge pull request #90077 from mdlayher/mdl-nixos-apcupsd
nixos/prometheus-apcupsd-exporter: new module
This commit is contained in:
commit
3190ba12f7
@ -21,6 +21,7 @@ let
|
|||||||
# `serviceOpts.script` or `serviceOpts.serviceConfig.ExecStart`
|
# `serviceOpts.script` or `serviceOpts.serviceConfig.ExecStart`
|
||||||
|
|
||||||
exporterOpts = genAttrs [
|
exporterOpts = genAttrs [
|
||||||
|
"apcupsd"
|
||||||
"bind"
|
"bind"
|
||||||
"blackbox"
|
"blackbox"
|
||||||
"collectd"
|
"collectd"
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
{ config, lib, pkgs, options }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.prometheus.exporters.apcupsd;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
port = 9162;
|
||||||
|
extraOpts = {
|
||||||
|
apcupsdAddress = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = ":3551";
|
||||||
|
description = ''
|
||||||
|
Address of the apcupsd Network Information Server (NIS).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
apcupsdNetwork = mkOption {
|
||||||
|
type = types.enum ["tcp" "tcp4" "tcp6"];
|
||||||
|
default = "tcp";
|
||||||
|
description = ''
|
||||||
|
Network of the apcupsd Network Information Server (NIS): one of "tcp", "tcp4", or "tcp6".
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
serviceOpts = {
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = ''
|
||||||
|
${pkgs.prometheus-apcupsd-exporter}/bin/apcupsd_exporter \
|
||||||
|
-telemetry.addr ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
-apcupsd.addr ${cfg.apcupsdAddress} \
|
||||||
|
-apcupsd.network ${cfg.apcupsdNetwork} \
|
||||||
|
${concatStringsSep " \\\n " cfg.extraFlags}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -56,6 +56,21 @@ let
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
exporterTests = {
|
exporterTests = {
|
||||||
|
apcupsd = {
|
||||||
|
exporterConfig = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
metricProvider = {
|
||||||
|
services.apcupsd.enable = true;
|
||||||
|
};
|
||||||
|
exporterTest = ''
|
||||||
|
wait_for_unit("apcupsd.service")
|
||||||
|
wait_for_open_port(3551)
|
||||||
|
wait_for_unit("prometheus-apcupsd-exporter.service")
|
||||||
|
wait_for_open_port(9162)
|
||||||
|
succeed("curl -sSf http://localhost:9162/metrics | grep -q 'apcupsd_info'")
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
bind = {
|
bind = {
|
||||||
exporterConfig = {
|
exporterConfig = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user