~ubuntu-branches/ubuntu/saucy/nut/saucy

« back to all changes in this revision

Viewing changes to INSTALL

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-07-20 19:48:50 UTC
  • mto: (16.1.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050720194850-oo61wjr33rrx2mre
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    For the purposes of this document, the user name and group name 
39
39
    will both be "nut".
40
40
 
 
41
    Be sure the new user is a member of the new group!  If you forget to
 
42
    do this, you will have problems later on when you try to start upsd.
 
43
 
41
44
============================================================================
42
45
============================================================================
43
46
============================================================================
76
79
 
77
80
        make install
78
81
 
 
82
    If you would like sample versions of the configuration files to
 
83
    be installed, use the install-conf target:
 
84
 
 
85
        make install-conf
 
86
 
 
87
    Sample files are installed with names like ups.conf.sample so they
 
88
    will not overwrite any existing real config files you may have 
 
89
    created.
 
90
 
79
91
    If you are packaging this software, then you will probably want to
80
92
    use the DESTDIR variable to redirect the build into another place,
81
93
    i.e.:
82
94
 
83
95
        make DESTDIR=/tmp/package install
 
96
        make DESTDIR=/tmp/package install-conf
84
97
 
85
98
---------------------------------------------------------------------------
86
99
 
87
 
 5. Create a directory for the driver(s) and server to use for data,
88
 
    and make it owned by the user you created.
 
100
 5. Create the state path directory for the driver(s) and server to use
 
101
    for storing UPS status data and other auxiliary files, and make it
 
102
    owned by the user you created.
89
103
 
90
 
        mkdir /var/state/ups
 
104
        mkdir -p /var/state/ups
91
105
        chmod 0700 /var/state/ups
92
106
        chown nut:nut /var/state/ups
93
107
 
98
112
    the user you created earlier.
99
113
 
100
114
    These examples assume the second serial port (ttyS1) on a typical
101
 
    Slackware system.  Serial port device names vary greatly, so yours
102
 
    may be quite different.
 
115
    Slackware system.  On FreeBSD, that would be cuaa1.  Serial ports
 
116
    vary greatly, so yours may be called something else.
103
117
 
104
118
        chmod 0600 /dev/ttyS1
105
119
        chown nut:nut /dev/ttyS1
106
120
 
107
121
    NOTE: if you are using something like devfs, make sure these
108
 
    permissions do not reset themselves when your system reboots.
109
 
    Otherwise, your driver(s) may fail to start.
 
122
    permissions stay set across a reboot.  If they revert to the old
 
123
    values, your drivers may fail to start.
110
124
 
111
125
---------------------------------------------------------------------------
112
126
 
113
 
 7. Create section(s) for your hardware in /usr/local/ups/etc/ups.conf
 
127
 7. Create one section per UPS in /usr/local/ups/etc/ups.conf
114
128
 
115
129
    To find out which driver to use, check the "HARDWARE SUPPORT TABLE"
116
 
    in the README file, or docs/driver.list.
117
 
 
118
 
    Once you have picked a driver, create an entry for your UPS in
119
 
    ups.conf.  If the driver does not need any extra configuration
120
 
    options, then it should resemble this:
121
 
 
 
130
    in the README file, or data/driver.list.
 
131
 
 
132
    Once you have picked a driver, create a section for your UPS in
 
133
    ups.conf.  You must supply values for "driver" and "port".
 
134
 
 
135
    Some drivers may require other flags or settings.  The "desc" value
 
136
    is optional, but is recommended to provide a better description of
 
137
    what your UPS is supporting.
 
138
 
 
139
    A typical UPS without any extra settings looks like this:
 
140
    
122
141
        [myupsname]
123
142
                driver = mydriver
124
143
                port = /dev/ttyS1
133
152
 
134
153
        /usr/local/ups/bin/upsdrvctl start
135
154
 
136
 
    If the driver doesn't start cleanly, make sure you're starting the 
137
 
    right one for your hardware.  Also check the man page for the
138
 
    driver to see if there are any extra values that you can set.
 
155
    Make sure the driver doesn't report any errors.  It should show a
 
156
    few details about the hardware and then enter the background.  You
 
157
    should get back to the command prompt a few seconds later.  For
 
158
    reference, a successful start of the belkin driver looks like this:
 
159
 
 
160
        # /usr/local/ups/bin/upsdrvctl start
 
161
        Network UPS Tools - UPS driver controller 1.5.12
 
162
        Network UPS Tools - Belkin Smart protocol driver 0.21 (1.5.12)
 
163
        Detected F6C525-SER on /dev/cuaa0
 
164
        #
 
165
 
 
166
    If the driver doesn't start cleanly, make sure you have picked the
 
167
    right one for your hardware.  You might need to try other drivers
 
168
    by changing the "driver=" value in ups.conf.
 
169
 
 
170
    Be sure to check the driver's man page to see if it needs any extra
 
171
    settings in ups.conf to detect your hardware.
139
172
 
140
173
    If it says "can't bind /var/state/ups/..." or similar, then your
141
174
    state path probably isn't writable by the driver.  Check the
142
 
    permissions and mode on that directory.
 
175
    permissions and mode on that directory (step 5).
143
176
 
144
177
    After making changes, try step 6 again.
145
178
 
147
180
 
148
181
---------------------------------------------------------------------------
149
182
 
150
 
 9. Configure the network server (upsd).  The files that need your
151
 
    attention are upsd.conf and upsd.users.  Sample versions are
152
 
    installed in most cases.
 
183
 9. Configure upsd, which serves data from the drivers to the clients.
153
184
 
154
 
    At the very least, you need something like this in upsd.conf:
 
185
    First, edit upsd.conf to allow access to your client systems.
 
186
    A minimal configuration which allows localhost to read status
 
187
    data (and nothing else) looks like this:
155
188
 
156
189
        ACL all 0.0.0.0/0
157
190
        ACL localhost 127.0.0.1/32
158
191
 
159
 
        ACCESS grant monitor localhost
160
 
        ACCESS deny all all
161
 
 
162
 
    That much is already in the sample upsd.conf, so just copying that 
163
 
    to the proper name should get you started.  You should add 
164
 
    additional ACL/ACCESS directives for other hosts/networks that need
165
 
    to talk to upsd on this system.
166
 
 
167
 
    Note: upsd.conf and upsd.users must not be world-readable, since
168
 
    they control access controls and passwords.  They do need to be
169
 
    readable by the user you created in the preparation process.
170
 
 
171
 
    The suggested configuration is to make it owned by that user,
172
 
    mode 0400:
173
 
 
174
 
        chown nut:nut upsd.conf upsd.users
175
 
        chmod 0400 upsd.conf upsd.users
 
192
        ACCEPT localhost
 
193
        REJECT all
 
194
 
 
195
    If you have other hosts or networks which will need to talk to
 
196
    upsd, you should create ACL and ACCEPT directives for them.
 
197
 
 
198
    Next, create upsd.users.  For now, this can be an empty file.
 
199
    You can come back and add more to it later when it's time to 
 
200
    configure upsmon or run one of the management tools.
 
201
 
 
202
    Do not make either file world-readable, since they both hold
 
203
    access control data and passwords.  They just need to be readable by
 
204
    the user you created in the preparation process.
 
205
 
 
206
    The suggested configuration is to chown it to root, chgrp it to the
 
207
    group you created, then make it readable by the group.
 
208
 
 
209
        chown root:nut upsd.conf upsd.users
 
210
        chmod 0640 upsd.conf upsd.users
176
211
 
177
212
    *** References: man pages: upsd.conf(5), upsd.users(5), upsd(8)
178
213
 
182
217
 
183
218
        /usr/local/ups/sbin/upsd
184
219
 
 
220
    Make sure it is able to connect to the driver(s) on your system.
 
221
    A successful run looks like this:
 
222
 
 
223
        # /usr/local/ups/sbin/upsd
 
224
        Network UPS Tools upsd 1.5.12
 
225
        Connected to UPS [belkin]: belkin-cuaa0
 
226
        Synchronizing...done
 
227
        # 
 
228
 
 
229
    upsd prints dots while it waits for the driver to respond.  Your
 
230
    system may print more or less depending on how many drivers you
 
231
    have and how fast they are.
 
232
 
185
233
    NOTE: if upsd says that it can't connect to a UPS or that the data
186
234
    is stale, then your ups.conf is not configured correctly, or you
187
 
    have a driver that isn't working properly. 
188
 
 
189
 
    Nothing else will work until you fix it.
 
235
    have a driver that isn't working properly.  You must fix this before
 
236
    going on to the next step.
190
237
 
191
238
    *** Reference: man page: upsd(8)
192
239
 
194
241
 
195
242
11. Make sure that the UPS is providing good status data.
196
243
 
197
 
        /usr/local/ups/bin/upsc myupsname@localhost     
198
 
 
199
 
    Ignore everything but "ups.status" for now.  If your system is
200
 
    running on line power, it should have "OL" in that field. 
201
 
    Otherwise, something is wrong with the driver that was configured in
202
 
    step 5.
 
244
        /usr/local/ups/bin/upsc myupsname@localhost ups.status
 
245
 
 
246
    You should see just one line in response:
 
247
 
 
248
        OL
 
249
 
 
250
    OL means your system is running on line power.  If it says something
 
251
    else (like OB - on battery, or LB - low battery), your driver was 
 
252
    probably misconfigured in step 7.  If you reconfigure the driver,
 
253
    use 'upsdrvctl stop' to stop it, then start it again in step 8.
203
254
 
204
255
    If upsc says "access denied", then your upsd.conf probably doesn't
205
 
    have a good ACL/ACCESS definition for your host.
206
 
 
207
 
    *** Reference: man page: upsc(8)
208
 
 
209
 
---------------------------------------------------------------------------
210
 
 
211
 
12. Edit your startup scripts.
 
256
    have a good ACL/ACCEPT definition for your host.  Go back to step
 
257
    9 and fix it.  If you reconfigure upsd, you must either stop and
 
258
    restart it, or tell it to reload (upsd -c reload).
 
259
 
 
260
    *** Reference: man page: upsc(8)
 
261
 
 
262
---------------------------------------------------------------------------
 
263
 
 
264
12. Look at all of the status data which is being monitored.
 
265
 
 
266
        /usr/local/ups/bin/upsc myupsname@localhost
 
267
 
 
268
    What happens now depends on the kind of UPS and driver you have.
 
269
    In the list, you should see ups.status with the same value you got
 
270
    above.  A sample run on a Belkin Regulator Pro looks like this:
 
271
 
 
272
        battery.charge: 100
 
273
        battery.temperature: 048
 
274
        battery.voltage: 13.9
 
275
        driver.name: belkin
 
276
        driver.parameter.port: /dev/cuaa0
 
277
        driver.version: 1.5.12
 
278
        driver.version.internal: 0.21
 
279
        input.frequency: 59.9
 
280
        input.transfer.high: 127.6
 
281
        input.transfer.low: 96.6
 
282
        input.voltage: 119.0
 
283
        output.frequency: 59.9
 
284
        output.voltage: 119.0
 
285
        ups.firmware: 001
 
286
        ups.load: 018
 
287
        ups.mfr: BELKIN
 
288
        ups.model: F6C525-SER
 
289
        ups.status: OL
 
290
        ups.temperature: 048
 
291
 
 
292
    *** Reference: man page: upsc(8)
 
293
 
 
294
---------------------------------------------------------------------------
 
295
 
 
296
13. Edit your startup scripts.
212
297
 
213
298
    Make sure upsdrvctl and upsd are run every time your system starts.
214
299
 
224
309
sure your system shuts down properly, you will need to perform some
225
310
additional configuration and run upsmon.  Here are the basics:
226
311
 
 
312
---------------------------------------------------------------------------
 
313
 
227
314
 1. Configure upsd to recognize upsmon.
228
315
 
229
316
    First create an ACL in upsd.conf for the host that will be running
230
 
    upsmon.  Be sure to grant it monitor privileges with an ACCESS line.
231
 
    This will allow upsmon to connect to upsd.
 
317
    upsmon.  Then use it in an ACCEPT line to allow that host to monitor
 
318
    the UPS.  This will let upsmon connect to upsd.
 
319
 
 
320
    Assuming a host called mybox with the IP address of 192.168.1.50,
 
321
    the configuration looks like this:
 
322
 
 
323
        ACL mybox 192.168.1.50/32
 
324
        ACCEPT mybox
 
325
 
 
326
    You probably have other ACL and ACCEPT/REJECT lines, so be sure this
 
327
    ACCEPT happens above any REJECTs which may match this client.  Most 
 
328
    users have a "REJECT all" at the bottom.  Here's an example which 
 
329
    grants access to localhost and mybox, then rejects anything else.
232
330
 
233
331
        ACL all 0.0.0.0/0
234
 
        ACL mybox a.b.c.d/32
235
 
        ACCESS grant monitor mybox
236
 
        ACCESS deny all all
 
332
        ACL localhost 127.0.0.1/32
 
333
        ACL mybox 192.168.1.50/32
 
334
 
 
335
        ACCEPT localhost
 
336
        ACCEPT mybox
 
337
        REJECT all
 
338
 
 
339
    Note: if you run a firewall of some sort, you may have to add a rule
 
340
    to allow this connection.  upsd runs on port 3493/tcp by default.
237
341
 
238
342
    *** References: man pages: upsd(8), upsd.conf(5)
239
343
 
240
344
---------------------------------------------------------------------------
241
345
 
242
 
 2. Edit upsd.users, and create a user for upsmon to use.  This will
243
 
    allow upsmon to coordinate shutdowns with other systems.
 
346
 2. Create a upsd user for upsmon to use while monitoring this UPS.
 
347
 
 
348
    Edit upsd.users and create a new section.  upsmon will connect
 
349
    to upsd and use this user name (in brackets) and password to
 
350
    authenticate.  This example is for a user called "monuser":
244
351
 
245
352
        [monuser]
246
353
                password = mypass
247
354
                allowfrom = mybox
248
 
                upsmon master           (or upsmon slave)
 
355
                upsmon master           # or upsmon slave
249
356
 
250
357
    *** References: man pages: upsd(8), upsd.users(5)
251
358
 
252
359
---------------------------------------------------------------------------
253
360
 
254
 
 3. Edit upsmon.conf, and create a MONITOR directive with that host,
255
 
    username, and password.
256
 
 
257
 
        MONITOR myupsname@mybox 1 monuser mypass master         (or slave)
258
 
 
259
 
    Also check the POWERDOWNFLAG to make sure it's what you want.
260
 
 
261
 
    *** References: man pages: upsmon(8), upsmon.conf(5)
262
 
 
263
 
---------------------------------------------------------------------------
264
 
 
265
 
 4. Reload upsd.  Depending on your configuration, you may be able to 
 
361
 3. Reload upsd.  Depending on your configuration, you may be able to 
266
362
    do this without stopping upsd:
267
363
 
268
364
        /usr/local/ups/sbin/upsd -c reload
277
373
 
278
374
---------------------------------------------------------------------------
279
375
 
280
 
 5. Start upsmon.
 
376
 4. Set the POWERDOWNFLAG location for upsmon.
 
377
 
 
378
    In upsmon.conf, add a POWERDOWNFLAG directive with a filename.
 
379
    upsmon will create this file when the UPS needs to be powered off
 
380
    during a power failure when low battery is reached.
 
381
 
 
382
    We will test for the presence of this file in a later step.
 
383
 
 
384
        POWERDOWNFLAG /etc/killpower
 
385
 
 
386
    *** References: man pages: upsmon(8), upsmon.conf(5)
 
387
 
 
388
---------------------------------------------------------------------------
 
389
 
 
390
 5. Secure upsmon.conf.
 
391
 
 
392
    The recommended setting is to have it owned by root:nut, then
 
393
    make it readable by the group and not world.  This file contains
 
394
    passwords that could be used by an attacker to start a shutdown,
 
395
    so keep it secure.
 
396
 
 
397
        chown root:nut upsmon.conf
 
398
        chmod 0640 upsmon.conf
 
399
 
 
400
    This step has been placed early in the process so you secure this
 
401
    file before adding sensitive data in the next step.
 
402
 
 
403
---------------------------------------------------------------------------
 
404
 
 
405
 6. Create a MONITOR directive for upsmon
 
406
 
 
407
    Edit upsmon.conf and create a MONITOR line with the UPS definition
 
408
    (<upsname>@<hostname>), username and password from step 2, and
 
409
    the master or slave setting.
 
410
 
 
411
    If it's the master (i.e., it's connected to this UPS directly):
 
412
 
 
413
        MONITOR myupsname@mybox 1 monuser mypass master
 
414
 
 
415
    If it's just monitoring this UPS over the network, and some other
 
416
    system is the master:
 
417
 
 
418
        MONITOR myupsname@mybox 1 monuser mypass slave
 
419
 
 
420
    The number "1" here is the power value.  This should always be set
 
421
    to 1 unless you have a very special (read: expensive) system with
 
422
    redundant power supplies.  See big-servers.txt and data-room.txt.
 
423
 
 
424
    *** References: man pages: upsmon(8), upsmon.conf(5)
 
425
 
 
426
---------------------------------------------------------------------------
 
427
 
 
428
 7. Define a SHUTDOWNCMD for upsmon.
 
429
 
 
430
    Still in upsmon.conf, add a directive that tells upsmon how to
 
431
    shut down your system.  This example seems to work on most systems:
 
432
 
 
433
        SHUTDOWNCMD "/sbin/shutdown -h +0"
 
434
 
 
435
    Notice the presence of "quotes" here to keep it together.
 
436
 
 
437
    If your system has special needs, you may want to set this to
 
438
    a script which does local shutdown tasks before calling init.
 
439
 
 
440
---------------------------------------------------------------------------
 
441
 
 
442
 8. Start upsmon.
281
443
 
282
444
        /usr/local/ups/sbin/upsmon
283
445
 
 
446
    If it complains about something, then check your configuration.
 
447
 
284
448
---------------------------------------------------------------------------
285
449
 
286
 
 6. Look for messages in the syslog to indicate success.  It should look
 
450
 9. Look for messages in the syslog to indicate success.  It should look
287
451
    something like this:
288
452
 
289
453
        May 29 01:11:27 mybox upsmon[102]: Startup successful
290
 
        May 29 01:11:28 mybox upsd[100]: Client monuser@a.b.c.d logged into UPS [myupsname]
 
454
        May 29 01:11:28 mybox upsd[100]: Client monuser@192.168.50.1
 
455
        logged into UPS [myupsname]
 
456
 
 
457
    Any errors seen here are probably due to an error in the config
 
458
    files of either upsmon or upsd.  You should fix them before
 
459
    continuing.
291
460
 
292
461
---------------------------------------------------------------------------
293
462
 
294
 
 7. Edit your startup scripts: add upsmon
 
463
10. Edit your startup scripts: add upsmon
295
464
 
296
465
    Make sure upsmon starts when your system comes up.  Do it after
297
466
    upsdrvctl and upsd, or it will complain about not being able to
299
468
 
300
469
---------------------------------------------------------------------------
301
470
 
302
 
 8. Edit your shutdown scripts: add upsdrvctl shutdown
 
471
11. Edit your shutdown scripts: add upsdrvctl shutdown
303
472
 
304
473
    You should configure your system to power down the UPS after the
305
474
    filesystems are remounted read-only.  Have it look for the presence
309
478
        then
310
479
                echo "Killing the power, bye!"
311
480
                /usr/local/ups/bin/upsdrvctl shutdown
 
481
 
 
482
                sleep 120
 
483
 
 
484
                # uh oh... the UPS power-off failed
 
485
                # you probably want to reboot here so you don't get stuck!
 
486
                # *** see the section on power races in shutdown.txt! ***
312
487
        fi
313
488
 
314
489
    Be careful: that upsdrvctl command will probably power off your