configure apcupsd server

This commit is contained in:
Michele Guerini Rocco 2024-08-02 19:26:13 +02:00
parent 7c772395de
commit a0832392b9
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
2 changed files with 17 additions and 19 deletions

View File

@ -61,7 +61,8 @@
nftables.enable = true;
firewall.extraInputRules = ''
meta l4proto esp counter accept comment "allow ipsec"
meta l4proto esp counter accept comment "allow IPsec"
ip saddr 192.168.1.0/24 tcp dport apcupsd accept comment "allow UPS from LAN"
'';
usePredictableInterfaceNames = false;

View File

@ -38,36 +38,33 @@
UPSTYPE usb
UPSCABLE usb
NETSERVER on
NISPORT 3551
MINUTES 5
'';
hooks =
let
# Send notifications on the Maxwell
# room when something bad happens.
# Send notifications when something bad happens
notify = msg: ''${pkgs.maxwell-notify}/bin/notify "UPS: ${msg}"'';
in
{
changeme = notify "sostituire le batterie";
battdetach = notify "batterie disconnesse";
battattach = notify "batterie riconnesse";
commfailure = notify "connessione persa";
commok = notify "connessione ristabilita";
loadlimit = notify "livello batterie critico (5%)";
runlimit = notify "autonomia batterie critico (5min)";
doshutdown = notify "inizio sequenza di spegnimento";
powerout = notify "rete elettrica disconnessa";
mainsback = notify "rete elettrica riconnessa";
onbattery = notify "attivate batterie";
offbattery = notify "disattivate batterie";
emergency = notify "malfunzionamento batterie, possibile spegnimento!";
changeme = notify "replace batteries";
battdetach = notify "batteries disconnected";
battattach = notify "batteries reconnected";
commfailure = notify "connection lost";
commok = notify "connection enstablished";
loadlimit = notify "critical battery level (5%)";
runlimit = notify "critical battery life (5min)";
doshutdown = notify "shutting down!";
powerout = notify "main power is out";
mainsback = notify "main power is back";
onbattery = notify "batteries connected";
offbattery = notify "batteries disconnected";
emergency = notify "battery malfunction, possible shutdown!";
};
};
services.smartd =
let
# Send a notification on the Maxwell
# when a disk is starting to fail.
# Send a notification when a disk is starting to fail
failHook = with pkgs; writeScript "disk-fail-hook" ''
#!/bin/sh
${pkgs.maxwell-notify}/bin/notify \