'upsd' is the server, 'upsmon' is the client.
Other things like Nagios have their own clients that connect directly to upsd to query the status.
This is a simple way of setting up the NUT ups monitoring system to shut servers down well before you get to powerfail status. If you lose power for more than about 5 seconds, chances are pretty good you're going to have lost it for a while, so you may as well shut things down now
It will, on the first ONBATT signal from the UPS, start a 30 second timer. If the power does not return during this time it will schedule a 2 minute shutdown, after which the box is shutdown cleanly. If power returns at all during this time, the shutdown will be cancelled. -- DanielLawson
/etc/nut/ups.conf
[mge] ## USB cable #driver = newhidups #port = auto ## SNTMP #driver = snmp-ups #port = 1.2.3.4 #mibs = mge desc = "MGE UPS"
/etc/nut/upsd.conf
ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACCEPT localhost REJECT all
/etc/nut/upsd.users
# Supervision user [admin] password = password allowfrom = localhost actions = SET instcmds = ALL # Protection user [monuser] password = monitor allowfrom = localhost upsmon master
/etc/nut/upsmon.conf
MONITOR mge@localhost 1 monuser monitor master MINSUPPLIES 1 SHUTDOWNCMD "/sbin/shutdown -h +0" POLLFREQ 5 POLLFREQALERT 5 HOSTSYNC 15 DEADTIME 15 #POWERDOWNFLAG /etc/killpower RBWARNTIME 43200 NOCOMMWARNTIME 300 FINALDELAY 5 NOTIFYCMD /sbin/upssched NOTIFYFLAG ONBATT WALL+SYSLOG+EXEC NOTIFYFLAG ONLINE WALL+SYSLOG+EXEC NOTIFYFLAG LOWBATT WALL+SYSLOG+EXEC NOTIFYFLAG FSD WALL+SYSLOG+EXEC
/etc/nut/upssched.conf
CMDSCRIPT /usr/local/bin/upssched-cmd PIPEFN /var/run/upssched/upssched.pipe LOCKFN /var/run/upssched/upssched.lock AT ONBATT * START-TIMER early-shutdown 30 AT LOWBATT * START-TIMER early-shutdown 30 AT ONLINE * CANCEL-TIMER resume AT ONLINE * EXECUTE resume AT FSD * EXECUTE forced-shutdown
GlennRamsey - On Ubuntu 8.04 the above script doesn't work. According to the man page the line:
AT ONLINE * CANCEL-TIMER resumeshould be:
AT ONLINE * CANCEL-TIMER early-shutdown resumebut that seemed to cause a problem with cancelling the shutdown, after 30s had elapsed
AT ONLINE * CANCEL-TIMER early-shutdown
seems to work properly. I suspect the issue was related to the 'resume' command being given by both 'AT ONLINE' events.
/usr/local/bin/upssched-cmd
#!/bin/bash # time in minutes time=2 case "${1}" in early-shutdown) logger -t upssched-cmd "Early Shutdown" shutdown -h +$time powerevent ;; resume) logger -t upssched-cmd "Resume" [ -f /var/run/shutdown.pid ] && shutdown -c || exit 0 ;; forced-shutdown) logger -t upssched-cmd "Forced Shutdown" shutdown -h +$time powerevent-forced ;; *) logger -t upssched-cmd "Unknown command: ${1}" ;; esac
On Ubuntu 8.04 I had to add 'RUN_AS_USER root' to upsmon.conf in order for the early shutdown script to work. I guess one could achieve the same effect by giving the nut user permission to run shutdown command. -- GlennRamsey
The Socomec NETYS PE UPS available from Dick Smith works with nut using the megatec_usb driver. -- GlennRamsey
---
Part of CategorySystemAdministration