forked from DGNum/infrastructure
feat(upsmon): Send mails to isp team
This commit is contained in:
parent
ee81052766
commit
4d16839a10
1 changed files with 29 additions and 8 deletions
|
@ -18,12 +18,30 @@
|
||||||
let
|
let
|
||||||
cmdScript = pkgs.writeShellApplication {
|
cmdScript = pkgs.writeShellApplication {
|
||||||
name = "upssched-cmd.sh";
|
name = "upssched-cmd.sh";
|
||||||
runtimeInputs = with pkgs; [ systemd ];
|
runtimeInputs = with pkgs; [
|
||||||
|
systemd
|
||||||
|
msmtp
|
||||||
|
];
|
||||||
text = ''
|
text = ''
|
||||||
case $1 in
|
case $1 in
|
||||||
shutdown) shutdown now
|
shutdown-low) MEANING="Battery is low, shutting down.";;
|
||||||
# TODO : warn
|
shutdown-batt) MEANING="On battery for 15min, shutting down.";;
|
||||||
# TODO : warn & log on unknown cmd
|
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 <<ERRMAIL
|
||||||
|
To: fai@dgnum.eu
|
||||||
|
Subject: [$HOSTNAME] Battery signal: $1
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
|
||||||
|
$MEANING
|
||||||
|
ERRMAIL
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
shutdown-*) shutdown 20s # let 20s to send the email
|
||||||
esac
|
esac
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -31,10 +49,13 @@
|
||||||
CMDSCRIPT ${cmdScript}/bin/upssched-cmd.sh
|
CMDSCRIPT ${cmdScript}/bin/upssched-cmd.sh
|
||||||
PIPEFN /var/state/ups/upssched/upssched.pipe
|
PIPEFN /var/state/ups/upssched/upssched.pipe
|
||||||
LOCKFN /var/state/ups/upssched/upssched.lock
|
LOCKFN /var/state/ups/upssched/upssched.lock
|
||||||
AT LOWBATT * EXECUTE shutdown
|
AT LOWBATT * EXECUTE shutdown-low
|
||||||
AT ONBATT * START-TIMER shutdown 900
|
AT ONBATT * EXECUTE warn-batt
|
||||||
AT ONLINE * CANCEL-TIMER shutdown
|
AT ONBATT * START-TIMER shutdown-batt 900
|
||||||
# TODO : warn admins at COMMBAD NOCOMM BYPASS (and maybe at ONBATT)
|
AT ONLINE * CANCEL-TIMER shutdown-batt
|
||||||
|
AT COMMBAD * EXECUTE warn-comm
|
||||||
|
AT NOCOMM * EXECUTE warn-comm
|
||||||
|
AT BYPASS * EXECUTE warn-bypass
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
(pkgs.writeTextFile {
|
(pkgs.writeTextFile {
|
||||||
|
|
Loading…
Reference in a new issue