feat(monitoring): Add simple systemd monitoring
All checks were successful
lint / check (push) Successful in 24s
build configuration / build_vault01 (pull_request) Successful in 1m5s
build configuration / build_storage01 (pull_request) Successful in 1m7s
build configuration / build_compute01 (pull_request) Successful in 1m12s
build configuration / build_web02 (pull_request) Successful in 54s
build configuration / build_web01 (pull_request) Successful in 1m31s
build configuration / build_rescue01 (pull_request) Successful in 51s

This commit is contained in:
sinavir 2024-03-29 23:15:10 +01:00
parent e9c6f0a2b6
commit e06472d2a4
4 changed files with 91 additions and 0 deletions

View file

@ -43,6 +43,7 @@
"dgn-console" "dgn-console"
"dgn-fail2ban" "dgn-fail2ban"
"dgn-hardware" "dgn-hardware"
"dgn-notify"
"dgn-netbox-agent" "dgn-netbox-agent"
"dgn-network" "dgn-network"
"dgn-records" "dgn-records"
@ -60,5 +61,6 @@
"services/crabfit" "services/crabfit"
"services/forgejo-nix-runners" "services/forgejo-nix-runners"
"services/bupstash" "services/bupstash"
"services/systemd-notify"
]); ]);
} }

View file

@ -0,0 +1,46 @@
{
config,
pkgs,
lib,
...
}:
{
options.dgn-notify = {
enable = lib.mkEnableOption "DGNum email notification cli" // {
default = true;
};
};
config = lib.mkIf config.dgn-notify.enable {
programs.msmtp = {
enable = true;
setSendmail = false;
accounts.default = {
tls = true;
tls_starttls = false;
port = 465;
auth = true;
host = "kurisu.lahfa.xyz";
from = "noreply@infra.dgnum.eu";
user = "web-services@infra.dgnum.eu";
passwordeval = "cat ${config.age.secrets.mail.path}";
};
};
services.systemd-notify = {
enable = true;
command = builtins.toString (
pkgs.writeShellScript "sendmail" ''
${pkgs.msmtp}/bin/sendmail -i -t <<ERRMAIL
To: admins+monitoring@dgnum.eu
Subject: [$HOSTNAME] Systemd failure: $1
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
$(systemctl status --full "$1")
ERRMAIL
''
);
};
age-secrets.sources = [ ./. ];
};
}

42
modules/dgn-notify/mail Normal file
View file

@ -0,0 +1,42 @@
age-encryption.org/v1
-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X¼Ú·´¾<C2B4>w1vž »ËnÆvws¾úäLó9-»k*€Öı:耤/»o@îöù—J

View file

@ -0,0 +1 @@
{ mail.publicKeys = (import ../../lib { }).machineKeys; }