Version 0.4

	I write this program just because I have bought 
Pulsar ES5+ UPS for protect my Internet server. Software
what I get form MGE's WWW server imho not apply to Linux
ideology. My program like many others UPS daemons check up
only for three state of UPS: OK, power fail, low battery
and send this information to init in usual way - write
state of UPS to file /etc/powerstatus & send SIGPWR to
init. If program was started with option -pwroff or -q
the UPS turns power off. Unlike many others UPS "Pulsar"
turns off even if main supply restored during shutdown
procedure when monitoring daemon is already killed & shutdown
can not be canceled. In this case power will be turned on
after several (as for me just about 5) seconds.

	To install mgeupsd on your system type
make install
it will be installed mgeupsd and its manpages.

	To run mgeupsd just insert to any startup script
(depend on your distribution, f.e. rc.M in slackware,
in RH you may create your own SXXrunups - see example
in rc.d.sample) line
mgeupsd [options] ttyline
where ttyline is the name of tty port where UPS is connected
to your machine. ttyline may be defined as ttyXnn or /dev/ttyXnn.
The possible options are:
-q	- turn ups off
	It's usually used to turn computer off while shutdowning in
	powerfail mode. In Slackware in script /etc/rc.d/rc.0 calling
	of powerd -q exist already, you must only change calling of 
	powerd to mgeupsd. For RH I put in rc.d.sample file S99poweroff
	which must be placed as /etc/rc0.d/S99poweroff.
-pwroff N - turn ups off, but wait N seconds first

-t trace_file - turn on trace of UPS<->computer communication
		protocol. Use only for debugging - this produce
		a huge output. Since trace_file stay opened all
		time to its remove you must kill mgeupsd before.

-l	- Use syslog for reporting. off by default, but very useful
	  option.

-i N	- set UPS checking interval to N seconds. Default 10

-li N	- set to N interval for reporting battery low status. Usually
	  if battery low status reported init must start immediate
	  shutdown. When shutdown started it must kill mgeupsd.
	  If mgeupsd is not killed during N seconds the low battery
	  status will be reported again. Default 30

-s on|off - turn power saving mode on or off (see UPS manual for more
	    information about power saving mode)

-p on|off - turn total discharge protection on or off (see UPS manual
	    for more information about  total discharge protection)

Since version 0.3 you may use your UPS not only for protecting the
computer, powered from UPS. You may connect to computer UPS which
protect any other equipment (f.e. rack-mount modems). For this case
there are some additional options:

-pwrfile filename	- Change power status filename from default 
			(/etc/powerstatus) to something else.

-process  pid		- Change pid of process to send SIGPWR from
			default (1 - init) to pid. mgeupsd check is
			this process running.

-run /path/cmd		- Don't send SIGPWR at all, but run specified
			program & give power status file as a first
			argument. Note that program must be specified
			with full path.

-swpwr W,B		- Switch (turn off/on) power. Argument W set
			the time in minutes to wait before turning
			power back to on. Argument B set the time in
			seconds to wait before turning power off. You
			may set only one time (f.e. -swpwr W or 
			-swpwr ,B or even -swpwr ,) - in this case 
			unspecified time will be set to 0. Note that
			the time before power off must be in seconds,
			but the time before power on - in minutes.
			If waiting time for turn UPS back to on set
			to 0, power will be turned off just about
			5 seconds.
	Several examples:
Start monitoring with sending SIGPWR to process 1111
mgeupsd -l -pwrfile /tmp/pwf -process 1111 ttyS3

Start monitoring with running /sbin/mdmpwfail when UPS
status changes. Look in rc.d.sample/mdmpwfail.skeleton
for example. 
mgeupsd -l -pwrfile /tmp/pwf -run /sbin/mdmpwfail ttyS3

Switch power for 5 seconds.
mgeupsd -swpwr , ttyS3

Wait 20 seconds & turn off power for a 5 minutes.
mgeupsd -swpwr 5,20 ttyS3

Turn power off for 1 minute immediately
mgeupsd -swpwr 1 ttyS3


Since version 0.4 mgeupsd also can act as a network server for
daemons running on other machines connected to one UPS by power
cord. As a remote power status daemon I use powerd-2.0 by
Alessandro Rubini  <rubini@ipvvis.unipv.it>. It can be downloaded
from: ftp://sunsite.unc.edu/pub/Linux/system/ups/powerd-2.0.tar.gz
For use mgeupsd as a server there are two additional options:

-S		Run in server mode.

-P port		Use UDP portnumber port instead of default 2045.

NOTE: To use this feature you need to setup NET=1 in a head of
Makefile. Otherwise mgeupsd will be compiled without network
support.
 

	After announcing version 0.1 I receive a lot of e-mail with
questions about cable. UPS must be connected to machine by usual
RS-232 9pin to 9pin cable. Pins on connectors must be connected 
one-to-one, i.e. 1-1,2-2,..9-9. Those cable was included to my
UPS from factory. If you have not such cable you can buy it in
nearest computer shop or make it by yourself. If port on your 
machine has 25pin connector to connect included cable you can use
usual 25_to_9 adaptor. To make this cable by yourself use
this table:
Machine		UPS
25pin		9pin
female		male
2	-	3	*
3	-	2	*
4	-	7
5	-	8
6	-	6
7	-	5	*
8	-	1	*
20	-	4
22	-	9

The wires marked by (*) are mandatory.

I add to this archive program talkups.
This program is intended for communicate with UPS
by hand for debugging purposes. To use type
talkups /dev/ttyXnn
To leave this program press ^C.

That's about all. If you have any suggestion or question about this
program don't hesitate to write to me. My E-mail: stas@esc.kharkov.com
