about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/modemmanager.nix
blob: 0eb193c0021f2b8469ab2ae6589fe15efdf4b2a7 (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
{ config, lib, pkgs, options, ... }:

with lib;

let
  cfg = config.services.prometheus.exporters.modemmanager;
in
{
  port = 9539;
  extraOpts = {
    refreshRate = mkOption {
      type = types.str;
      default = "5s";
      description = lib.mdDoc ''
        How frequently ModemManager will refresh the extended signal quality
        information for each modem. The duration should be specified in seconds
        ("5s"), minutes ("1m"), or hours ("1h").
      '';
    };
  };
  serviceOpts = {
    serviceConfig = {
      # Required in order to authenticate with ModemManager via D-Bus.
      SupplementaryGroups = "networkmanager";
      ExecStart = ''
        ${pkgs.prometheus-modemmanager-exporter}/bin/modemmanager_exporter \
          -addr ${cfg.listenAddress}:${toString cfg.port} \
          -rate ${cfg.refreshRate} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
      RestrictAddressFamilies = [
        # Need AF_UNIX to collect data
        "AF_UNIX"
      ];
    };
  };
}