From 7db769a19ad248a19642b5f1a22e9027cde8901a Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Wed, 29 Mar 2023 09:00:55 -0600 Subject: [PATCH] monitoring: build fs list from config --- monitoring/default.nix | 12 ++++++++++-- monitoring/monitrc | 3 --- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/monitoring/default.nix b/monitoring/default.nix index f0d48c3..be10faf 100644 --- a/monitoring/default.nix +++ b/monitoring/default.nix @@ -1,6 +1,9 @@ { config, ... }: +let + inherit (builtins) + readFile concatStringsSep attrValues mapAttrs replaceStrings; -{ +in { config = { sops.secrets = { monit_cfg = { @@ -11,7 +14,12 @@ }; services.monit = { enable = true; - config = builtins.readFile ./monitrc; + config = readFile ./monitrc + (concatStringsSep "\n" (attrValues (mapAttrs + (f: _: '' + check filesystem ${replaceStrings [ "/" ] [ "_" ] f} with path ${f} + if space usage > 90% then alert + if inode usage > 90% then alert + '') config.fileSystems))); }; }; } diff --git a/monitoring/monitrc b/monitoring/monitrc index 815a5db..7dcb74d 100644 --- a/monitoring/monitrc +++ b/monitoring/monitrc @@ -20,6 +20,3 @@ check system $HOST if cpu usage (wait) > 80% for 2 cycles then alert if cpu usage > 200% for 4 cycles then alert -check filesystem rootfs with path / - if space usage > 90% then alert - if inode usage > 90% then alert