NAME

upswatch - watches an UPS using an Hardware::UPS::Perl driver indirectly via TCP or directly on a serial device

SYNOPSIS

upswatch [ -h, --help ] [ -M, --man ] [ -V, --version ] [ -D, --driver driver ] [ -d, --debug-level [debuglevel] ] [ -g, --grace-period grace ] [ -L, --logfile logfile ] [ -l, --loop-time loop ] [ -m, --mailto mailto ] [ -p, --pidfile pidfile ] [ -r, --remote [HOST:[PORT] ] [device-name]

DESCRIPTION

upswatch watches an UPS using a driver specified on the command line. There are to ways of operating:

On the one hand, the UPS can reside on a local serial device specified by the optional device-name parameter. If the parameter is omitted, /dev/ttyS0, i.e. the COM1 port, is used per default unless overriden by the environment variable UPS_DEVICE.

On the other hand, the UPS can be watched via TCP/IP, if there is an UPS agent running at a remote host specified by the --remote option.

The program examines the UPS every loop seconds. For a period of one hour the minimum and maximum line voltage and frequency are determined. At each full hour these values are written to the syslog.

If the line voltage fails, the computer will be shutdown down savely after a grace period of grace minutes. If the line voltage returns within this period of time, the program will switch back to standard monitoring. Both events will be noted in the syslog. If a mail address mailto is provided, a mail will be sent to the corresponding recipient. This will be the case as well if the environment variable UPS_MAILTO is set.

All messages will be logged in a logfile specified by the -L or --logfile option, if available, /var/run/upswatch.log, otherwise.

OPTIONS

-h, --help

Displays a short usage help message and exits without errors.

-M, --man

Displays the embedded pod documentation of upswatch (this screen) using pod2man, groff and less as pager; it exits without errors.

-V, --version

Displays version information and exits without errors.

-D, --driver driver

Sets the UPS driver driver to use. driver is a case-insensitive string. If not specified, the default driver "Megatec" is used.

-d, --debug-level [debuglevel]

Sets the integer debug level debuglevel. If the debug level is not specified, a default of 1 is assumed. A higher debug level will increase the verbosity. The maximum is 5. If the debug level option is used the system will not shutdown automatically.

-g, --grace-period grace

Sets the grace period grace in minutes after that the system will be safely shutdown, if the line voltages failes. If not specified, a default value of 5 minutes is used.

-L, --logfile logfile

Sets the logfile to logfile. If this option is not specified, the default logfile /var/run/upswatch.log will be used.

-l, --loop-time loop

Sets the loop time loop in seconds, the UPS is examined. If not specified, a default value of 10 seconds is used.

-m, --mailto mailto

Sets the mail address to mailto. If not specified, no mail will be sent at all unless the environment variable UPS_MAILTO is set.

-p, --pidfile pidfile

Sets the PID file to pidfile. If this option is not specified, the default PID file /var/run/upswatch.pid will be used.

-r, --remote [HOST[:PORT]]

Switches to the remote operation modus, i.e. the UPS is watched via TCP/IP using a remotely running UPS agent. The remote site is specified by the HOST and optionally the TCP port PORT separated by ':'. If not specified, the local host's default FQDN will be used together with default TCP port 9050.

EXAMPLES

upswatch

Monitors the UPS on COM1 every 10 seconds and performes a safe shutdown, if the line voltage fails for more than 5 minutes.

upswatch -g 10 -l 20 /dev/ttyS1

Monitors the UPS on COM2 every 20 seconds with a grace time of 10 minutes, before the system will be shutdown in case of line voltage failure.

upswatch -r 192.168.1.2:7030

Monitors the UPS located at host 192.168.1.2 via an UPS agent listening at TCP port 7030 at this host.

SEE ALSO

groff(1), less(1), pod2man(1), upsadm(1), upsagent(1), upsstat(1), Getopt::Long(3pm), Time::HiRes(3pm), Hardware::UPS::Perl::Connection(3pm), Hardware::UPS::Perl::Connection::Net(3pm), Hardware::UPS::Perl::Connection::Serial(3pm), Hardware::UPS::Perl::Constants(3pm), Hardware::UPS::Perl::Driver(3pm), Hardware::UPS::Perl::Driver::Megatec(3pm), Hardware::UPS::Perl::General(3pm), Hardware::UPS::Perl::Logging(3pm), Hardware::UPS::Perl::PID(3pm), Hardware::UPS::Perl::Utils(3pm)

AUTHOR

Bernd Holzhauer, info@cc-c.de Christian Reile, Christian.Reile@t-online.de