Hier eine von Techno Tim “inspirierte” Anleitung für das einrichten eines in meinem Fall Eaton 3s 550 USV. Ziel soll sein, das USV direkt mit dem Server zu verbinden und im Fall eines Stromausfalls den Server automatisch runterfahren zu lassen.
Eigentlich sollte das Ganze nach einer gewissen Zeit geschehen, aber in der Praxis fährt mein Server doch erst runter, wenn die USV Batterie einen kritischen Zustand erreicht. Ist für meine Zwecke fürs Erste ausreichend, entspricht aber nicht ganz dem Code.
Falls die Software bei euch nach einem Serverneustart nicht mehr das Netzteil erkennt, müsst ihr folgendes tun:
Gebt die Befehle nach einem Neustart manuell im Server ein oder lasst sie mit cron bei jedem boot (“@reboot”) laufen:
▪ upsdrvctl start
▪ systemctl restart nut-server
Dies war bei mir nötig, nach einem Umzug mit den gleichen Config-Dateien auf einen anderen Server jedoch nicht mehr.
Überprüft gelegentlich mal die Logs eures Servers.
Anleitung von Techno Tim, welche ich größtenteils übernommen habe!
als erstes muss das nut-package auf dem linux-server installiert werden. Auf jeden Falls sollten das nut-client und nut-server sein, aber sicherheitshalber einfach alle (apt install nut*
).
Ich erwähne hier öfters “neue x.conf”, was damit zu tun hat, das die Konfigurationsdateien schon standardmäßig Inhalte haben, vor allem viel auskommentiertes. Das könnt ihr teilweise stehen lassen, doch soweit ich mich erinnere, kann das alles weg und nur die Inhalte hier sind nötig für den Betrieb, bzw nach Techno Tims Anleitung werden die nötigen Befehle hier übersichtlicher zusammengetragen, ohne viele Kommentare.
Die NUT Dokumentation ist sehr ausführlich und wird euch bei weiterführenden Fragen helfen!
Die Skripte liegen im Übrigen nach der Installation von NUT in /etc/nut/.
Konfiguration:
nut-scanner -U
SNMP library not found. SNMP search disabled.
Neon library not found. XML search disabled.
IPMI library not found. IPMI search disabled.
Scanning USB bus.
[nutdev1]
driver = "usbhid-ups"
port = "auto"
vendorid = "0463"
productid = "FFFF"
product = "Eaton 3S"
serial = "Blank"
vendor = "EATON"
bus = "001"
neue ups.conf:
pollinterval = 1
maxretry =3
[eaton3s550]
driver = usbhid-ups
port = auto
desc =Eaton 3S 550 DIN USV"
vendorid = "0463"
productid = "FFFF"
neue upsmon.conf:
eaton3s550@localhost 1 admin secret master
hier sollte statt admin secret noch was anderes stehen, da das zugangsdaten sind
siehe upsd.users!
neue upsd.conf:
LISTEN 127.0.0.1 3493
neue nut.conf:
MODE=standalone
neue upsd.users:
[monuser]
password = secret
admin master
jetzt system neu starten oder:
service nut-server restart
service nut-client restart
systemctl restart nut-monitor
upsdrvctl stop
upsdrvctl start
dann
upsc eaton3s550@localhost
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 20
battery.runtime: 2544
battery.type: PbAc
device.mfr: EATON
device.model: Eaton 3S 550
device.serial: Blank
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 1
driver.parameter.port: auto
driver.parameter.productid: FFFF
driver.parameter.synchronous: no
driver.parameter.vendorid: 0463
driver.version: 2.7.4
driver.version.data: MGE HID 1.40
driver.version.internal: 0.41
input.transfer.high: 264
input.transfer.low: 184
outlet.1.desc: PowerShare Outlet 1
outlet.1.id: 1
outlet.1.status: on
outlet.1.switchable: no
outlet.desc: Main Outlet
outlet.id: 0
outlet.switchable: yes
output.frequency.nominal: 50
output.voltage: 230.0
output.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.firmware: 02.08.0010
ups.load: 10
ups.mfr: EATON
ups.model: Eaton 3S 550
ups.power.nominal: 550
ups.productid: ffff
ups.serial: Blank
ups.status: OL
ups.timer.shutdown: 0
ups.timer.start: 0
ups.type: offline / line interactive
ups.vendorid: 0463
diese queries können auch nach dem Befehl eingegeben werden, z.B.:
upsc eaton3s550@localhost battery.charge:
Init SSL without certificate database
100
coole: battery.charge, ups.load, battery.runtime
Dann hat TT das auf 2 systemen getrennt, also ne client config (welche sich auch im gleichen System übernehmen lässt):
apt install nut-client
nano /etc/nut/upsmon.conf
theoretisch:
RUN_AS_USER root
MONITOR eaton3s550@localhost 1 admin secret slave
aber braucht man nicht, wenn man es eh als root einrichtet, glaube?
dann:
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h"
NOTIFYCMD /usr/sbin/upssched
POLLFREQ 8
POLLFREQALERT 1
# das denke nur bei master-slave: HOSTSYNC 15
#POWERDOWNFLAG /etc/killpower
NOTIFYMSG ONLINE "UPS %s on line power"
NOTIFYMSG ONBATT "UPS %s on battery"
NOTIFYMSG LOWBATT "UPS %s batter is low
NOTIFYMSG FSD "UPS %s: foced shutdown in progress"
NOTIFYMSG COMMOK "Communications with UPS %s established"
NOTIFYMSG COMMBAD "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceedint"
NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM "UPS %s is unavailable"
NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"
NOTIFYLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYLAG LOWBATT SYSLOG+WALL
NOTIFYLAG FSD SYSLOG+WALL+EXEC
NOTIFYLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYLAG NOCOMM SYSLOG+WALL
NOTIFYLAG NOPARENT SYSLOG+WALL+EXEC
RBWANRTIME 43200
NOCOMMWARNTIME 600
FINALDELAY 5
nach Kopie von nano /etc/nut/upssched.conf:
CMDSCRIPT /etc/nut/upssched-cmd
PIPEFN /etc/nut/upssced.pipe
LOCKFN /etc/nut/upssched.lock
AT ONBATT * START-TIMER onbatt 30
AT ONLINE * CANCEL-TIMER onbatt online
AT ONBATT * START-TIMER earlyshutdown 30
#dieser Timer is in sekunden! also hier wird festgelegt, dass sich sowieso das System nach 30 Sek runterfährt!
AT LOWBATT * EXECUTE onbatt
AT COMMBAD * START-TIMER commbad 30
AT COMMOK * CANCEL-TIMER commbad commok
AT NOCOMM * EXECUTE commbad
AT SHUTDOWN * EXCECUTE powerdown
dann Skript erstellen:
nano /etc/nut/upssched-cmd
#!/bin/sh
case $1 in
onbatt)
logger -t upssched-cmd "The UPS is on battery"
;;
earlshutdown)
logger -t upssched-cmd "UPS on battery too long, forced shutdown"
/usr/sbin/upsmon -c fsd
;;
shutdowncritical)
logger -t upssched-cmd "UPS on battery critical, forced shutdown"
/usr/sbin/upsmon -c fsd
;;
upsgone)
logger -t upssched-cmd "The UPS has been gone for a while, can't reach"
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
zuletzt noch Autostart von dem Ganzen (upsdrvctl zumindest):
nano /etc/default/nut
#upsd starten
START_UPSD=yes
# upsmon starten
START_UPSMON=yes
Befehle aus upsmon.example.conf:
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
# POWERDOWNFLAG - Flag file for forcing UPS shutdown on the master system
#
# upsmon will create a file with this name in master mode when it's time
# to shut down the load. You should check for this file's existence in
# your shutdown scripts and run 'upsdrvctl shutdown' if it exists.
#
# See the config-notes.txt file in the docs subdirectory for more information.
# Refer to the section:
# [[UPS_shutdown]] "Configuring automatic shutdowns for low battery events"
# or refer to the online version.
POWERDOWNFLAG /etc/killpower
FINALDELAY 1