From aba9251f809b93532c5fe4d3869cf8c728560192 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 7 Apr 2021 00:01:21 +0200 Subject: [PATCH] nixos-module/collectd: init --- nix/nixos-module/collectd.nix | 42 +++++++++++++++++++++++++++++++++++ nix/nixos-module/default.nix | 1 + 2 files changed, 43 insertions(+) create mode 100644 nix/nixos-module/collectd.nix diff --git a/nix/nixos-module/collectd.nix b/nix/nixos-module/collectd.nix new file mode 100644 index 000000000..8c91bf9 --- /dev/null +++ b/nix/nixos-module/collectd.nix @@ -0,0 +1,42 @@ +{ hostName, config, lib, ... }: + +let + hostRole = config.site.hosts.${hostName}.role; + networkPort = 25826; +in +{ + services.collectd = { + enable = true; + buildMinimalPackage = true; + + plugins = lib.mkMerge [ { + interface = ""; + conntrack = ""; + # TODO: dhcpcount + } (lib.optionalAttrs (hostName == "stats") { + network = '' + Listen "::" "${toString networkPort}" + Forward true + Server "${config.site.net.serv.hosts4.spaceapi}" "${toString networkPort}" + Server "${config.site.net.serv.hosts4.grafana}" "${toString networkPort}" + ''; + }) (lib.optionalAttrs (hostName != "stats") { + network = '' + Server "${config.site.net.serv.hosts6.dn42.stats}" "${toString networkPort}" + ''; + }) (lib.optionalAttrs (hostRole == "server") { + irq = ""; + cpu = ""; + load = ""; + memory = ""; + swap = ""; + entropy = ""; + disk = ""; + df = ""; + processes = ""; + hddtemp = ""; + sensors = ""; + thermal = ""; + }) ]; + }; +} diff --git a/nix/nixos-module/default.nix b/nix/nixos-module/default.nix index 7200ac6..87d5136 100644 --- a/nix/nixos-module/default.nix +++ b/nix/nixos-module/default.nix @@ -11,6 +11,7 @@ in { ../lib/config/options.nix ./defaults.nix ./network.nix + ./collectd.nix ] ++ optionals (hostConfig.role == "server") [ ./server/lxc-containers.nix