電源管理 APCUPSDインストール

電源管理 APCUPSDインストール

ネット上で検索した文書だとうまく設定出来なかったのでメモ。
LAN経由のコントロールでも NETPORT や MASTER 、 SLAVE などの設定項目は無かった。
バージョンの違い?

  • 1台のUPSで3台のマシンに電源を供給。
  • 3台のマシンのうち1台をマスターとし、残り2台をスレーブとする。
  • UPSへの接続はマスターがUSBでスレーブはEthernet(LAN)とする。

環境:CentOS 5.3 x1台+CentOS4.8 x2台
UPS:APC UPS-1500

apcupsdインストール

yum install apcupsd

※rpmforgeの導入が必要
インストールされたバージョンは
apcupsd release 3.14.3 (20 January 2008) - redhat

2011-01-29更新
UPSCLASS と UPSMODE はオプションのAPC expansion cardを取り付けていて複数のUPSをコントロールする場合に設定するようだ。以前の設定(UPSCLASS sharemaster)同一ネットワーク上に複数のUPSを置いて、USBで接続するとうまくいかない。shareslave にしてもダメ。

マスター設定(/etc/apcupsd/apcupsd.conf)

# 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. It should be 8 characters or less.
 UPSNAME APC_UPS_1500 ←修正(好きな名前に)
# UPSCABLE
#   Defines the type of cable connecting the UPS to your computer.
#
#   Possible generic choices for  are:
#     simple, smart, ether, usb
#
#   Or a specific cable model number may be used:
#     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
#
 UPSCABLE usb ←修正

# To get apcupsd to work, in addition to defining the cable
# above, you must also define a UPSTYPE, which corresponds to
# the type of UPS you have (see the Description for more details).
# You must also specify a DEVICE, sometimes referred to as a port.
# For USB UPSes, please leave the DEVICE directive blank. For
# other UPS types, you must specify an appropriate port or address.
#
# UPSTYPE   DEVICE           Description
# apcsmart  /dev/tty**       Newer serial character device,
#                            appropriate for SmartUPS models using
#                            a serial cable (not USB).
#
# usb                 Most new UPSes are USB. A blank DEVICE
#                            setting enables autodetection, which is
#                            the best choice for most installations.
#
# net       hostname:port    Network link to a master apcupsd
#                            through apcupsd's Network Information
#                            Server. This is used if you don't have
#                            a UPS directly connected to your computer.
#
# 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", "APC_NOTRAP"
#                            or "RFC" where APC is the powernet MIB,
#                            "APC_NOTRAP" is powernet with SNMP trap
#                            catching disabled, and RFC is the IETF's
#                            rfc1628 UPS-MIB. You usually want "APC".
#                            Port is usually 161. Community is usually
#                            "private".
#
# dumb      /dev/tty**       Old serial character device for use
#                            with simple-signaling UPSes.
#
# pcnet    ipaddr:username:passphrase
#                            PowerChute Network Shutdown protocol
#                            which can be used as an alternative to SNMP
#                            with AP9617 family of smart slot cards.
#                            ipaddr is the IP address of the UPS mgmt
#                            card. username and passphrase are the
#                            credentials for which the card has been
#                            configured.
#
 UPSTYPE usb ←修正
 DEVICE ←修正

# NETTIME
#   Interval (in seconds) at which the NIS client polls the server.
#   Used only when this apcupsd is a network client (UPSTYPE net).
 NETTIME 60 ←コメント削除

#
# ========== Configuration statements used if sharing =============
#            a UPS with more than one machine

#
# Remaining items are for ShareUPS (APC expansion card) ONLY
#

# UPSCLASS [ standalone | shareslave | sharemaster ]
#   Normally standalone unless you share an UPS using an APC ShareUPS
#   card.
 UPSCLASS sharemaster ←修正
 UPSCLASS standalone ←修正

# UPSMODE [ disable | share ]
#   Normally disable unless you share an UPS using an APC ShareUPS card.
 UPSMODE share←修正
 UPSMODE disable ←修正

起動:
/etc/rc.d/init.d/apcupsd start

ステータス確認:
/sbin/apcaccess status

自動起動設定:
chkconfig apcupsd on

スレーブ側:

# UPSCABLE
#   Defines the type of cable connecting the UPS to your computer.
#
#   Possible generic choices for  are:
#     simple, smart, ether, usb
#
#   Or a specific cable model number may be used:
#     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
#
 UPSCABLE ether ←修正
# To get apcupsd to work, in addition to defining the cable
# above, you must also define a UPSTYPE, which corresponds to
# the type of UPS you have (see the Description for more details).
# You must also specify a DEVICE, sometimes referred to as a port.
# For USB UPSes, please leave the DEVICE directive blank. For
# other UPS types, you must specify an appropriate port or address.
#
# UPSTYPE   DEVICE           Description
# apcsmart  /dev/tty**       Newer serial character device,
#                            appropriate for SmartUPS models using
#                            a serial cable (not USB).
#
# usb                 Most new UPSes are USB. A blank DEVICE
#                            setting enables autodetection, which is
#                            the best choice for most installations.
#
# net       hostname:port    Network link to a master apcupsd
#                            through apcupsd's Network Information
#                            Server. This is used if you don't have
#                            a UPS directly connected to your computer.
#
# 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", "APC_NOTRAP"
#                            or "RFC" where APC is the powernet MIB,
#                            "APC_NOTRAP" is powernet with SNMP trap
#                            catching disabled, and RFC is the IETF's
#                            rfc1628 UPS-MIB. You usually want "APC".
#                            Port is usually 161. Community is usually
#                            "private".
#
# dumb      /dev/tty**       Old serial character device for use
#                            with simple-signaling UPSes.
#
# pcnet    ipaddr:username:passphrase
#                            PowerChute Network Shutdown protocol
#                            which can be used as an alternative to SNMP
#                            with AP9617 family of smart slot cards.
#                            ipaddr is the IP address of the UPS mgmt
#                            card. username and passphrase are the
#                            credentials for which the card has been
#                            configured.
#
 UPSTYPE net ←修正
 DEVICE 192.168.1.xxx ←マスターのIPアドレス

# NETTIME
#   Interval (in seconds) at which the NIS client polls the server.
#   Used only when this apcupsd is a network client (UPSTYPE net).
 NETTIME 60 ←コメント削除

#
# Remaining items are for ShareUPS (APC expansion card) ONLY
#

#
# ========== Configuration statements used if sharing =============
#            a UPS with more than one machine

#
# Remaining items are for ShareUPS (APC expansion card) ONLY
#

# UPSCLASS [ standalone | shareslave | sharemaster ]
#   Normally standalone unless you share an UPS using an APC ShareUPS
#   card.
 UPSCLASS shareslave ←修正
 UPSCLASS standalone ←修正

# UPSMODE [ disable | share ]
#   Normally disable unless you share an UPS using an APC ShareUPS card.
 UPSMODE share ←修正
 UPSMODE disable ←修正

起動:
/etc/rc.d/init.d/apcupsd start

ステータス確認:
/sbin/apcaccess status

ステータスが表示されればOK?

動作確認

apcupsdはいずれかの条件が一つでも当てはまればシャットダウンを実行する。

  1. BATTERYLEVEL … バッテリー残が設定したパーセント以下になったら
  2. MINUTES … バッテリー残が設定した分以下になったら
  3. TIMEOUT … 商用電源からの供給が切れた時からの経過秒を過ぎたら

マスターの設定を TIMEOUT 600(秒)に設定し、動作確認を行う。

マスターの設定はTIMEOUT のみ変更して、他はデフォルトのまま。

結果は5分超後、全てのサーバがシャットダウンされた。

2010-11-12追記

/etc/apcupsd/hosts.conf を編集して、http://管理サーバのIPアドレス/cgiのディレクトリ/multimon.cgi でweb上からそれぞれの状態を監視できる。

vi /etc/apcupsd/hosts.conf
# Network UPS Tools - hosts.conf
#
# This file does double duty - it lists the systems that multimon will
# monitor, and also specifies the systems that upsstats is allowed to
# watch.  It keeps people from feeding random addresses to upsstats,
# among other things.  upsimage also uses this file to know who it
# may speak to. upsfstats too.
#
# Usage: list systems running upsd that you want to monitor
#
# MONITOR
"" # # Please note, MONITOR must start in column 1 (no spaces permitted) # # Example: # MONITOR 10.64.1.1 "Finance department" # MONITOR 10.78.1.1 "Sierra High School data room #1" # MONITOR 127.0.0.1 "Local Host" MONITOR 192.168.1.2 "Web server" MONITOR 192.168.1.3 "DB server"

参考:Apcupsd Network Monitoring – Hamabo's Web

インストールにはこちらの記事もよさそう
停電対策としてApcupsd 3.14.8をインストールした時のメモ。 Vine Linux 5.0 Apcupsd 3.14.8 APC

さらに追記

ITmedia エンタープライズ:How-To:特別企画:UPSを利用した電源対策
を見てたら、マスターとスレーブの設定が違う気がしてきた。実際に動作したのだからいいかと思うけど、、、。

# UPSCLASS [ standalone | shareslave | sharemaster ]
# Normally standalone unless you share an UPS using an APC ShareUPS
# card.
UPSCLASS sharemaster ←修正

# UPSMODE [ disable | share ]
# Normally disable unless you share an UPS using an APC ShareUPS card.
UPSMODE share ←修正

この辺は違う気がする。

Lipwood - Apcupsd 3.14.1~3.14.3のapcupsd.confの日本語訳
を読むと合ってる気もする。UPSが複数ある時の設定なのかなぁ?