From 4d16839a104dadf63c022670899a3d7d74f41fc8 Mon Sep 17 00:00:00 2001 From: catvayor Date: Sat, 20 Apr 2024 15:06:49 +0200 Subject: [PATCH] feat(upsmon): Send mails to isp team --- machines/vault01/ups.nix | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/machines/vault01/ups.nix b/machines/vault01/ups.nix index badda28..87642ca 100644 --- a/machines/vault01/ups.nix +++ b/machines/vault01/ups.nix @@ -18,12 +18,30 @@ let cmdScript = pkgs.writeShellApplication { name = "upssched-cmd.sh"; - runtimeInputs = with pkgs; [ systemd ]; + runtimeInputs = with pkgs; [ + systemd + msmtp + ]; text = '' case $1 in - shutdown) shutdown now - # TODO : warn - # TODO : warn & log on unknown cmd + shutdown-low) MEANING="Battery is low, shutting down.";; + shutdown-batt) MEANING="On battery for 15min, shutting down.";; + warn-batt) MEANING="Power line faillure, going on battery.";; + warn-comm) MEANING="Communication with the UPS was broken.";; + warn-bypass) MEANING="The UPS is not protecting the server, power line failure would kill $HOSTNAME instantly.";; + *) MEANING="Signal unknown, check configuration.";; + esac + sendmail -i -t <