version 8, including all changes.
.
| Rev |
Author |
# |
Line |
| 4 |
JohnMcPherson |
1 |
!! Very brief overview |
| 5 |
JohnMcPherson |
2 |
|
| |
|
3 |
'''upsd''' is the server, '''upsmon''' is the client. |
| 4 |
JohnMcPherson |
4 |
|
| |
|
5 |
* __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''" |
| |
|
6 |
* __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. |
| |
|
7 |
* __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) |
| |
|
8 |
|
| 5 |
JohnMcPherson |
9 |
Other things like [Nagios] have their own clients that connect directly to ''upsd'' to query the status. |
| 4 |
JohnMcPherson |
10 |
|
| 3 |
DanielLawson |
11 |
!! Sample Configuration |
| |
|
12 |
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 |
| |
|
13 |
|
| |
|
14 |
|
| |
|
15 |
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 |
| |
|
16 |
|
| |
|
17 |
|
| |
|
18 |
''/etc/nut/ups.conf'' |
| |
|
19 |
<verbatim> |
| |
|
20 |
[mge] |
| |
|
21 |
## USB cable |
| |
|
22 |
#driver = newhidups |
| |
|
23 |
#port = auto |
| |
|
24 |
## SNTMP |
| |
|
25 |
#driver = snmp-ups |
| |
|
26 |
#port = 1.2.3.4 |
| |
|
27 |
#mibs = mge |
| |
|
28 |
desc = "MGE UPS" |
| |
|
29 |
</verbatim> |
| |
|
30 |
|
| |
|
31 |
''/etc/nut/upsd.conf'' |
| |
|
32 |
<verbatim> |
| |
|
33 |
ACL all 0.0.0.0/0 |
| |
|
34 |
ACL localhost 127.0.0.1/32 |
| |
|
35 |
|
| |
|
36 |
ACCEPT localhost |
| |
|
37 |
REJECT all |
| |
|
38 |
</verbatim> |
| |
|
39 |
|
| |
|
40 |
''/etc/nut/upsd.users'' |
| |
|
41 |
<verbatim> |
| |
|
42 |
# Supervision user |
| |
|
43 |
[admin] |
| |
|
44 |
password = password |
| |
|
45 |
allowfrom = localhost |
| |
|
46 |
actions = SET |
| |
|
47 |
instcmds = ALL |
| |
|
48 |
|
| |
|
49 |
# Protection user |
| |
|
50 |
[monuser] |
| |
|
51 |
password = monitor |
| |
|
52 |
allowfrom = localhost |
| |
|
53 |
upsmon master |
| |
|
54 |
</verbatim> |
| |
|
55 |
|
| |
|
56 |
''/etc/nut/upsmon.conf'' |
| |
|
57 |
<verbatim> |
| |
|
58 |
MONITOR mge@localhost 1 monuser monitor master |
| |
|
59 |
MINSUPPLIES 1 |
| |
|
60 |
SHUTDOWNCMD "/sbin/shutdown -h +0" |
| |
|
61 |
POLLFREQ 5 |
| |
|
62 |
POLLFREQALERT 5 |
| |
|
63 |
HOSTSYNC 15 |
| |
|
64 |
DEADTIME 15 |
| |
|
65 |
#POWERDOWNFLAG /etc/killpower |
| |
|
66 |
RBWARNTIME 43200 |
| |
|
67 |
NOCOMMWARNTIME 300 |
| |
|
68 |
FINALDELAY 5 |
| |
|
69 |
NOTIFYCMD /sbin/upssched |
| |
|
70 |
NOTIFYFLAG ONBATT WALL+SYSLOG+EXEC |
| |
|
71 |
NOTIFYFLAG ONLINE WALL+SYSLOG+EXEC |
| |
|
72 |
NOTIFYFLAG LOWBATT WALL+SYSLOG+EXEC |
| |
|
73 |
NOTIFYFLAG FSD WALL+SYSLOG+EXEC |
| |
|
74 |
</verbatim> |
| |
|
75 |
|
| |
|
76 |
''/etc/nut/upssched.conf'' |
| |
|
77 |
<verbatim> |
| |
|
78 |
CMDSCRIPT /usr/local/bin/upssched-cmd |
| |
|
79 |
PIPEFN /var/run/upssched/upssched.pipe |
| |
|
80 |
LOCKFN /var/run/upssched/upssched.lock |
| |
|
81 |
|
| |
|
82 |
AT ONBATT * START-TIMER early-shutdown 30 |
| |
|
83 |
AT LOWBATT * START-TIMER early-shutdown 30 |
| |
|
84 |
AT ONLINE * CANCEL-TIMER resume |
| |
|
85 |
AT ONLINE * EXECUTE resume |
| |
|
86 |
AT FSD * EXECUTE forced-shutdown |
| |
|
87 |
</verbatim> |
| 7 |
GlennRamsey |
88 |
|
| |
|
89 |
GlennRamsey - On Ubuntu 8.04 the above script doesn't work. According to the man page the line: |
| |
|
90 |
<verbatim> |
| |
|
91 |
AT ONLINE * CANCEL-TIMER resume |
| |
|
92 |
</verbatim> |
| |
|
93 |
should be: |
| |
|
94 |
<verbatim> |
| |
|
95 |
AT ONLINE * CANCEL-TIMER early-shutdown resume |
| |
|
96 |
</verbatim> |
| 8 |
GlennRamsey |
97 |
but that seemed to cause a problem with cancelling the shutdown, after 30s had elapsed |
| |
|
98 |
<verbatim> |
| |
|
99 |
AT ONLINE * CANCEL-TIMER early-shutdown |
| |
|
100 |
</verbatim> |
| |
|
101 |
seems to work properly. I suspect the issue was related to the 'resume' command being given by both 'AT ONLINE' events. |
| |
|
102 |
|
| 3 |
DanielLawson |
103 |
|
| |
|
104 |
''/usr/local/bin/upssched-cmd'' |
| |
|
105 |
<verbatim> |
| |
|
106 |
#!/bin/bash |
| |
|
107 |
# time in minutes |
| |
|
108 |
time=2 |
| |
|
109 |
case "${1}" in |
| |
|
110 |
early-shutdown) |
| |
|
111 |
logger -t upssched-cmd "Early Shutdown" |
| |
|
112 |
shutdown -h +$time powerevent |
| |
|
113 |
;; |
| |
|
114 |
resume) |
| |
|
115 |
logger -t upssched-cmd "Resume" |
| |
|
116 |
[ -f /var/run/shutdown.pid ] && shutdown -c || exit 0 |
| |
|
117 |
;; |
| |
|
118 |
forced-shutdown) |
| |
|
119 |
logger -t upssched-cmd "Forced Shutdown" |
| |
|
120 |
shutdown -h +$time powerevent-forced |
| |
|
121 |
|
| |
|
122 |
;; |
| |
|
123 |
*) |
| |
|
124 |
logger -t upssched-cmd "Unknown command: ${1}" |
| |
|
125 |
;; |
| |
|
126 |
esac |
| |
|
127 |
</verbatim> |
| 6 |
GlennRamsey |
128 |
|
| |
|
129 |
!! Notes |
| |
|
130 |
|
| |
|
131 |
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 |
| |
|
132 |
|
| |
|
133 |
The Socomec NETYS PE UPS available from Dick Smith works with nut using the megatec_usb driver. -- GlennRamsey |
| |
|
134 |
|
| 3 |
DanielLawson |
135 |
|
| |
|
136 |
--- |
| |
|
137 |
|
| |
|
138 |
Part of CategorySystemAdministration |