about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/apcupsd.nix
blob: 57c35a742c5f541af21708f34665708d36036cca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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}
      '';
    };
  };
}