POWERD(8)

NAME
powerd -- monitor an UPS through serial line, tcp port or file.

SYNOPSIS
/sbin/powerd [options]

DESCRIPTION
Powerd is a daemon process that sits in the background and monitors the state of an Uninterruptible Power Supply (UPS). Information comes to powerd from the status signals of a serial line, from a remote host, or from a fifo. Alternatively, powerd can spawn another process which reports information on stdout.

The idea is to have a single tool which can handle a variety of situations without need to hack the source code. This version of powerd can be configured either on the command line or by means of a configuration file. This version of powerd is designed to work with init release 2.4 or later under the Linux environment.

The program performs two tasks: it brings down the system to single-user mode when a powerfail is detected, and it brings back the system to multi-user mode when the power is back. Proper setup of the system startup files is required, as explained in both the UPS-HOWTO and the README file of powerd itself.

OPTIONS
The whole configuration file can be passed to powerd on the command line. Usually, however, it is preferable to write a configuration file. A sample configuration file is enclosed in the package distribution. Commands which can either go on command line or in the configuration file are described below, in the section ``COMMANDS''.

EXAMPLES
Here I present some example of powerd invocation. They are meant to ease testing without continuous editing of /etc/powerd.conf, and to avoid altogether writing of the file in most simple situations.
powerd
This simplest invocation causes powerd to read the default configuration file, /etc/powerd.conf.
powerd /dev/ttyS0
powerd /dev/cua0
powerd /var/run/upsctl
powerd /etc/powerd.conf.new
When infoked with a single argument, the program behaves differently according the the file type: if it is a regular file it is used in place of the default configuration file; if it is a fifo it is used as the monitoring information, and powerd waits for "OK" or "FAIL"; if it is a serial device it is used to monitor the DCD line, like powerd version 1 used to do.

powerd /dev/cua0 -port 1043
    If a tcp port is specified last in the command line, powerd uses it to report information to clients. Powerd becomes a network server.

powerd -host jupiter 1043
    The daemon will connect as a client to the specified TCP port of a remote server. Powerd's running on different computers, using "-port"/"-host" can happily be used to handle a single UPS feeding power to more than one computer.

powerd serialline=/dev/cua1 monitor=DCD failwhen=high
    If needed, the whole configuration file can be fed on the command line. Possible commands are listed below.

THE CONFIGURATION FILE
The configuration file for powerd is line-oriented. Any line where the first non-black character is a hash mark is ignored. Any empty line is ignored. Other lines should contain pairs "option value", where option is an option keyword, and value is its value. Note that the separator is one or more white spaces, while on the command line the separator is the `=' sign. option is the first word on the line, and value is the following word. if value nedds to be more than one word, enclose it within double quotes. Boolean entities can do without a value field. The followin keywords may appear in the configuration file. The description here is quite skeletal, and you should refer to the sample powerd.conf distributed with the powerd source code.

disabled
    Boolean, on by default. A disabled daemon only generates messages, without shutting down the system.

delay seconds
    Wait before taking action, and re-sample the input later. To ignore glitches. Default is 0 for network clients and 10 otherwise.

debug
    Boolean. If on it disables fork()ing and prints many messages on stderr.

logfile filename
    Even if debug is on, fork, and redirect stderr to the specified file.

remoteserver hostname
    Use the remote host as source for power information.

serverport portnumber
    Number of the UDP port to use, as server or client. If the port is specified and "remoteserver" is not, this host is the server.

timeout seconds
    Time to wait for a server reply before retrial.

trials number
    How many times to try the connection. If that fails, the daemon exits.

serialline pathname
    Use the serial device as source for power information.

monitor signal_name
    Tell which signal (wire) conveys info. Defaults to `DCD'.

failwhen condition
    Either ``high'', ``low'' or a string, according to what is being monitored,

asserthigh signal_name
    Toggle an outgoing serial signal (wire), and delay one second before proceeding.

assertlow signal_name
    The same.

pollingstep seconds
    Time to wait between samples when information comes from a non-selectable agent (like the serial port), or via udp (network).

readfifo pathname
    Use a fifo as source for power information. Mainly for hand-testing.

spawnmonitor commandline
    Invoke an external program, using its stdout as source for power information.

DIAGNOSTICS
Powerd reports any configuration error on stderr, and any subsequent error to syslogd. When debug is active, the program doesn't go to the backgroud. And prints everything to stderr.

BUGS
Report any new bug to rubini@ipvvis.unipv.it. Be sure to include "powerd" in the subject line, to help me sort my folder.

SEE ALSO
shutdown(8), init(8), inittab(5), README in the powerd distribution, genpower-1.0.x by Tom Webster, the UPS-HOWTO.

AUTHORS
Miquel van Smoorenburg, miquels@drinkel.nl.mugnet.org
Alessandro Rubini, rubini@ipvvis.unipv.it