2024-12-12 14:41:43 +01:00
|
|
|
# SPDX-FileCopyrightText: 2024 Maurice Debray <maurice.debray@dgnum.eu>
|
|
|
|
# SPDX-FileCopyrightText: 2024 Ryan Lahfa <ryan.lahfa@dgnum.eu>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
2024-12-10 01:55:20 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
sources,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-04-14 01:06:22 +02:00
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
|
|
|
mkOption
|
|
|
|
|
|
|
|
types
|
|
|
|
;
|
|
|
|
cfg = config.dgn-node-monitoring;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.dgn-node-monitoring = {
|
|
|
|
enable = mkEnableOption "DGNum nodes monitoring (needs a valid netbird tunnel)" // {
|
|
|
|
default = true;
|
|
|
|
};
|
2024-12-15 20:45:34 +01:00
|
|
|
|
|
|
|
ports = mkOption {
|
|
|
|
type = types.attrsOf types.port;
|
|
|
|
default = {
|
|
|
|
node = 9002;
|
|
|
|
cgroup = 9003;
|
|
|
|
};
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Ports to listen on for each exporter.
|
2024-04-14 01:06:22 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-12-10 01:55:20 +01:00
|
|
|
imports = [
|
|
|
|
"${sources.cgroup-exporter}/nix/module.nix"
|
|
|
|
];
|
|
|
|
|
2024-04-14 01:06:22 +02:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.prometheus = {
|
|
|
|
exporters = {
|
|
|
|
node = {
|
|
|
|
enable = true;
|
|
|
|
enabledCollectors = [
|
|
|
|
"processes"
|
|
|
|
"systemd"
|
|
|
|
];
|
2024-12-15 20:45:34 +01:00
|
|
|
port = cfg.ports.node;
|
2024-04-14 01:06:22 +02:00
|
|
|
listenAddress = "0.0.0.0";
|
|
|
|
};
|
2024-12-10 01:55:20 +01:00
|
|
|
cgroup = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.callPackage "${sources.cgroup-exporter}/nix/package.nix" { };
|
2024-12-15 20:45:34 +01:00
|
|
|
listenAddress = "0.0.0.0";
|
|
|
|
port = cfg.ports.cgroup;
|
2024-12-10 01:55:20 +01:00
|
|
|
};
|
2024-04-14 01:06:22 +02:00
|
|
|
};
|
|
|
|
};
|
2024-12-15 20:45:34 +01:00
|
|
|
networking.firewall.interfaces.wt0.allowedTCPPorts = builtins.attrValues cfg.ports;
|
2024-04-14 01:06:22 +02:00
|
|
|
};
|
|
|
|
}
|