1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

chore: dont add empty lists to telegraf, it doesn't like it

This commit is contained in:
oddlama 2024-07-19 01:02:43 +02:00
parent 9b6c4a0ca6
commit 6a50fc769c
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A

View file

@ -26,6 +26,7 @@
; ;
cfg = config.meta.telegraf; cfg = config.meta.telegraf;
mkIfNotEmpty = xs: mkIf (xs != []) xs;
in { in {
options.meta.telegraf = { options.meta.telegraf = {
enable = mkEnableOption "telegraf to push metrics to influx."; enable = mkEnableOption "telegraf to push metrics to influx.";
@ -188,7 +189,7 @@ in {
temp = {}; temp = {};
wireguard = {}; wireguard = {};
ping = concatLists (flip mapAttrsToList globals.monitoring.ping ( ping = mkIfNotEmpty (concatLists (flip mapAttrsToList globals.monitoring.ping (
name: pingCfg: name: pingCfg:
optionals (elem pingCfg.network cfg.availableMonitoringNetworks) ( optionals (elem pingCfg.network cfg.availableMonitoringNetworks) (
concatLists (forEach ["hostv4" "hostv6"] ( concatLists (forEach ["hostv4" "hostv6"] (
@ -214,9 +215,9 @@ in {
} }
)) ))
) )
)); )));
http_response = concatLists (flip mapAttrsToList globals.monitoring.http ( http_response = mkIfNotEmpty (concatLists (flip mapAttrsToList globals.monitoring.http (
name: httpCfg: name: httpCfg:
optional (elem httpCfg.network cfg.availableMonitoringNetworks) { optional (elem httpCfg.network cfg.availableMonitoringNetworks) {
interval = "1m"; interval = "1m";
@ -231,9 +232,9 @@ in {
inherit (httpCfg) network; inherit (httpCfg) network;
}; };
} }
)); )));
dns_query = concatLists (flip mapAttrsToList globals.monitoring.dns ( dns_query = mkIfNotEmpty (concatLists (flip mapAttrsToList globals.monitoring.dns (
name: dnsCfg: name: dnsCfg:
optional (elem dnsCfg.network cfg.availableMonitoringNetworks) { optional (elem dnsCfg.network cfg.availableMonitoringNetworks) {
interval = "1m"; interval = "1m";
@ -245,9 +246,9 @@ in {
inherit (dnsCfg) network; inherit (dnsCfg) network;
}; };
} }
)); )));
net_response = concatLists (flip mapAttrsToList globals.monitoring.tcp ( net_response = mkIfNotEmpty (concatLists (flip mapAttrsToList globals.monitoring.tcp (
name: tcpCfg: name: tcpCfg:
optional (elem tcpCfg.network cfg.availableMonitoringNetworks) { optional (elem tcpCfg.network cfg.availableMonitoringNetworks) {
interval = "1m"; interval = "1m";
@ -259,7 +260,7 @@ in {
}; };
fieldexclude = ["result_type" "string_found"]; fieldexclude = ["result_type" "string_found"];
} }
)); )));
} }
// optionalAttrs config.services.smartd.enable { // optionalAttrs config.services.smartd.enable {
sensors = {}; sensors = {};