56 lines
1.4 KiB
Nix
56 lines
1.4 KiB
Nix
{ hostName, config, lib, pkgs, ... }:
|
|
|
|
let
|
|
hostRole = config.site.hosts.${hostName}.role;
|
|
networkPort = 25826;
|
|
upstreamTypesDb = pkgs.stdenv.mkDerivation {
|
|
name = "types.db";
|
|
src = config.services.collectd.package.src;
|
|
phases = [ "unpackPhase" "installPhase" ];
|
|
installPhase = "cp src/types.db $out";
|
|
};
|
|
customTypesDb = builtins.toFile "types.db" ''
|
|
stations value:GAUGE:0:U
|
|
'';
|
|
in
|
|
{
|
|
services.collectd = {
|
|
enable = true;
|
|
buildMinimalPackage = true;
|
|
|
|
extraConfig = ''
|
|
TypesDB "${upstreamTypesDb}" "${customTypesDb}"
|
|
'';
|
|
|
|
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 = "";
|
|
}) ];
|
|
};
|
|
}
|