Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
NutNotes
Edit
PageHistory
Diff
Info
LikePages
!! Very brief overview '''upsd''' is the server, '''upsmon''' is the client. * __ups.conf__ - this defines the UPSes that are connected to the server. You might see a process running like "''/lib/nut/newhidups -a YOUR_UPS_NAME''" * __upsd.conf__ - the ''upsd'' daemon is the interface for other programs to connect and query the directly-connected UPSes. This config file controls some access restrictions. * __upsmon.conf__ - ''upsmon'' is the program that periodically connects to upsd to get the status, and can run commands (eg to shutdown your server if the battery gets low) Other things like [Nagios] have their own clients that connect directly to ''upsd'' to query the status. !! Sample Configuration 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'' <verbatim> [mge] ## USB cable #driver = newhidups #port = auto ## SNTMP #driver = snmp-ups #port = 1.2.3.4 #mibs = mge desc = "MGE UPS" </verbatim> ''/etc/nut/upsd.conf'' <verbatim> ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACCEPT localhost REJECT all </verbatim> ''/etc/nut/upsd.users'' <verbatim> # Supervision user [admin] password = password allowfrom = localhost actions = SET instcmds = ALL # Protection user [monuser] password = monitor allowfrom = localhost upsmon master </verbatim> ''/etc/nut/upsmon.conf'' <verbatim> 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 </verbatim> ''/etc/nut/upssched.conf'' <verbatim> 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 </verbatim> GlennRamsey - On Ubuntu 8.04 the above script doesn't work. According to the man page the line: <verbatim> AT ONLINE * CANCEL-TIMER resume </verbatim> should be: <verbatim> AT ONLINE * CANCEL-TIMER early-shutdown resume </verbatim> but that seemed to cause a problem with cancelling the shutdown, after 30s had elapsed <verbatim> AT ONLINE * CANCEL-TIMER early-shutdown </verbatim> 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'' <verbatim> #!/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 </verbatim> !! Notes 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
One page links to
NutNotes
:
UPSNotes