Penguin
Note: You are viewing an old revision of this page. View the current version.

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

[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

/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

---

Part of CategorySystemAdministration