From c03e5601ba9e7210f042e96c513304855a020d28 Mon Sep 17 00:00:00 2001
From: coolneng <akasroua@gmail.com>
Date: Mon, 15 Mar 2021 14:00:59 +0100
Subject: [PATCH] Add SMART monitoring

---
 configuration.nix      |  1 +
 modules/monitoring.nix | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 modules/monitoring.nix

diff --git a/configuration.nix b/configuration.nix
index 1d0d724..2b0bbb0 100644
--- a/configuration.nix
+++ b/configuration.nix
@@ -90,6 +90,7 @@
     ./modules/networking.nix
     ./modules/datasync.nix
     ./modules/virtualization.nix
+    ./modules/monitoring.nix
   ];
 
 }
diff --git a/modules/monitoring.nix b/modules/monitoring.nix
new file mode 100644
index 0000000..06c9cbf
--- /dev/null
+++ b/modules/monitoring.nix
@@ -0,0 +1,23 @@
+{ config, lib, pkgs, ... }:
+
+{
+  # Notify when a disk starts going haywire
+  services.smartd = {
+    enable = true;
+    notifications.mail = {
+      enable = true;
+      recipient = "akasroua@gmail.com";
+    };
+  };
+
+  # Enable trivial MTA for smartd notifications
+  services.ssmtp = {
+    enable = true;
+    useTLS = true;
+    useSTARTTLS = true;
+    domain = "gmail.com";
+    hostName = "smtp.gmail.com:587";
+    authUser = "akasroua@gmail.com";
+    authPassFile = "/var/keys/ssmtp";
+  };
+}