aboutsummaryrefslogtreecommitdiff
path: root/flakes
diff options
context:
space:
mode:
Diffstat (limited to 'flakes')
-rw-r--r--flakes/flake.lock22
-rw-r--r--flakes/private/monitoring/flake.nix55
2 files changed, 66 insertions, 11 deletions
diff --git a/flakes/flake.lock b/flakes/flake.lock
index 85690fa..991a73b 100644
--- a/flakes/flake.lock
+++ b/flakes/flake.lock
@@ -2815,7 +2815,7 @@
2815 }, 2815 },
2816 "locked": { 2816 "locked": {
2817 "lastModified": 1, 2817 "lastModified": 1,
2818 "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=", 2818 "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
2819 "path": "../../flakes/private/monitoring", 2819 "path": "../../flakes/private/monitoring",
2820 "type": "path" 2820 "type": "path"
2821 }, 2821 },
@@ -2833,7 +2833,7 @@
2833 }, 2833 },
2834 "locked": { 2834 "locked": {
2835 "lastModified": 1, 2835 "lastModified": 1,
2836 "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=", 2836 "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
2837 "path": "../../flakes/private/monitoring", 2837 "path": "../../flakes/private/monitoring",
2838 "type": "path" 2838 "type": "path"
2839 }, 2839 },
@@ -2851,7 +2851,7 @@
2851 }, 2851 },
2852 "locked": { 2852 "locked": {
2853 "lastModified": 1, 2853 "lastModified": 1,
2854 "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=", 2854 "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
2855 "path": "../../flakes/private/monitoring", 2855 "path": "../../flakes/private/monitoring",
2856 "type": "path" 2856 "type": "path"
2857 }, 2857 },
@@ -2869,7 +2869,7 @@
2869 }, 2869 },
2870 "locked": { 2870 "locked": {
2871 "lastModified": 1, 2871 "lastModified": 1,
2872 "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=", 2872 "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
2873 "path": "../../flakes/private/monitoring", 2873 "path": "../../flakes/private/monitoring",
2874 "type": "path" 2874 "type": "path"
2875 }, 2875 },
@@ -3753,7 +3753,7 @@
3753 }, 3753 },
3754 "locked": { 3754 "locked": {
3755 "lastModified": 1, 3755 "lastModified": 1,
3756 "narHash": "sha256-KL5aC6l/mM+ucHadjCtlSY6iBZ9/VKRf2Rgw2tjwfqo=", 3756 "narHash": "sha256-90nIfmXTv1DCJThIjtlNtnkMxefYJMHLp0CHmIekgDc=",
3757 "path": "../systems/backup-2", 3757 "path": "../systems/backup-2",
3758 "type": "path" 3758 "type": "path"
3759 }, 3759 },
@@ -3776,7 +3776,7 @@
3776 }, 3776 },
3777 "locked": { 3777 "locked": {
3778 "lastModified": 1, 3778 "lastModified": 1,
3779 "narHash": "sha256-VliQ62boc8jNgPCBX6JjVS/pA6YoikZVkvE1xxHAITk=", 3779 "narHash": "sha256-kUhSjG2OtbZMeIEykJGKUC2RovZ1prxXc8aIckE0auI=",
3780 "path": "../systems/dilion", 3780 "path": "../systems/dilion",
3781 "type": "path" 3781 "type": "path"
3782 }, 3782 },
@@ -3824,7 +3824,7 @@
3824 }, 3824 },
3825 "locked": { 3825 "locked": {
3826 "lastModified": 1, 3826 "lastModified": 1,
3827 "narHash": "sha256-YVJi4KPT8rsGNzZshYfUyz9l27QGAEsb8Iyu3O0/bMA=", 3827 "narHash": "sha256-20vFVAd2/24Q0Lewy0eNXf94eTY96cFE8mPeKtvT5jY=",
3828 "path": "../systems/eldiron", 3828 "path": "../systems/eldiron",
3829 "type": "path" 3829 "type": "path"
3830 }, 3830 },
@@ -3850,7 +3850,7 @@
3850 }, 3850 },
3851 "locked": { 3851 "locked": {
3852 "lastModified": 1, 3852 "lastModified": 1,
3853 "narHash": "sha256-HiDwzScPHp084MwtWET+17WbrWf3zs9qJzv/EqNaSqM=", 3853 "narHash": "sha256-BHpsgdt0NuJHTVvfTrsnNlOZdSBtPy/cTidd8sEIhx4=",
3854 "path": "../systems/monitoring-1", 3854 "path": "../systems/monitoring-1",
3855 "type": "path" 3855 "type": "path"
3856 }, 3856 },
@@ -3875,7 +3875,7 @@
3875 }, 3875 },
3876 "locked": { 3876 "locked": {
3877 "lastModified": 1, 3877 "lastModified": 1,
3878 "narHash": "sha256-YWEuXALLICHE+WsMtMuiCm6b2IRQyJrFpfMgH6ZLD0A=", 3878 "narHash": "sha256-lT2cXjUGDFOzRtqF4p0oyFCR4gv+VEjthk4FMbOzrL0=",
3879 "path": "../systems/quatresaisons", 3879 "path": "../systems/quatresaisons",
3880 "type": "path" 3880 "type": "path"
3881 }, 3881 },
@@ -7384,7 +7384,7 @@
7384 }, 7384 },
7385 "locked": { 7385 "locked": {
7386 "lastModified": 1, 7386 "lastModified": 1,
7387 "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=", 7387 "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
7388 "path": "../../flakes/private/monitoring", 7388 "path": "../../flakes/private/monitoring",
7389 "type": "path" 7389 "type": "path"
7390 }, 7390 },
@@ -8294,7 +8294,7 @@
8294 }, 8294 },
8295 "locked": { 8295 "locked": {
8296 "lastModified": 1, 8296 "lastModified": 1,
8297 "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=", 8297 "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
8298 "path": "./private/monitoring", 8298 "path": "./private/monitoring",
8299 "type": "path" 8299 "type": "path"
8300 }, 8300 },
diff --git a/flakes/private/monitoring/flake.nix b/flakes/private/monitoring/flake.nix
index b7c3997..5610d67 100644
--- a/flakes/private/monitoring/flake.nix
+++ b/flakes/private/monitoring/flake.nix
@@ -164,6 +164,13 @@
164 Whether to enable monitoring. 164 Whether to enable monitoring.
165 ''; 165 '';
166 }; 166 };
167 smartdDisks = lib.mkOption {
168 type = lib.types.listOf lib.types.str;
169 default = [];
170 description = ''
171 List of smartd disks ids (symlinks in /dev/disk/by-id/) to monitor
172 '';
173 };
167 master = lib.mkOption { 174 master = lib.mkOption {
168 type = lib.types.bool; 175 type = lib.types.bool;
169 default = false; 176 default = false;
@@ -261,6 +268,54 @@
261 objectDefs = 268 objectDefs =
262 self.lib.toObjects cfg.objects; 269 self.lib.toObjects cfg.objects;
263 }; 270 };
271
272 myServices.monitoring.objects.service = builtins.map (d: {
273 service_description = "Disk /dev/disk/by-id/${d} is sane";
274 use = "local-service";
275 check_command = [ "check_smartctl" "/dev/disk/by-id/${d}" ];
276 __passive_servicegroups = "webstatus-resources";
277
278 check_interval = 60;
279 }) cfg.smartdDisks;
280
281 systemd = let
282 checkShortTimer = {
283 timerConfig = {
284 OnCalendar = "monthly";
285 RandomizedDelaySec = "3 weeks";
286 FixedRandomDelay = true;
287 };
288 wantedBy = [ "timers.target" ];
289 };
290 checkLongTimer = {
291 timerConfig = {
292 OnCalendar = "monthly";
293 RandomizedDelaySec = "3 weeks";
294 FixedRandomDelay = true;
295 };
296 wantedBy = [ "timers.target" ];
297 };
298 toSDTimers = id: {
299 "check-smartd-long-${id}" = checkLongTimer;
300 "check-smartd-short-${id}" = checkShortTimer;
301 };
302 toCheckService = id: type: {
303 description = "Run ${type} smartctl test for /dev/disk/by-id/${id}";
304 after = [ "multi-user.target" ];
305 serviceConfig = {
306 Type = "oneshot";
307 ExecStart = "${pkgs.smartmontools}/bin/smartctl -t ${type} /dev/disk/by-id/${id}";
308 };
309 };
310 toSDServices = id: {
311 "check-smartd-long-${id}" = toCheckService id "long";
312 "check-smartd-short-${id}" = toCheckService id "short";
313 };
314
315 in {
316 services = lib.attrsets.mergeAttrsList (builtins.map toSDServices cfg.smartdDisks);
317 timers = lib.attrsets.mergeAttrsList (builtins.map toSDTimers cfg.smartdDisks);
318 };
264 }; 319 };
265 }; 320 };
266 }; 321 };