1{ config, lib, pkgs, options }:
2
3with lib;
4
5let
6 cfg = config.services.prometheus.exporters.apcupsd;
7in
8{
9 port = 9162;
10 extraOpts = {
11 apcupsdAddress = mkOption {
12 type = types.str;
13 default = ":3551";
14 description = lib.mdDoc ''
15 Address of the apcupsd Network Information Server (NIS).
16 '';
17 };
18
19 apcupsdNetwork = mkOption {
20 type = types.enum ["tcp" "tcp4" "tcp6"];
21 default = "tcp";
22 description = lib.mdDoc ''
23 Network of the apcupsd Network Information Server (NIS): one of "tcp", "tcp4", or "tcp6".
24 '';
25 };
26 };
27 serviceOpts = {
28 serviceConfig = {
29 ExecStart = ''
30 ${pkgs.prometheus-apcupsd-exporter}/bin/apcupsd_exporter \
31 -telemetry.addr ${cfg.listenAddress}:${toString cfg.port} \
32 -apcupsd.addr ${cfg.apcupsdAddress} \
33 -apcupsd.network ${cfg.apcupsdNetwork} \
34 ${concatStringsSep " \\\n " cfg.extraFlags}
35 '';
36 };
37 };
38}