nixos/prometheus-modemmanager-exporter: new module
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
parent
703c75f4a9
commit
a58346a5ee
3 changed files with 59 additions and 0 deletions
|
@ -34,6 +34,7 @@ let
|
|||
"mail"
|
||||
"mikrotik"
|
||||
"minio"
|
||||
"modemmanager"
|
||||
"nextcloud"
|
||||
"nginx"
|
||||
"node"
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
{ 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 = ''
|
||||
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}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -363,6 +363,31 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
modemmanager = {
|
||||
exporterConfig = {
|
||||
enable = true;
|
||||
refreshRate = "10s";
|
||||
};
|
||||
metricProvider = {
|
||||
# ModemManager is installed when NetworkManager is enabled. Ensure it is
|
||||
# started and is wanted by NM and the exporter to start everything up
|
||||
# in the right order.
|
||||
networking.networkmanager.enable = true;
|
||||
systemd.services.ModemManager = {
|
||||
enable = true;
|
||||
wantedBy = [ "NetworkManager.service" "prometheus-modemmanager-exporter.service" ];
|
||||
};
|
||||
};
|
||||
exporterTest = ''
|
||||
wait_for_unit("ModemManager.service")
|
||||
wait_for_unit("prometheus-modemmanager-exporter.service")
|
||||
wait_for_open_port(9539)
|
||||
succeed(
|
||||
"curl -sSf http://localhost:9539/metrics | grep -q 'modemmanager_info'"
|
||||
)
|
||||
'';
|
||||
};
|
||||
|
||||
nextcloud = {
|
||||
exporterConfig = {
|
||||
enable = true;
|
||||
|
|
Loading…
Reference in a new issue