From 782f5c20241c3b7fa3065ca39e48f0968473586b Mon Sep 17 00:00:00 2001 From: coolneng Date: Sun, 6 Sep 2020 00:39:40 +0200 Subject: [PATCH] Notify of disk errors via email --- README.org | 7 ++++--- configuration.nix | 7 ++++--- modules/monitoring.nix | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 modules/monitoring.nix diff --git a/README.org b/README.org index 87ce0f7..7b6e6a7 100644 --- a/README.org +++ b/README.org @@ -9,8 +9,9 @@ - ZFS pool configuration: hardware-configuration.nix - Network configuration: networking.nix - Printing and scanner server: printing.nix - - Nginx and PostgreSQL: webstack.nix - - Radicale and Syncthing: datasync.nix - - Gitea: devops.nix + - Synchronization and backup services: datasync.nix + - Web services and reverse proxy: webstack.nix + - Development tools: devops.nix + - Smartd: monitoring.nix All the modules are imported in *configuration.nix* diff --git a/configuration.nix b/configuration.nix index 2cb1afd..db803d7 100644 --- a/configuration.nix +++ b/configuration.nix @@ -103,12 +103,13 @@ # Import other configuration modules imports = [ - ./modules/printing.nix - ./modules/networking.nix - ./modules/datasync.nix ./modules/hardware-configuration.nix + ./modules/networking.nix + ./modules/printing.nix + ./modules/datasync.nix ./modules/webstack.nix ./modules/devops.nix + ./modules/monitoring.nix ]; } diff --git a/modules/monitoring.nix b/modules/monitoring.nix new file mode 100644 index 0000000..5ea8fd3 --- /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 = "/run/keys/ssmtp"; + }; +}