UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / kernstodo
blob4dc864eeb167ae5adf69833664e234cb0c5a1332
1                 Kern's ToDo List
3 - Convert Windows emulation from Cygwin to native Win32
4   The main missing piece here is an emulation layer for
5   the serial port.
6 - Implement USB support for Windows
7 - Convert the manual to LaTeX
8   This will be done in the next couple of months.
9 - Consider converting apcupsd to C++
10   This will be done in the next couple months -- after
11   the 3.10.17 release.
13 - UPS 500ES with cable 094-0127B
14   BATTERYLEVEL -5
15   otherwise the UPS would shut off immediately.
16 - The UPS sensitivity can be adjusted using the UPS front-panel. You press and 
17   hold the Power Switch for more than 10 seconds and then press again 
18   repeatedly until the required number of front-panel indicators are displayed.
19   The UPS manual includes information on adjusting the Transfer Voltage using 
20   this procedure.
21 - Add a call to a script on restart after a powerfailure.
22   Can we have the init.d script call the apccontrol script with a some 
23   kind of "restart" event if the powerfail file existed?
24 - If you --disable-nis, then the build of apcaccess fails.
25 - See if NISIP is properly documented saying that it restricts to
26   the IP you set.
27 - Fix make file dependencies by adding libaries to dependencies
28   in src/Makefile.in, but do not add $(LIBS).
29 - Document problem with Dmsg() going to serial port.
30 - Document apctest.
31 - Document that manually running the UPS you should send
32   Y first of all.
33 - Fix DNS for apcupsd.com and apcupsd.org being set by Italian
34   server.
35 - Check if new net code does the following on a slave during
36   a power failure:
37     Fri Sep 05 15:19:55 CEST 2003 Power failure.
38     Fri Sep 05 15:19:55 CEST 2003 Running on UPS batteries.
39     Fri Sep 05 15:20:02 CEST 2003 Power is back. UPS running on mains.
40     Fri Sep 05 15:20:07 CEST 2003 Power failure.
41     Fri Sep 05 15:20:07 CEST 2003 Running on UPS batteries.
42     Fri Sep 05 15:20:10 CEST 2003 Power is back. UPS running on mains.
44 === USB on windows ====
45 usbhidioc2.zip in apcupsd/others
46     Re: Apcupsd for Win32 with USB support ?
47     From: "Vladislav Staroselskiy" <inet@vladstar.pp.ru>
48     To: kern@sibbald.com
49     CC: "Apcupsd-users" <apcupsd-users@lists.sourceforge.net>
50         
51     Hi Kern !
53     > > Is there any chance to see Apcupsd for Win32 with USB support at the
54     near
55     > > future ?
56     > Very unlikely, unless someone sends me or points me to some sample code
57     > that reads and writes USB via Windows. Even then, I'm not too
58     > enthusiastic about programming in Windows.
61     There are code examples here: http://www.alanmacek.com/usb/deviceAPI.html
63     There are also few helpful links:
64     USB Central: http://www.lvr.com/usb.htm
65     USB drivers page on MSDN:
66     http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceddk40/html/cxconusbdrivers.asp
67     MSDN newsgroups, where programming questions can be asked:
68     http://msdn.microsoft.com/newsgroups/
70     P.S. Please, don't drop this idea, the most of modern UPS's don't have
71     serial port anymore, but Windows is still OS, that users like to have on
72     their workstations... and THANKS for doing this project, apcupsd is great !
74     Sincerely yours, Vladislav Staroselskiy.
75 ======
77 =====
78     In PowerChute Plus a daemon "_upsd" starts during the booting
79     process (or it could be started manually) by reading the
80     "pwrchute.ini" file such as "apcups.conf" in APCUPSD. This file
81     specify the parameters to the daemon, in which several variables
82     are included.  The interesting one is ups turn off and wakeup
83     time in hours.
85     By reading the ups turn off time the daemon execute the process
86     to turn off the Computer and ups at specific time, based on the
87     system clock.  This process would be summarized as follows:
89     1.  At the specific time the daemon (_upsd) execute a script to
90     shutdown the system.  This script contain the command to shutdown
91     the system (system dependent)
93     2.  An script file is written on root directory called
94     "upsoff.cmd" by the daemon.  This file consist the command to
95     turn off the ups.  Such as:
97     !/bin/sh
98     /usr/lib/powerchute/upsoff /dev/ttyd0 Normal UUS^@
100     The above script produced during the power failure situation and
101     similarly the following script will be produced during the
102     scheduled shutdown, in which "upsoff" is a binary in PowerChute
103     Plus package to turnoff the UPS. The above scenario is as power
104     failing situation in APCUPSD with "killpower" option.
106     !/bin/sh
107     /usr/lib/powerchute/upsoff /dev/ttyd0 Normal @165^@
109     The final parameter specifies the amount of time UPS has to go on
110     sleep, i.e., the above script is executed by the "halt" script in
111     RedHat and removed.  So that, it turn of the UPS (or make it to
112     sleep for specific time in 24 hors time period) then it the UPS
113     will wake up after the prescribed time.  Just as power failing
114     situation in APCUPSD with "killpower" option.  Then the system
115     will up as usual.  The last parameter variables specify from the
116     command set of the UPS (as I hope).
119 - Possibly add a user configurable delay before declaring a
120   power outage.
121 - If you add a battery pack, there is a special procedure to do
122   that is documented in the APC Knowledge Base in order for the
123   timeleft to be updated properly.
124 - Put the apcupsd events into Win system log.
125 - To whom it may concern:  May 2003
126   I have found a vendor for the APC 940-0095A cables as well as all of
127   the other cables that APC makes.  The discount of the cable equates to
128   roughly 30%.
129   I bought a 940-0095A for $30.00 US + shipping from Stonewall Cable,
130   Inc.  www.stonewallcable.com
131     James Widener <james at manisys.com>
132 - I have a quantity of new in the package 940-0127A cables you mention
133   on your website for UPS. Do you know of anyone needing a large quantity
134   of these?  Also manual/packets and other short electronic type cables.
135   Please feel free to pass on my name if you can.  Thank you.
137   Carl Lindahl                     May 2003
138   Hardware Engineer
139   American Systems Corporation
140   7001 University Blvd
141   Winter Park, Fl 32792
142   carl.lindahl@2asc.com
143   407-678-8500 x6033
144   407-678-5178 fax
147 - Add minVolt maxVolt to apcupsd (calculate them ourselves).
148 - Apparently apcaccess status crashes for apcupsd without threads.
149 - Try adding -lm if a local copy of libgd is used (or patch the
150   makefile).
151 - Please consider creating a graphical setup for APCUPSD which would
152   walk the user through the type of UPS, how it is conneted, the type
153   cable used similar to the Palm configuration in Ximian Evolution.
155   After several attempts, I was unsuccessful at using APCUPSD, until I
156   found (http://www.mandrake.com/en/archives/cooker/2002-04/msg01252.php)
157   which provides all of the configuration needed to use APCUPSD with
158   Mandrake 8.2.
160 - Produce a more reasonable error message in attempting EEPROM
161   configuration on a USB device.
162 - Check that 3.10.5 will autostart on XP
163 - Neither 3.8.6 nor 3.10.5 has a description of the service displayed under
164   admintools/services/properties/description on XP (Gorm Jensen). 
165 - Make NISP handle multiple devices or addresses.
166 - Make sure that log dir and lock dir are created if they do
167   not exist in "make install".
168 - Add a ./configure option for setting NISIP.
169 - See if 3.10.4 takes longer to link up with the UPS than 3.8.5
170 - Make sure old copies of scripts are saved during install.
171 - Don't delete old apccontrol -- may be modified by user. 
172 - Add CONFIG_USB_HIDDEV=y possible fix to manual.
173 - Make sure apcnisd works (at least for forked version).
174 - Fix CI_VBATT that doesn't seem to work.
175 - Look into shutdown delay (perhaps add MASTERDELAY).
176   Check document.
177 - Consider MASTERKILLPOWERDELAY
178 - Implement install_slave
179 - Add Master shutdown delay.
180 - If in power loss and slave looses connection with
181   master, initiate shutdown -- after a user definable timout.
182 - Document LOGSTATS
183 - Document or remove NETACCESS
184 - --prefix reportedly does not work in ./configure
185 - Add relative links to the bottom of the multimon stats
186   page -> href-"multimon.cgi" or back to the home.
187 - Try to find the right mail program on Solaris (i.e. mailx
188   rather then mail) or document the smtp program.
189 - Possibly use shutdown -i5 on Solaris instead of 
190   shutdown -i0 -- check with Carl
191 - For FreeBSD use shutdown -h according to Neil.
192 - Failure to connect to the UPS should generate an event
193   and perhaps apcupsd should continue running and periodically
194   generate events rather than exiting in error.
195 - Fix hot swapping of USB UPSes with a different UPS model.
196   Need to update static data from USB.
197 - Implement kill power for USB.
198 - Cleanup apcreports and apcstatus code to use Status word.
199   Especially the dumb UPS code.
200 - Become daemon sooner to avoid network hangs.
201 - Avoid opening, closing, then reopening the serial port.
202 - Close all open file descriptors before execing.
203 - add /sbin/halt -i -d -p to shutdown
204   See above for FreeBSD and Solaris.
205 - Don't try to create nologin or powerfail files if doing a killpower.
206 - Make suggested changes to Makefiles (see emails).
207 - Figure out po stuff works.
208 - When running the --killpower, delete the
209   powerfail file if we are not in a powerfail
210   condition.
211 - look at use of snprintf and vsnprintf!
212 - Add SSL
213 - Add "File | Save" to Windows shutdown.
214 - Add optional delay on onbattery to eliminate messages
215   for short outages (or add a new event).
216 - Look into making rpm relocatable or at least the cgi part.
217 - Add calibrate runtime option.
218 - Setuid of network processes to "nobody".
219 - Document porting issues.
220 - enhance manual for master/slave stuff especially
221   the network problems.
222 - Fix power off problems for Dumb UPSes which don't know about 
223   2 minute delay of modern dumb UPSes.
224     Email from Richar Lovison <riovison@simons-rock.edu>
225     Concerning Bacuk-UPS ES series and cables.  One more thing I should
226     let you know.  For some reason the function, doshutdown, is not
227     being called in apccontrol.  That explains why I was getting a
228     shutdown when I saw the "Emergency shutdown" xconsole message since
229     the emergency function has the shutdown command as part of the
230     function.  For now I worked around this by inserting the line:
232     ${SHUTDOWN} -h now "apcupsd remote shutdown"
234     at the end of the failing, timeout, loadlimit and runlimit functions
235     in the apccontrol file.  Maybe this is a problem with version 3.8.1?
236     In any case, I now get a proper shutdown with the batteries fully
237     charged after a designated TIMEOUT. After your vacation, if you wish
238     any further help from me I'd be willing to give it...  my way of
239     giving back I guess.  [:)]
241 Next release focus: improved documentation, simpler installation,
242                     improved security and networking.
244 Key:   - => to be done; + => in beta; * => completed
246 A.1  * Linux USB (implemented in 3.9.4 - kill power doesn't work)
247 A.2  * Configure USB code on/off (implemented in 3.9.5)
248 A.3  - Configure Network Information Server (CGI) code on/off 
249        (smaller footprint)
250 A.4  - Configure master/slave code on/off (smaller footprint)
251 A.5  - Add universal Dumb UPS configurator similar to what
252        exists in powerd, but much more comprehensive. (general cleanup
253        and allows support of ANY Dumb UPS with ANY cable).
254 A.6  * Drivers (USB, Smart, Dumb) (general cleanup of core code).
255        (implemented by Riccardo). (implemented in 3.9.5)
256 A.7  * Configure drivers code on/off (smaller footprint) (implemented
257        in 3.9.5).
258 A.8  * Add port to hosts.conf (implemented in 3.8.3).
259 A.9  * Log errors in apccontrol.
260 A.10 * Persistent slave connections. Currently connection
261        is made and broken each communication. (implemented
262        in 3.9.4). 
263 A.11 - CRAM-MD5 authentication for master/slave (security - requires A.10).
264 A.12 + Ensure that ANNOY and ANNOYDELAY work (correctly documented).
265        Need possible coding changed to separate ANNOY and NOLOGON.
266 A.13 * Reduced STATUS output by eliminating lines with N/A
267        (implemented in 3.8.3).
268 A.14 * Detect, log, and generate event when master/slave not 
269        responding (improved error detection) (implemented in
270        3.9.6)
271 A.15 - Eliminate of unnecessary/confusing configuration directives
272        (this requires a good deal of thought and implmentation of
273        A.6).
274 A.16 * Additional documentation including pdf version of document.
275 A.17 - Merge of specific 4.0 code/features (e.g. new Makefiles, 
276        eeprom programming, ...)
278 Possibilities:
279 B.1 + New master/slave protocol using same network code as CGI
280        (future releases would be be upward compatible -- needs A.6)
281 B.2 - Built-in mini-Web server (Carl's suggestion) with SSL.
282 B.3 - GUI via mini-Web server or CGI code.
283 B.4 * Support of multiple-UPSes (implemented in 3.8.3).
284 B.5 - General cleanup of configuration file reading code
285       possibly with new configuration file syntax. (this
286       is only needed if B.4 is implemented).
287 B.6 - Move EEPROM programming code to a separate program
288       and add additional features.
290 User Requests:
291 C.1 * More documentation, including pdf format; better
292       organization of documentation (work here progressing
293       but it is a continuing effort).
294 C.2 - Develop a formalized release test plan.
295 C.3 * Implement an effective bug tracking system.
296 C.4 + Identification of people responsible for various 
297       functions (platform maintenance, testing, web
298       site maintenance, documentation, ...) (Job descriptions
299       written -- several people formally identified).
300 C.5 * Reorganize code for efficiency and for easier
301       maintenance (part of A.6 and A.17).
303 Design:
304 UPSTYPE = Smart/Dumb/USB/Slave 
306 CABLE = DUMB
308 GETPORT <condition> <signal-spec>
310 SETPORT <event> <action-spec>
312 Where:
314 <condition> = POWERFAIL | LOWBATT | LINEDOWN   (ONBATT)
315 <event>     = INITUPS | POWERFAIL | SHUTDOWN   (EXIT)   
316 action-spec = <signal-spec> | <sleep-spec> ...
317 signal-spec = <signal> <state> ...
318 signal      = CTS | DSR | RNG | ST | CSR | RTS
319 state       = SET | CLEAR
320 sleep-spec  = SLEEP N
322 <html>
323 <body>
324 <pre>
327 To do:
328 ========
329 Hello,
331 Yes, what you did is exactly what it takes to get
332 apcupsd to work with cygwin installed.  There are
333 four major pitfalls:
335 1. The normal cygwin installation uses mount points
336    and installs everything in a subdirectory of cygwin.
337    This was not appropriate for apcupsd, and is not how
338    I run my system -- I prefer my files to be visible
339    in the root directory as on Unix.  If you use the
340    standard apcupsd install, it removes all cygwin mount
341    points. From what you wrote, you avoided this problem.
343 2. If you install on a cygwin system, you must ensure that
344    /apcupsd/bin gets you to the apcupsd directory, so if you
345    are using the standard cygwin suggestions, you must ensure
346    that you place apcupsd into the cygwin directory as you did.
348 3. Finally, you must either delete the cygwin1.dll from the
349    apcupsd bin directory or insure that you are always running
350    the same cygwin distribution as apcupsd (currently 1.3.10)
351    since two different cygwin1.dll programs will not co-exist.
353 4. If you do upgrade your cygwin system, be aware that my experience
354    is that only about one out of every 3 of their releases is
355    stable enough to run apcupsd. So upgrade with caution, and
356    you may need to build apcupsd depending on what changes
357    they made.
359 Thanks for pointing out that you got this cygwin configuration
360 to work. I'll try to get these notes + yours into the 
361 next manual for the next time someone wants to try 
362 running apcupsd with cygwin.  As Neil pointed out, it is
363 not evident that it will work, and though these notes should
364 be helpful, we probably won't officially support running apcupsd
365 AND cygwin unless you wish to be constrained to running on
366 the same version as we are (not always evident).
368 Best regards,
370 Kern
373 On Mon, 2002-07-01 at 18:29, James Garrison wrote:
374 > I didn't find details on installing apcupsd with an existing
375 > cygwin installation, but after looking over the install
376 > script I "guessed" that all I had to do was put the
377 > apcupsd directory under my cygwin root and run
379 >       apcupsd /install
381 > from the there.  Everything appears to be working correctly,
382 > including running apcupsd slaved to a Linux master.  Did I miss
383 > something or is it really that simple? Did I miss where this
384 > is documented?  If not, it definitely needs to be added to the doc.
386 > Thanks for a great program.  This is what APC *should* be
387 > providing to its users, not the crappy stuff they currently have.
389 ======
392 Wish list:
393 - Look at using libgd-1.3 in place of gd for cgi.
394   Perhaps a lib directory could be added to the build tree and a
395   "-with-included-gd" configure switch could control the inclusion of the
396   local libgd.  
397 - Fix confusion with UPSTYPE, ... 
398 - Add more commands (individual variables) to apcnetd
399 - Make apcaccess use the network code as an option.
400 - Eliminate rest of character command codes using new
401   capabilities code in apcsetup.c (for setup stuff).
402 - Eliminate the rest of the printfs().
403 - Eliminate as many error_aborts as possible in making
404   new events.
405 - STATUS file should be opened with open() rather
406   than fopen(). Some small changes required. 
407 - Expand Last UPS Self Test field in cgi program
408 - Send events across network to slaves rather than 
409   status values.
410 - Send configuration (ups type, ...) across network to
411   slaves and ignore slave UPS configuration info.
412 - Create globals file and move more variables out
413   of shared memory buffer.  Maybe even eliminate
414   shared memory.
415 - Implement a new option or mode in apcupsd where when there
416   is a power failure, apcupsd issues the system shutdown as
417   usual, but it continues running. After a user defined time
418   limit after the shutdown, apcupsd will tell the UPS to
419   shut off the power.
420   From: Zsolt Domokos [DomokosZ@esi.com]
421              
423 Fixed but needs testing:
424 - Add Chris' schematic of the 940-0095A cable.
425 - add 127 and 128A cables to 3.9.8!   
429 Done:
430 - When USB is offline status indicates SLAVE
431 - Need to insure that the reports are done if they
432   are requested more frequently than the poll period.
433 - Fix powerflute build problem.
434 - Win32 Threads
435 - Fix libwrap
436 - Change the default SERVERPORT and NETPORT 
437 - Add configuration for ports
438 - Add configuration for logfile
439 - Fix passing stack pointer to thread in apcnis.c !!!!!
440 - Master did not shutdown in TIMEOUT.
441 - Set appropriate permissions on files in /etc/apcupsd during
442   make install.
443 - Finish the rpm spec file.
444 - Accumulate time on batteries and number of transfers
445   to batteries. Perhaps save history in file so that the
446   info can be recovered if apcupsd restarts.
447 - Remember date and time when apcupsd started.
448 - Allow IP addresses for masters and slaves.
449 - Add remaining time before TIMEOUT to STATUS output.
450 - Fix 4/8 byte problem reported by Tom Holroyd
451 - Fix zombies on BSD. Each exec() increments a counter.
452 - Fix the problem with DoS with the email files
453   where the file can be linked to a system file.
454 - fix ChangeBatt problem in apcnet (line 389).
455       > 1) Start master and slave apcupsd daemons
456       > 2) Terminate the apcupsd daemon on the master
457       > 3) Wait a little time
458       > 4) Start the master apcupsd daemon
459       > 5) Slave reports that UPS batteries have failed
460       > 6) A zombie shell process appears on slave
461   why is bad data being sent.
462   Do nonblocking wait in main loop and decrement counter.
463 - Use links and .bat files instead of .pifs on Win32
464 - Add a KILLDELAY mode where after shutdown, apcupsd continues
465   running, and then after a specified time issues
466   the kill_power to the UPS.    
467 - Detect self tests
468 - SEGFAULT in kill_power()
469 - Buffer overflow in capabilities
470 - If UPS capabilities, only test those defined
471 - Fast Poll when on batteries.
472 - Improved Win32 shutdown -- guarantees shutdown, previous
473   version could hang if dialogue not answered. Can now
474   specify shutdown delay.
475 - Some files have large diff files because they
476   have been reformatted to apcupsd 4.0 standards.
477 - I am in the process of integrating version 4.0
478   code into this stream, so many of the changes are
479   related to this activity.
480 - Modified code for handling 940-0095B cable. Hopefully,
481   it will work now.
482 - Added the Caldera code that was submitted by John Pinner.
483 - Integrated NetBSD patches that I received from Devin Reade -- thanks.
484 - To correct a problem with zombies on BSD systems, I added
485   a UPSINFO variable that is the count of children created
486   by execute_command(). do_action() in apcaction.c was
487   modified to check this variable, do a non-blocking wait,
488   and decrement it if any children were found.  This should
489   properly reap the zombies.
490 - Added additional debug information (strerror) to failed
491   semaphore and shared memory system call errors in apcipc.c
492 - In apcnet.c, removed ChangeBatt from slave because it is
493   apparently being set incorrectly on some BSD masters when
494   apcupsd is restarted.
495 - Added an O_NDELAY to the serial port open() in apcserial.c
496   to avoid infinite waits on some BSD systems. This required
497   the addition of an fcntl() after the open to reset the
498   blocking read(), which is needed in apcupsd.
499 - Removed an unwanted break in a switch in apcstatus.c that
500   caused the status output for BackUPS Pros to be cut short.
501 - Added a HAVE_POWERFLUTE define and changed powerflute.c to
502   use it. This prevents a lot of the errors seen on systems
503   that don't have ncurses.
504 - configure.in, added HAVE_NETBSD_OS, HAVE_POWERFLUTE, and
505   modified generation of makefiles to only configure the files
506   in the recognized distribution.  Modified the automatic 
507   make of the dependencies to use "make depend"
508 - Removed the call on the shell to execute a script file in
509   apccontrol. This permits execution of any type of file, but
510   it now requires that the file be executable.
511 - Reindent apclock.c apcstatus.c apclog.c apcevents.c
512 - Add TCP Wrappers -- fix problems pointed out by Neil,
513   and implement code.
514 - Fix gethostbyname on Win32 (apparently this works).
515 - Fix apcaction.c to be a state machine,
516   and to generate events.
517 - Make all events into event subroutines that can be
518   called from anywhere -- including network code.
519   Thus do_action() will be a very small loop detecting
520   and sending events.
523 We have several electrical circuits in our computer room. So we have one master running on each circuit and the rest on a circuit are slaves. This way, we don't get messages from all PCs, just one per circuit. We can monitor each circuit individually now. Not only does APC's PowerChute Linux version not run on most of our machines (needs X) but you just can't customize it that way I have learned with apcupsd. Plus, powerchute likes to go out and find everything and I don't want that. Many of our machines are just servers and don't have X. They don't need it. 
524 Yes, fixing apcupsd so that it doesn't send out power loss messages
525 during the automatic self test is definitely on my list of things
526 to do, and I will make sure it is in the next release. Your vote
527 does count as much as everyone else's. In fact, you just gave me
528 an idea - it might be good to have an optional configuration directive
529 that delays the onbattery event for a given number of seconds, and
530 if the condition is cleared, the event would be dropped. This could
531 eliminate a lot of noise for small problems that are easily handled
532 by apcupsd.
534 This sounds perfect. I'm sure many people could use this feature.
535 Thanks,
537 Charles
538 - Use links and .bat files instead of .pifs on Win32
539 - Pass second argument to apccontrol indicating if
540   we are master/slave and other info.
541 - Add multiple arguments to apccontrol
544 ========================================
545 From: Alan W. Irwin <irwin@beluga.phys.uvic.ca>
546 To: apcupsd-devel@apcupsd.org
547 Subject: [Apcupsd-devel] Comparison of the official Debian unstable package for apcupsd-3.8.5 with my own
548 Date: 15 Feb 2002 12:30:05 -0800
549 I compared the official version with my unofficial patch to do the same thing,
550 and except for two files in my patch, I think the official patch is the same
551 or better.
553 The official patch completely ignores
554 apcupsd-3.8.5/distributions/debian/packageinfo and instead creates its own
555 apcupsd-3.8.5/debian directory.  The apcupsd team might consider adopting
556 the official debian patch (which has no impact outside the debian directory)
557 and dropping the packaginfo directory (which is misnamed, and which contains
558 white-space munged versions of a subset of the files in the official debian
559 directory).  I would recommend the official patch over my own because they
560 included some additional minor fixups to the files in the debian directory.
562 The only exceptions where I did a better job are the files named
563 packageinfo/undocumented and packageinfo/examples in my patch which should
564 replace debian/undocumented and debian/examples in the official Debian
565 patch. The file named "undocumented" documents executables which should have
566 a man page, but don't, and "examples" is a list of example files to install.
567 "examples" is seriously incomplete for the official debian patch.  For
568 example, it does not include safe.apccontrol so that file is not part of the
569 official Debian package, but it is part of mine.
571 To summarize, I just installed the official version for Debian unstable
572 apcupsd-3.8.5 and aside from some example and man page files which are
573 missing it works as well as can be expected for a BackUPS with 940-0023A cable
574 connected to the Master which in turn is connected to a slave (also on
575 UPS) via the LAN.  My patch should be put in the dustbin except for the
576 files named "undocumented" and "examples".
578 One thing I noticed relevant to documentation fixups is their example
579 apcupsd.conf specifically replaced the configuration parameter SERVERPORT
580 with NISPORT.  Assuming the Debian packager knows what he is doing, this means
581 such a transition has occurred in 3.8.5, but I cannot find it in the
582 documentation.  Also, if SERVERPORT is going to be replaced by NISPORT, I
583 suggest you also do the replacement in examples/apcupsd.slave.conf and
584 examples/apcupsd.master.conf for consistency.
586 Alan
588 email: irwin@beluga.phys.uvic.ca
589 phone: 250-727-2902     FAX: 250-721-7715
590 snail-mail:
591 Dr. Alan W. Irwin
592 Department of Physics and Astronomy,
593 University of Victoria, P.O. Box 3055,
594 Victoria, British Columbia, Canada, V8W 3P6
595 __________________________
597 Linux-powered astrophysics
598 __________________________
602                                       From: Alan W. Irwin <irwin@beluga.phys.uvic.ca>
603                                       Cc: Apcupsd-devel <apcupsd-devel@apcupsd.org>
604                                       Subject: Re: [Apcupsd-devel] Debian woody apcupsd-3.8.5 working so far in safe mode (was Cannot get Debian woody apcupsd-3.8.1.5 to actually shutdown the computer even though dumb UPS signalling seems to be w
605                                       Date: 14 Feb 2002 20:13:44 -0800
606                                       On 14 Feb 2002, Kern Sibbald wrote:
609 > 1). Yes, NETACCESS is not documented -- an oversight, but
610 >     it is in fact not used and we hope to remove it.
611 >     I've put it on my todo list -- thanks.
613 Note that examples/apcupsd.master.conf and examples/apcupsd.slave.conf have
614 this parameter (and perhaps other example configuration files as well?) so
615 it should be removed from these example files when you remove NETACCESS
616 altogether.
619 > 2.  I found this a bit surprising. So I looked into the
620 >     problem a bit more and found that there is a bit of
621 >     confusion -- perhaps in our manual as well. Basically,
622 >     it appears that the shutdown on both machines is done
623 >     immediately. What is delayed 30 seconds on the master
624 >     is the kill power request to the UPS.
625 >     In looking at the kill power code for 3.8.5, the master,
626 >     regardless of whether it is a Dumb or Smart UPS, waits
627 >     30 seconds before setting the kill power bit, then
628 >     after setting it, it waits an additional 10 seconds to
629 >     hold the bit on.  Clearly at least the documentation
630 >     could be improved on this. It is now on my todo list.
632 >     Modifying apccontrol is the best way to correct the situation.
633 >     You are right -- it does get overwritten on the next installation.
634 >     I'll put this on my todo list to see if we can find a solution.
636 Thanks.  While I am asking, I suppose I should ask for the Moon....;-)
637 Ideally, what I would like to see is a configurable wait (although 30
638 seconds is not bad) after the remote shutdown command is sent to the slaves
639 before the master starts its shutdown.  This is important when the slaves
640 (such as mine) depend on the Master to export their NFS mounted files
641 systems, for example.
645 > 3.  This is a general problem with installation. Basically the
646 >     installation is designed for a stand alone situation, so when
647 >     you installed the slave, it installed the instructions in your
648 >     halt script necessary to recall apcupsd at the end of the shutdown
649 >     to kill the power. This can be fixed either as you did or by
650 >     deleting the changes to the halt script. We've made improvements
651 >     in the installation process for 3.8.5, but it probably merits more
652 >     attention.
654 Thanks.
657 > Feature request:
658 > Unfortunately, it is impossible to implement what you ask for the
659 > 023A cable due to the physical limitations of the cable
660 > wiring. Here is a section from our manual on the subject:
662 >       This cable can only be used on simple signaling UPSes,
663 >       and apparently only provides the On Battery signal. As
664 >       a consequence, this cable is pretty much useless, and
665 >       we recommend that you find a better cable because all
666 >       APC UPSes support more than just On Battery.
669 Thanks for pointing me to that reference.  I will probably just grit my
670 teeth and live with the 23A limitations.
673 > If you have any Debian patches or changes for our 3.8.5 code that would
674 help us, please send them to us.
676 See attached.
678 Here are the instructions for building the debian woody package,
679 apcupsd_3.8.5-1_i386.deb.
681 Apply this patch to a clean 3.8.5 tree, then cd into the patched tree
683 cd apcupsd-3.8.5
685 and either
687 ln -s distributions/debian/packageinfo debian
689 mv distributions/debian/packageinfo debian
691 mv distributions/debian/packageinfo distributions/debian/debian
693 (I only tried the first of these, but I think the others would work as well.
694 I also could have put some variation of this as part of the patch, but that
695 makes for a larger patch, and I will leave it to the apcupsd team to decide
696 the best way to rename packageinfo to debian. The point is that the current
697 packageinfo/rules file *must* be accessible as debian/rules in order for the
698 debian build software to work.) Then build the package (stay in directory
699 apcupsd-3.8.5 to invoke this command, but look for the generated deb file in
700 directory above)
702 debuild -us -uc
704 As a first step, this command scans through the tree to find the debian/rules file
705 so that is why you must symlink or rename packageinfo above.
707 debuild worked without errors for me, (and also the installed package works
708 well on my two Debian Master and Slave systems). To install the package simply
709 cd .. ; dpkg --install apcupsd_3.8.5-1_i386.deb, and follow normal procedure
710 for configuring and testing apcupsd.
712 Despite my success in building and installing apcupsd_3.8.5-1_i386.deb, I
713 cannot guarantee any success for others since their situation may be
714 different.  However, I believe it is at least a good start to packaging
715 3.8.5 for Debian because I have taken the approach of making minimalist
716 changes to 3.8.5 guided by the current official Debian packaging. I have
717 added needed files to the debian (a.k.a. packageinfo) tree (and also removed
718 one unneeded one) and tweaked the contents of a few files (such as the
719 undocumented man pages and the examples).  However, the most important
720 change is white-space issues in the debian/rules file.  Whitespace issues
721 are important there since that is a makefile. Somehow the whitespace in
722 rules got badly munged for 3.8.5. Without my patch (which reverts to the
723 official Debian rules file with correct whitespace), that file is unusuable.
725 I will also be submitting my patch to Debian as part of a bug report.
727 Alan
729 email: irwin@beluga.phys.uvic.ca
730 phone: 250-727-2902     FAX: 250-721-7715
731 snail-mail:
732 Dr. Alan W. Irwin
733 Department of Physics and Astronomy,
734 University of Victoria, P.O. Box 3055,
735 Victoria, British Columbia, Canada, V8W 3P6
736 __________________________
738 Linux-powered astrophysics
739 __________________________
742 gzip-compressed file attachment (patch.debian.gz), "Patch file which allows Debian packaging of 3.8.5"
743      
744 Documentation:
746 Munagala Ramanath <Munagala.Ramanath@PostX.com>
748 I would add documentation improvements as A16 if you
749 have the bandwidth to do it. Specifically:
751 1. A separate section discussing master/slave setup,
752    discussing for example the order in which the master
753    and slaves should be activated, how often they
754    communicate, who initiates the communication, what
755    happens if the master goes down or some (or even _all_
756    the slaves go down), etc.
758 2. (done)
759    In the "Configure Options" section, add a note that
760    many of these configuration options are equivalent
761    to changing the corresponding option in the apcupsd.conf
762    file. Similarly, add a note in the "Configuration Directives"
763    section that some of these directives are set based on
764    --with options given to the configure script.
766 3. (done)
767    In the Solaris section, ask users to verify that they have
768    either /usr/sbin (or /etc since /etc/shutdown is just a
769    symbolic link to /usr/sbin/shutdown) before /usr/ucb in
770    their path to avoid using the wrong shutdown program.
772 4. (done)
773    In the Solaris section (this may be worth adding to the
774    other systems as well) that discusses modifying /sbin/rc0
775    add a note saying that if you want to manually reboot
776    the machines you can skip this step (I prefer to manually
777    reboot my machines after a powerfail because it is not
778    unusual for power to fail and return a couple of times
779    in rapid succession and I don't want to worry about the
780    unpredictability of power shutting off during a reboot)
782 5. (done)
783    Add a note in the "Solaris EEPROM Changes" section that
784    recent versions of Solaris (7 & 8) appear to have removed
785    this eeprom option and there seems to be no way to suppress
786    the serial port probing during boot.
788 6. Add a section specifically devoted to setup and testing
789    for dumb UPSes. I first tried cables 940-0024C and 940-1524C
790    with a BackUPS 500 but was unable to make it work (when I
791    pulled the power cord, the event was not detected by the
792    demon). I couldn't tell if I was using the wrong cable or
793    if something else was wrong. So I went out and bought a
794    SmartUPS and this seems to work OK.
796 7. In the "Configuration Directives" section, it would be useful
797    if for each parameter, the following is specified:
798    -- what the values should be for master and slave (e.g. UPSCABLE
799       should be "ether" for the slaves -- this is stated in the
800       description of MASTER; it would be helpful to put it in the
801       description of UPSCABLE).
802    -- whether it is required or optional.
803    -- what exactly "default value" means (e.g. the DEVICE option
804       says the default is /dev/ttyS[0|1|2|3|4]; it is not clear
805       how multiple values can be a "default" and also whether
806       I can simply comment out this option to get the default or
807       whether it just means the configure script will choose a default
808       but this option is required.
810 8. (done)
811    In the discussion of TIMEOUT, it says "The timeout for the master
812    is always 30 seconds longer than slaves". It is not clear if this
813    means slave_timeout = master_timeout - 30 or master_timeout =
814    slave_timeout + 30, or something else.
816 From Carl:
817 I'm responding to Kern's recent note, in regard to Solaris issues:
819 >3. In the Solaris section, ask users to verify that they have
820   either /usr/sbin (or /etc since /etc/shutdown is just a
821   symbolic link to /usr/sbin/shutdown) before /usr/ucb in
822   their path to avoid using the wrong shutdown program.
824 Would it make sense to directly call /usr/sbin/shutdown, and
825 ignore the /usr/ucb/shutdown script entirely? I have never
826 heard of anyone moving this script from where it is installed,
827 although that would be possible. In such a case, a note that
828 says: If you moved shutdown for some reason, be aware your
829 must also modify the apc scripts to reflect the new location.
831 Sun has stated a number of times that /usr/sbin/shutdown is
832 the recommended way to gracefully stop the system. Since this
833 file is a shell script, it can be easily modified, but again,
834 almost no one does this.
836 Directly calling the script would eliminate any confusion, but
837 would require extra effort if for some reason the user moved
838 the script somewhere else. Still, it's a simpler, more fool-
839 proof approach.
841 >4. In the Solaris section (this may be worth adding to the
842   other systems as well) that discusses modifying /sbin/rc0
843   add a note saying that if you want to manually reboot
844   the machines you can skip this step (I prefer to manually
845   reboot my machines after a powerfail because it is not
846   unusual for power to fail and return a couple of times
847   in rapid succession and I don't want to worry about the
848   unpredictability of power shutting off during a reboot)
850 Yes, or give the option during the config, and run a script
851 of some kind to do the editing (or not, if the user chooses
852 to skip automated shutdown).
854 >5. Add a note in the "Solaris EEPROM Changes" section that
855   recent versions of Solaris (7 & 8) appear to have removed
856   this eeprom option and there seems to be no way to suppress
857   the serial port probing during boot.
859 I'm not sure this is accurate. Solaris X86 still has this
860 option in Solaris 8 - I am running it as my primary machine
861 at home. Solaris Sparc never needed this option, as it did
862 not probe the serial ports during boot. Only the new Sun
863 'Sunblade' machines seem to need the option, and do not
864 have it. I've spoken to my friends at Sun, and am awaiting
865 a response. As of now, I do not know of a work-around for
866 the SunBlade systems.
868 But my Sun Ultra-80 at work runs fine, and does not have the
869 noprobe option. It just doesn't need it. As far as reports go,
870 only the Sunblade machines seem to have a problem.
872 Perhaps a note should be added that we cannot support the
873 Sunblade models at this time, and why. Sun also just added
874 a new line of rack servers, and they may also be sensitive
875 to this. But I have no reports yet, and do not have one of the
876 new Netra servers to test with.
878 I am going to write to one of our friends at APC, and see if
879 they are aware of the problem. They were recently certified as
880 a 'Solaris-Ready' hardware vendor. Perhaps they are working on
881 a solution with Sun already.
883 But there is still no problem with either X86 or the majority
884 of the Sparc systems out there, so there is also no cause for
885 panic about this.
887 What would be great would be a way to tell the UPS to ignore
888 the handshake probe for a few minutes after powerup. That
889 would get us past the problem, unless the user delayed turning
890 on the system after power returned.
892 Earlier email from Ram:
893 Thanks for your comments:
895 1. Yes, good point, I will create a second safe.apccontrol script
896    for systems requiring printf | wall.  On my Linux system, 
897    printf | wall sometimes prints nothing, which is why I changed
898    it for this debug script.
900    Thanks for pointing out the -a option on Solaris. I will add it
901    to the Solaris file (this option does not appear to be available
902    on other systems).
904 2. Hmm. Not too surprising given all the changes. I'll look at it.
905    Thanks.
907 3. Thanks for the suggestion for the doc, I will add them shortly.
908    Here is briefly what I will add.
909    --- No, you can start the master/slaves in any order they will
910        ultimately sync up. The "preferable" order is to bring the
911        slave up first since it waits for the master to contact it.
912        Note, I added a new output to the STATUS command some time
913        ago. It is MASTERUPD which indicates the last time the
914        slave was updated from the master. MASTERUPD appears only
915        in slave configurations.
916    --- Yes there is a default NETTIME. It is 60 seconds. NETPORT
917        has no default, but if you don't modify the standard
918 acpupsd.conf.in
919        file, it will be set. The value is system dependent, but
920        generally 6666 (but it is 6544 on Debian by default, ...).
921        The configured (possibly by default) NETPORT will be
922 displayed
923        in the output of your ./configure
924    --- When running as a netslave, the DEVICE is ignored. The
925 UPSCABLE
926        should be set to "ether" (without quotes), and the UPSTYPE
927 should
928        be set to the same type as the master.  In a future version,
930        hope to fix this so that ALL information is pulled from the
931        master. There is a new section of the 3.8.2 manual (rather
932 crude
933        at the moment) called "Configuration Examples" which is
934 intended
935        to help in this regard.
937 Thanks for your comments.
939 Best regards,
941 Kern
943 Munagala Ramanath wrote:
945 > Hi,
947 > A couple of minor points w.r.t. the Solaris version:
949 > 1. The safe.apccontrol script uses "wall <string>" but this usage is not
950 >     valid on Solaris; wall gets its input from a file or stdin. The
951 > apccontrol script
952 >     uses "printf <string> | wall" which works. Also, it may be better to use
953 >     "wall -a" because this will write to _all_ terminal windows rather than
954 > just
955 >     console windows (if the user does not have a console window, he doesn't
956 >     see the message).
957 > 2. The installed apcupsd script has an unused variable "sbindir=@sysbindir@"
959 > For the master/slave mode, it will be useful to add answers to the following
960 > questions:
962 > -- Does it matter if the master demon is started first or the slaves first ?
963 > -- Is there a default value for NETTIME and NETPORT or is it necessary
964 >    to specify these explicitly in the conf file ?
965 > -- If UPSCLASS is set to netslave, does it matter what UPSCABLE,
966 >    UPSTYPE and DEVICE are set to ?
968 > Thanks for an excellent package!
970 Items done:
971 - Add 10 second delay in apccontrol before the killpower.
972 - Make pthreads the default.
973 - Check INSTALL path on Solaris.
974 - Save script files on install (mainsback,...) rather than overwriting
975   them.
976 - Document need for 10 second delay to make USB killpower work.
977 - Make sure rpm for 3.10.6 doesn't install the manual
978   in .../man8/man8/...
979 - Check what changes were made to the Mandrake spec file to make non-root
980   rebuilds work.
981 - The USB chapter is out of date as supposedly refers to files
982   that do not exist in the current release.
983 - Switch to using /dev/usb/hiddev[0-9] in place of 
984   /dev/usb/hid/hiddev[0-9] in the next release.     
985 - Modify hid-ups.c to handle both forms.
986 - Extend apcupsd to handle [0-15].
987 - Generate events when slave makes/looses a connection.
988   Already done, I think, but check it.
989 - Fix USB battery voltage scaling problem (factor of 
990   10 to small).
991 - Document the -b option, and for some reason -b and --killpower
992   cannot be used together.
993 - Figure out why make -j doesn't work.
994 - Look into libgd
995 # This is what I was talking about in my last mail.  If the makefile had
996   a variable similar to apaches' "root", all those "install" lines could
997   be replaced by a single "make install root=$RPM_BUILD_ROOT".  This
998   also makes life a LOT easier if someone would like to write another
999   spec-file later.
1000 - Send list of USB programming problems to APC.
1001 - Make make install so that it can work with rpm