},
"locked": {
"lastModified": 1,
- "narHash": "sha256-W4TIMgSVOiYTGt6hXrMNVxrJ9QZaQrL+awvGLk2UXjU=",
+ "narHash": "sha256-bmglD7CvrNkfOtMTTLlDAGhmY4YPcZD3Qrxv0CBk5B8=",
"path": "../flakes",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-KL5aC6l/mM+ucHadjCtlSY6iBZ9/VKRf2Rgw2tjwfqo=",
+ "narHash": "sha256-90nIfmXTv1DCJThIjtlNtnkMxefYJMHLp0CHmIekgDc=",
"path": "../systems/backup-2",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-VliQ62boc8jNgPCBX6JjVS/pA6YoikZVkvE1xxHAITk=",
+ "narHash": "sha256-kUhSjG2OtbZMeIEykJGKUC2RovZ1prxXc8aIckE0auI=",
"path": "../systems/dilion",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-YVJi4KPT8rsGNzZshYfUyz9l27QGAEsb8Iyu3O0/bMA=",
+ "narHash": "sha256-20vFVAd2/24Q0Lewy0eNXf94eTY96cFE8mPeKtvT5jY=",
"path": "../systems/eldiron",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-HiDwzScPHp084MwtWET+17WbrWf3zs9qJzv/EqNaSqM=",
+ "narHash": "sha256-BHpsgdt0NuJHTVvfTrsnNlOZdSBtPy/cTidd8sEIhx4=",
"path": "../systems/monitoring-1",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-YWEuXALLICHE+WsMtMuiCm6b2IRQyJrFpfMgH6ZLD0A=",
+ "narHash": "sha256-lT2cXjUGDFOzRtqF4p0oyFCR4gv+VEjthk4FMbOzrL0=",
"path": "../systems/quatresaisons",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "./private/monitoring",
"type": "path"
},
"nixpkgs": "nixpkgs_106"
},
"locked": {
- "lastModified": 1713004475,
- "narHash": "sha256-zXj5DiaeAiLGIFcgMyQTtICXg4kgIiiYcTbnDIocY38=",
+ "lastModified": 1718015850,
+ "narHash": "sha256-svUAfD+aIaS9T9UtepEGlIdxcZyu3YJcrGOmjuwgplE=",
"ref": "master",
- "rev": "8fd3e35df106a494e3195708e8cba076f2c94acb",
- "revCount": 728,
+ "rev": "71fbb32c4b3195982c0f03c90714c959b5ce2251",
+ "revCount": 735,
"type": "git",
"url": "git+ssh://gitolite@git.immae.eu/perso/Immae/Config/Nix/Nixops/Secrets"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-W4TIMgSVOiYTGt6hXrMNVxrJ9QZaQrL+awvGLk2UXjU=",
+ "narHash": "sha256-bmglD7CvrNkfOtMTTLlDAGhmY4YPcZD3Qrxv0CBk5B8=",
"path": "./flakes",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-KL5aC6l/mM+ucHadjCtlSY6iBZ9/VKRf2Rgw2tjwfqo=",
+ "narHash": "sha256-90nIfmXTv1DCJThIjtlNtnkMxefYJMHLp0CHmIekgDc=",
"path": "../systems/backup-2",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-VliQ62boc8jNgPCBX6JjVS/pA6YoikZVkvE1xxHAITk=",
+ "narHash": "sha256-kUhSjG2OtbZMeIEykJGKUC2RovZ1prxXc8aIckE0auI=",
"path": "../systems/dilion",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-YVJi4KPT8rsGNzZshYfUyz9l27QGAEsb8Iyu3O0/bMA=",
+ "narHash": "sha256-20vFVAd2/24Q0Lewy0eNXf94eTY96cFE8mPeKtvT5jY=",
"path": "../systems/eldiron",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-HiDwzScPHp084MwtWET+17WbrWf3zs9qJzv/EqNaSqM=",
+ "narHash": "sha256-BHpsgdt0NuJHTVvfTrsnNlOZdSBtPy/cTidd8sEIhx4=",
"path": "../systems/monitoring-1",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-YWEuXALLICHE+WsMtMuiCm6b2IRQyJrFpfMgH6ZLD0A=",
+ "narHash": "sha256-lT2cXjUGDFOzRtqF4p0oyFCR4gv+VEjthk4FMbOzrL0=",
"path": "../systems/quatresaisons",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "./private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-KL5aC6l/mM+ucHadjCtlSY6iBZ9/VKRf2Rgw2tjwfqo=",
+ "narHash": "sha256-90nIfmXTv1DCJThIjtlNtnkMxefYJMHLp0CHmIekgDc=",
"path": "../systems/backup-2",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-VliQ62boc8jNgPCBX6JjVS/pA6YoikZVkvE1xxHAITk=",
+ "narHash": "sha256-kUhSjG2OtbZMeIEykJGKUC2RovZ1prxXc8aIckE0auI=",
"path": "../systems/dilion",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-YVJi4KPT8rsGNzZshYfUyz9l27QGAEsb8Iyu3O0/bMA=",
+ "narHash": "sha256-20vFVAd2/24Q0Lewy0eNXf94eTY96cFE8mPeKtvT5jY=",
"path": "../systems/eldiron",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-HiDwzScPHp084MwtWET+17WbrWf3zs9qJzv/EqNaSqM=",
+ "narHash": "sha256-BHpsgdt0NuJHTVvfTrsnNlOZdSBtPy/cTidd8sEIhx4=",
"path": "../systems/monitoring-1",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-YWEuXALLICHE+WsMtMuiCm6b2IRQyJrFpfMgH6ZLD0A=",
+ "narHash": "sha256-lT2cXjUGDFOzRtqF4p0oyFCR4gv+VEjthk4FMbOzrL0=",
"path": "../systems/quatresaisons",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "./private/monitoring",
"type": "path"
},
Whether to enable monitoring.
'';
};
+ smartdDisks = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
+ default = [];
+ description = ''
+ List of smartd disks ids (symlinks in /dev/disk/by-id/) to monitor
+ '';
+ };
master = lib.mkOption {
type = lib.types.bool;
default = false;
objectDefs =
self.lib.toObjects cfg.objects;
};
+
+ myServices.monitoring.objects.service = builtins.map (d: {
+ service_description = "Disk /dev/disk/by-id/${d} is sane";
+ use = "local-service";
+ check_command = [ "check_smartctl" "/dev/disk/by-id/${d}" ];
+ __passive_servicegroups = "webstatus-resources";
+
+ check_interval = 60;
+ }) cfg.smartdDisks;
+
+ systemd = let
+ checkShortTimer = {
+ timerConfig = {
+ OnCalendar = "monthly";
+ RandomizedDelaySec = "3 weeks";
+ FixedRandomDelay = true;
+ };
+ wantedBy = [ "timers.target" ];
+ };
+ checkLongTimer = {
+ timerConfig = {
+ OnCalendar = "monthly";
+ RandomizedDelaySec = "3 weeks";
+ FixedRandomDelay = true;
+ };
+ wantedBy = [ "timers.target" ];
+ };
+ toSDTimers = id: {
+ "check-smartd-long-${id}" = checkLongTimer;
+ "check-smartd-short-${id}" = checkShortTimer;
+ };
+ toCheckService = id: type: {
+ description = "Run ${type} smartctl test for /dev/disk/by-id/${id}";
+ after = [ "multi-user.target" ];
+ serviceConfig = {
+ Type = "oneshot";
+ ExecStart = "${pkgs.smartmontools}/bin/smartctl -t ${type} /dev/disk/by-id/${id}";
+ };
+ };
+ toSDServices = id: {
+ "check-smartd-long-${id}" = toCheckService id "long";
+ "check-smartd-short-${id}" = toCheckService id "short";
+ };
+
+ in {
+ services = lib.attrsets.mergeAttrsList (builtins.map toSDServices cfg.smartdDisks);
+ timers = lib.attrsets.mergeAttrsList (builtins.map toSDTimers cfg.smartdDisks);
+ };
};
};
};
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
};
in
{
+ config.myServices.monitoring.smartdDisks = [
+ "ata-Micron_1100_MTFDDAK512TBN_171216BD2A4B"
+ "ata-Micron_1100_MTFDDAK512TBN_171216BD2A70"
+ "ata-TOSHIBA_MG04ACA400N_96K1K87YFVLC"
+ "ata-WDC_WD3000FYYZ-01UL1B2_WD-WMC1F0E4X6WP"
+ ];
config.myServices.monitoring.activatedPlugins = [ "memory" "command" "bandwidth" "mdadm" "zfs" "notify-secondary" "smartctl" ];
config.myServices.monitoring.objects = lib.mkMerge [
(monitoring.lib.objectsCommon {
{
service = [
- {
- service_description = "Disk /dev/disk/by-id/ata-Micron_1100_MTFDDAK512TBN_171216BD2A4B is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-Micron_1100_MTFDDAK512TBN_171216BD2A4B" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
- {
- service_description = "Disk /dev/disk/by-id/ata-Micron_1100_MTFDDAK512TBN_171216BD2A70 is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-Micron_1100_MTFDDAK512TBN_171216BD2A70" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
- {
- service_description = "Disk /dev/disk/by-id/ata-TOSHIBA_MG04ACA400N_96K1K87YFVLC is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-TOSHIBA_MG04ACA400N_96K1K87YFVLC" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
- {
- service_description = "Disk /dev/disk/by-id/ata-WDC_WD3000FYYZ-01UL1B2_WD-WMC1F0E4X6WP is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-WDC_WD3000FYYZ-01UL1B2_WD-WMC1F0E4X6WP" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
{
service_description = "No mdadm array is degraded";
use = "local-service";
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
emailCheck = monitoring.lib.emailCheck config.myEnv.monitoring.email_check;
in
{
+ config.myServices.monitoring.smartdDisks = [
+ "ata-ST33000650NS_Z29540DM"
+ "ata-ST33000650NS_Z296JGJ4"
+ "ata-Micron_5200_MTFDDAK480TDC_18011BEE03B3"
+ ];
+
config.myServices.monitoring.activatedPlugins = [ "memory" "command" "bandwidth" "emails" "mdadm" "postfix" "postgresql" "zfs" "notify-secondary" "smartctl" ];
config.myServices.monitoring.pluginsArgs.postgresql.package = config.myServices.databases.postgresql.package;
config.myServices.monitoring.objects = lib.mkMerge [
{
service = [
- {
- service_description = "Disk /dev/disk/by-id/ata-ST33000650NS_Z29540DM is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-ST33000650NS_Z29540DM" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
- {
- service_description = "Disk /dev/disk/by-id/ata-ST33000650NS_Z296JGJ4 is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-ST33000650NS_Z296JGJ4" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
- {
- service_description = "Disk /dev/disk/by-id/ata-SAMSUNG_MZ7LM480HMHQ-00005_S2UJNX0HA05895 is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-SAMSUNG_MZ7LM480HMHQ-00005_S2UJNX0HA05895" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
- {
- service_description = "Disk /dev/disk/by-id/ata-Micron_5200_MTFDDAK480TDC_18011BEE03B3 is sane";
- use = "local-service";
- check_command = [ "check_smartctl" "/dev/disk/by-id/ata-Micron_5200_MTFDDAK480TDC_18011BEE03B3" ];
- __passive_servicegroups = "webstatus-resources";
-
- check_interval = 60;
- }
{
service_description = "No mdadm array is degraded";
use = "local-service";
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},
},
"locked": {
"lastModified": 1,
- "narHash": "sha256-A50vXg0qfzUhyQZKToEseYsLgtaYke41KE/4uuyj+PY=",
+ "narHash": "sha256-Lpe56lKWhlMQiQoCgvMJuqJtJ8+szDldjqMAGyt2U3U=",
"path": "../../flakes/private/monitoring",
"type": "path"
},