#contents();
*** UPS の導入 [#l66e18c4]
&ref(apces500.JPG);
- 自宅サーバー、ネットワークの電源障害(主として工事による短時間の停電対策として)小型の UPS を導入した
- UPS でバックアップ出来ないほど停電が続いた場合には、安全にサーバーをシャットダウンさせたい
- サーバー系の UPS で実績のある [[APC:http://www.apc.co.jp/products/ups/index.html]] のPC用の小型UPS [[APC ES 750:http://www.apc.co.jp/products/ups/es500_725.html]] を導入した
*** Linux 用シャットダウンソフト [#o37b2943]
- [[APC UPS deamon (community):http://www.apcupsd.org/]]

 [root@backup apcupsd-3.12.4]# ./configure --prefix=/usr --with-upstype=usb --with-upscable=usb /
                                       --sbindir=/sbin --enable-usb --enable-pthreads  /
                                       --disable-smnp --disable-apcsmart --disable-dumb

  Configuration on Sun Aug 20 14:03:21 JST 2006:
 
  Host:                       i686-pc-linux-gnu -- redhat (Bordeaux)
  Apcupsd version:            3.12.4 (19 August 2006)
  Source code location:       .
  Install binaries:           /sbin
  Install config files:       /etc/apcupsd
  Install man files:          /usr/share/man
  Nologin file in:            /etc
  PID directory:              /var/run
  LOG dir (events, status)    /var/log
  LOCK dir (for serial port)  /var/lock
  Power Fail dir              /etc/apcupsd
  Compiler:                   /usr/bin/g++ 4.1.1
  Compiler flags:             -g -O2 -Wall
  Linker flags:                -g -O
  Host and version:           redhat (Bordeaux)
  Shutdown Program:           /sbin/shutdown
  Port/Device:                /dev/ttyS0
  Network Info Port (CGI):    3551
  Master/slave Port:          6666
  UPSTYPE                     usb
  UPSCABLE                    usb
 
  drivers (no-* are disabled): no-apcsmart no-dumb no-net usb no-snmp no-test
 
  enable-master-slave:        no
  enable-nis:                 yes
  with-nisip:                 0.0.0.0
  enable-cgi:                 no
  with-cgi-bin:               /etc/apcupsd
  with-libwrap:
  enable-nls:                 no
  enable-libintl:             no
  enable-powerflute:          no
  enable-pthreads:            yes
  enable-dist-install:        yes

 [root@backup apcupsd-3.12.4]# make
 [root@backup apcupsd-3.12.4]# make install

 [root@spirit etc]# cat /etc/apcupsd/apcupsd.conf
 ## apcupsd.conf v1.1 ##
 #  for apcupsd release 3.10.18 (21 July 2005) - redhat
 # "apcupsd" POSIX config file
 #
 # ========= General configuration parameters ============
 #
 # UPSNAME xxx
 #   Use this to give your UPS a name in log files and such. This
 #   is particulary useful if you have multiple UPSes.  This does not
 #   set the EEPROM.
 UPSNAME APC-ES500
 #
 # UPSCABLE [ simple    | smart     | ether     | usb |
 #            940-0119A | 940-0127A | 940-0128A | 940-0020B |
 #            940-0020C | 940-0023A | 940-0024B | 940-0024C |
 #            940-1524C | 940-0024G | 940-0095A | 940-0095B |
 #            940-0095C | M-04-02-2000 ]
 #
 # defines the type of cable that you have.
 UPSCABLE usb
 #
 # Old types, still valid, are mapped to the new drivers
 #
 #           keyword       driver used
 # UPSTYPE [ backups        dumb
 #         | sharebasic     dumb
 #         | netups         dumb
 #         | backupspro     apcsmart
 #         | smartvsups     apcsmart
 #         | newbackupspro  apcsmart
 #         | backupspropnp  apcsmart
 #         | smartups       apcsmart
 #         | matrixups      apcsmart
 #         | sharesmart     apcsmart
 #
 # *** New driver names. They can be used directly
 #       rather than using one of the above aliases.
 #
 # UPSTYPE [ dumb | apcsmart | net | usb | snmp | test]
 # defines the type of UPS you have.
 UPSTYPE usb
 #
 #DEVICE <string> /dev/<serial port>
 # name of your UPS device
 #
 # Here a table of the possible devices related with the UPS drivers.
 #
 # Driver   Device                    Description
 # dumb     /dev/tty**                Serial character device
 # apcsmart /dev/tty**                Serial character device
 # usb      <BLANK>                   A blank DEVICE setting enables
 #                                    autodetection, best choice for most
 #                                    installations.
 # net      hostname:port             Network link to a master apcupsd
 #                                    through NIS
 # snmp     hostname:port:vendor:community
 #                                    SNMP Network link to an SNMP-enabled
 #                                    UPS device. Vendor is the MIB used by
 #                                    the UPS device: can be "APC" or "RFC"
 #                                    where APC is the powernet MIB and RFC
 #                                    is the IETF's rfc1628 UPS-MIB.
 #                                    Port is usually 161.
 #DEVICE /dev/usb/hiddev96
 #DEVICE usb
 DEVICE
 #
 #LOCKFILE <path to lockfile>
 # path for serial port lock file
 LOCKFILE /var/lock
 #
 # ======== configuration parameters used during power failures ==========
 #
 # The ONBATTERYDELAY is the time in seconds from when a power failure
 #   is detected until we react to it with an onbattery event.
 #
 #   This means that, apccontrol will be called with the powerout argument
 #   immediately when a power failure is detected.  However, the
 #   onbattery argument is passed to apccontrol only after the
 #   ONBATTERYDELAY time.  If you don't want to be annoyed by short
 #   powerfailures, make sure that apccontrol powerout does nothing
 #   i.e. comment out the wall.
 ONBATTERYDELAY 6
 #
 # Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction, so
 # the first that occurs will cause the initation of a shutdown.
 #
 # If during a power failure, the remaining battery percentage
 # (as reported by the UPS) is below or equal to BATTERYLEVEL,
 # apcupsd will initiate a system shutdown.
 BATTERYLEVEL 5
 #
 #
 # If during a power failure, the remaining runtime in minutes
 # (as calculated internally by the UPS) is below or equal to MINUTES,
 # apcupsd, will initiate a system shutdown.
 MINUTES 3
 #
 #
 # If during a power failure, the UPS has run on batteries for TIMEOUT
 # many seconds or longer, apcupsd will initiate a system shutdown.
 # A value of 0 disables this timer.
 #
 #  Note, if you have a Smart UPS, you will most likely want to disable
 #    this timer by setting it to zero. That way, you UPS will continue
 #    on batteries until either the % charge remaing drops to or below BATTERYLEVEL,
 #    or the remaining battery runtime drops to or below MINUTES.  Of course,
 #    if you are testing, setting this to 60 causes a quick system shutdown
 #    if you pull the power plug.
 #  If you have an older dumb UPS, you will want to set this to less than
 #    the time you know you can run on batteries.
 TIMEOUT 6000
 #
 #
 #  Time in seconds between annoying users to signoff prior to
 #  system shutdown. 0 disables.
 ANNOY 0
 #
 # Initial delay after power failure before warning users to get
 # off the system.
 ANNOYDELAY 180
 #
 # The condition which determines when users are prevented from
 # logging in during a power failure.
 # NOLOGON <string> [ disable | timeout | percent | minutes | always ]
 NOLOGON disable
 #
 # If killdelay is set, apcupsd will continue running after a
 # shutdown has been requested, and after the specified time in
 # seconds attempt to kill the power.  This is for use on systems
 # where apcupsd cannot regain control after a shutdown.
 # KILLDELAY <seconds>  0 disables
 KILLDELAY 0
 #
 #
 # ==== Configuration statements the network information server =========
 #
 # NETSERVER [ on | off ] on enables, off disables the network
 #  information server. If netstatus is on, a network information
 #  server process will be started for serving the STATUS and
 #  EVENT data over the network (used by CGI programs).
 NETSERVER off
 
  ( snip )
 
 #
 # ========== Configuration statements used if sharing =============
 #            a UPS and controlling it via the network
   (snip)
 
 UPSCLASS standalone
 UPSMODE disable
 
 #
 # ===== Configuration statements to control apcupsd system logging ========
 #
 # Time interval in seconds between writing the STATUS file; 0 disables
 
 STATTIME 0
 LOGSTATS off
 DATATIME 0
 
  ( snip ) 
 
 #
 # ========== Configuration statements used in updating the UPS EPROM =========
 #
 # UPS name, max 8 characters  -- used only during -n or --rename-ups
 #UPSNAME UPS_IDEN
 #
 # Battery date - 8 characters -- used only during -u or --update-battery-date
 #BATTDATE mm/dd/yy
 #
 #  The following items are set during -c or --configure
 #
 # Sensitivity to line voltage quality (H cause faster transfer to batteries)
 # SENSITIVITY H M L        (default = H)
 #SENSITIVITY H
 #
 # UPS delay after power return (seconds)
 # WAKEUP 000 060 180 300   (default = 0)
 WAKEUP 60
 #
 # UPS Grace period after request to power off (seconds)
 # SLEEP 020 180 300 600    (default = 20)
 #SLEEP 180
 #
 #
 # Low line voltage causing transfer to batteries
 # The permitted values depend on your model as defined by last letter
 #  of FIRMWARE or APCMODEL. Some representative values are:
 #    D 106 103 100 097
 #    M 177 172 168 182
 #    A 092 090 088 086
 #    I 208 204 200 196     (default = 0 => not valid)
 #LOTRANSFER  208
 #
 # High line voltage causing transfer to batteries
 # The permitted values depend on your model as defined by last letter
 #  of FIRMWARE or APCMODEL. Some representative values are:
 #    D 127 130 133 136
 #    M 229 234 239 224
 #    A 108 110 112 114
 #    I 253 257 261 265     (default = 0 => not valid)
 #HITRANSFER 253
 #
 # Battery change needed to restore power
 # RETURNCHARGE 00 15 50 90 (default = 15)
 #RETURNCHARGE 15
 #
 # Alarm delay
 # 0 = zero delay after pwr fail, T = power fail + 30 sec, L = low battery, N = never
 # BEEPSTATE 0 T L N        (default = 0)
 #BEEPSTATE T
 #
 # Low battery warning delay in minutes
 # LOWBATT 02 05 07 10      (default = 02)
 #LOWBATT 2
 #
 # UPS Output voltage when running on batteries
 # The permitted values depend on your model as defined by last letter
 #  of FIRMWARE or APCMODEL. Some representative values are:
 #    D 115
 #    M 208
 #    A 100
 #    I 230 240 220 225     (default = 0 => not valid)
 #OUTPUTVOLTS 230
 #
 # Self test interval in hours 336=2 weeks, 168=1 week, ON=at power on
 # SELFTEST 336 168 ON OFF  (default = 336)
 #SELFTEST 336
 #
 [root@spirit etc]#

*** モニターソフトの起動 [#i00d5bc2]
 [root@spirit etc]# service apcupsd restart
 Shutting down UPS monitoring:                              [  OK  ]
 Starting UPS monitoring:                                   [  OK  ]

*** backup.hmuna.com の起動に失敗した [#c855b385]

 [root@backup apcupsd-3.12.4]# apcaccess
 FATAL ERROR in apcaccess.c at line 252
 tcp_open: cannot connect to server localhost on port 3551.
 ERR=Connection refused

- 結論としては %%エラーメッセージから推測される LAN 関連ではなく%% USB の HID デバイスが正しく認識されていないのが原因だった
- USB デバイスの認識に問題があれば UPS アクセスが出来ないのは当たり前だが、LAN 関連の設定も必要 (2007-4)
- &color(red){上の /etc/apcupsd/apcupsd.conf の設定では apcaccess は動かないことが判った、以下を変更した (2007-4)};

 # NETSERVER [ on | off ] on enables, off disables the network
 #  information server. If netstatus is on, a network information
 #  server process will be started for serving the STATUS and
 #  EVENT data over the network (used by CGI programs).
 NETSERVER on

- backup.hmuna.com では、USBポートによって認識されない場所があった
ー dmesg で usb ドライバーのロードを確認しておくべきだった(少なくとも最初の接続時には)
-- dmesg には最初から usb connection が見つからないという正しいエラーメッセージが出ていた !
 Aug 26 01:13:22 backup apcupsd[27255]: apcupsd FATAL ERROR in linux-usb.c at line 649 Cannot find UPS device -- For a link to detailed USB trouble shooting information, please see <http://www.apcupsd.com/support.html>.
-- usb が正しく認識されたときには、以下のようなメッセージが残る
 Aug 26 01:26:57 backup kernel: ohci_hcd 0000:00:03.0: wakeup
 Aug 26 01:26:57 backup kernel: usb 1-2: new low speed USB device using ohci_hcd and address 2
 Aug 26 01:26:57 backup kernel: usb 1-2: configuration #1 chosen from 1 choice
 Aug 26 01:26:58 backup kernel: hiddev96: USB HID v1.10 Device [APC APC ES 725 FW:821.y1.A USB FW:y1] on usb-0000:00:03.0-2
- /proc/bus/usb/devices で USB で接続(認識)されたデバイスを確認することができる

 [root@backup apcupsd-3.12.4]# cat /proc/bus/usb/devices
 
 T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=1.5 MxCh= 0
 D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
 P:  Vendor=051d ProdID=0002 Rev= 1.06
 S:  Manufacturer=APC
 S:  Product=APC ES 725 FW:821.y1.A USB FW:y1
 S:  SerialNumber=QB0420132727
 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
 I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
 E:  Ad=81(I) Atr=03(Int.) MxPS=   6 Ivl=10ms
*** UPS ステータスの確認 ( apcaccess )[#i00d5bc2]

 [root@spirit ~]# apcaccess
 APC      : 001,033,0820
 DATE     : Mon May 15 02:18:46 JST 2006
 HOSTNAME : spirit.hmuna.com
 RELEASE  : 3.10.18
 VERSION  : 3.10.18 (21 July 2005) redhat
 UPSNAME  : APC-ES500
 CABLE    : USB Cable
 MODEL    : APC ES 500
 UPSMODE  : Stand Alone
 STARTTIME: Mon May 15 01:50:39 JST 2006
 STATUS   : ONLINE
 LINEV    : 101.0 Volts
 LOADPCT  :  35.0 Percent Load Capacity
 BCHARGE  : 100.0 Percent
 TIMELEFT :  24.0 Minutes
 MBATTCHG : 5 Percent
 MINTIMEL : 3 Minutes
 MAXTIME  : 6000 Seconds
 LOTRANS  : 090.0 Volts
 HITRANS  : 110.0 Volts
 ALARMDEL : Always
 BATTV    : 13.5 Volts
 NUMXFERS : 0
 TONBATT  : 0 seconds
 CUMONBATT: 0 seconds
 XOFFBATT : N/A
 STATFLAG : 0x02000008 Status Flag
 MANDATE  : 2005-08-09
 SERIALNO : AB0533121005
 BATTDATE : 2000-00-00
 NOMBATTV :  12.0
 FIRMWARE : 03.p4.A USB FW:p4
 APCMODEL : APC ES 500
 END APC  : Mon May 15 02:19:44 JST 2006
 [root@spirit ~]#

*** 復電時の動作 [#q43f7922]
- APC ES500 は停電検出してサーバーをシャットダウンさせた後自動停止する (時間は設定可能)
- %%デフォルトの状態では、公衆電源が復帰した時に UPS 電源出力がオンにならなかった%%
- 改めて実験した結果、一次側電源(= UPS 自体の電源) に連動して UPS が再起動した → 問題なし 
- %%APC に確認したところ Power Shute Plus personal edition というバンドルソフトで復電時の挙動を設定できるとのこと%% → これは設定がない

*** アラーム (停電、電池切れ,... ) [#qd4cc5c7]
- &ref(UPS.JPG);

*** バッテリー交換 [#d8c4befc]
- APC ES シリーズは交換用バッテリーをユーザーが自分で交換することがでできる
- バッテリー交換時には、&color(RED){バッテリーの残容量を完全に放電させるために、先にプラス側の配線を外して何回か電源スイッチを ON/OFF する。 }; 
- この時にアラームが鳴ることがある

- APC ES 500 用交換バッテリー ⇒ RBC2J
- APC ES 750 用交換バッテリー ⇒ RBC17J

*** LAN de BOOT (ネットワーク電源監視装置)との連動 [#b185156a]
- APC の UPS はコマンドを使って色々なUPSモニタリング情報を取得することが出来る仕組みを持っている
- LAN de BOOT は3線の信号の組合わせで 電源異常、ローバッテリー、シャットダウン を通知する (いわゆる 接点方式)
- &color(red){結論としては、APC と LAN de BOOT は連係させない(できない)};
-- 停電時のシャットダウンは APC からの制御とする
-- 遠隔リブート時のシャットダウンは LAN de BOOT から制御する
-- LAN de BOOT からのシャットダウン開始は実際にはシャットダウン完了後の時間を設定する

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS