作業日記@HatenaBlog

各種の作業メモ

apcupsdの設定メモ

インストール

/usr/ports/sysutils/apcupsdからportsでインストール。
バージョンは3.12.4

makeする


# make && make install
# rehash
# which apcupsd
/usr/local/sbin/apcupsd
#

[ ] CLIENT_ONLY Build apcupsd client only (no network server)
[ ] CGI Compile with CGI programms to show status
[X] USB Compile with USB Support (READ MANUAL!)
[X] SNMP Compile with SNMP Support (READ MANUAL!)


make途中でこんな画面が出てきたが、USBもネットワークカードも付けてないので、USBとSNMPのオプションはオフにした。


[ ] USB Compile with USB Support (READ MANUAL!)
[ ] SNMP Compile with SNMP Support (READ MANUAL!)

設定ファイル編集

以下のディレクトリに設定ファイルがある。
/usr/local/etc/apcupsd/


# cd /usr/local/etc/apcupsd/
# mv apcupsd.conf apcupsd.conf.orig
# cp apcupsd.conf.net-master.sample apcupsd.conf
# vi apcupsd.conf

設定を確認した箇所。


UPSCABLE smart
UPSTYPE smartups
DEVICE /dev/ttyd0 #ttyS0の場合もあり
LOCKFILE /var/spool/lock
ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 5
TIMEOUT 30
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 90
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

/etc/rc.confの編集

以下の通りapcupsdに関係する記述を追加。

# vi /etc/rc.conf
#
# for apcupsd
#
apcupsd_enable="YES"
apcupsd_program="/usr/local/sbin/apcupsd"

apcupsdの操作コマンド。


# /usr/local/etc/rc.d/apcupsd.sh start 起動
# /usr/local/etc/rc.d/apcupsd.sh stop 停止
# /usr/local/etc/rc.d/apcupsd.sh restart 再起動
# /usr/local/etc/rc.d/apcupsd.sh status 状態表示

起動してみる。


# /usr/local/etc/rc.d/apcupsd.sh start
Starting apcupsd.
#

ステータスを確認(1)


# /usr/local/etc/rc.d/apcupsd.sh status
apcupsd is running as pid nnnnn.
#

ステータスを確認(2)


# apcaccess status
APC : 001,051,1211
DATE : Sun Oct 22 00:51:59 JST 2006
HOSTNAME : hoge.fuga.jp
RELEASE : 3.12.4
VERSION : 3.12.4 (19 August 2006) freebsd
UPSNAME : LK-SMART
CABLE : Custom Cable Smart
MODEL : Smart-UPS 500
UPSMODE : Stand Alone
STARTTIME: Sun Oct 22 00:49:40 JST 2006
STATUS : ONLINE
LINEV : 102.9 Volts
LOADPCT : 0.0 Percent Load Capacity
BCHARGE : 100.0 Percent
TIMELEFT : 383.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 30 Seconds
MAXLINEV : 102.9 Volts
MINLINEV : 102.2 Volts
OUTPUTV : 102.9 Volts
SENSE : High
DWAKE : 000 Seconds
DSHUTD : 090 Seconds
DLOWBATT : 02 Minutes
LOTRANS : 092.0 Volts
HITRANS : 108.0 Volts
RETPCT : 000.0 Percent
ITEMP : 27.9 C Internal
ALARMDEL : 5 seconds
BATTV : 27.5 Volts
LINEFREQ : 50.0 Hz
LASTXFER : Automatic or explicit self test
NUMXFERS : 0
TONBATT : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STESTI : 336
STATFLAG : 0x07000008 Status Flag
REG1 : 0x00 Register 1
REG2 : 0x00 Register 2
REG3 : 0x00 Register 3
MANDATE : 09/27/06
SERIALNO : AS0640242245
BATTDATE : 09/27/06
NOMOUTV : 100
NOMBATTV : 24.0
EXTBATTS : 0
FIRMWARE : 650.13.A
APCMODEL : FWA
END APC : Sun Oct 22 00:52:25 JST 2006
#

ステータスを確認(3) EEPROM


# apcaccess eeprom

Valid EPROM values for the Smart-UPS 500

Config Current Permitted
Description Directive Value Values
===================================================================
Upper transfer voltage HITRANSFER 108 108 110 112 114
Lower transfer voltage LOTRANSFER 92 092 090 088 086
Return threshold RETURNCHARGE 0 00 15 30 45 60 75 90
Output voltage on batts OUTPUTVOLTS 100 100
Sensitivity SENSITIVITY H H M L
Low battery warning LOWBATT 2 02 05 08 11 14 17 20 23
Shutdown grace delay SLEEP 90 090 180 270 360 450 540 630 000
Alarm delay BEEPSTATE 0 0 T N
Wakeup delay WAKEUP 0 000 060 120 180 240 300 360 420
Self test interval SELFTEST 336 336 168 ON OFF

#

Smart-UPSのeepromを書き換える

サーバのshutdownが完了する前にUPSがpower failしないように時間調整。
UPS内 eeprom の shutdown grace delay SLEEP を90 →180に変更する。
マニュアル参照のこと。
以下を実行する前にあらかじめapcupsdをstopしておく。


# cd /usr/ports/sysutils/apcupsd/work/apcupsd-3.12.4/src/
# make apctest
# ./apctest
2006-10-22 01:01:29 apctest 3.12.4 (19 August 2006) freebsd
Checking configuration ...
Attached to driver: apcsmart
sharenet.type = DISABLE
cable.type = CUSTOM_SMART

You are using a SMART cable type, so I'm entering SMART test mode
mode.type = SMART
Setting up the port ...
Hello, this is the apcupsd Cable Test program.
This part of apctest is for testing Smart UPSes.
Please select the function you want to perform.

1) Query the UPS for all known values
2) Perform a Battery Runtime Calibration
3) Abort Battery Calibration
4) Monitor Battery Calibration progress
5) Program EEPROM
6) Enter TTY mode communicating with UPS
7) Quit

Select function number: 5

This is the EEPROM programming section of apctest.
Please select the function you want to perform.

1) Print EEPROM values
2) Change Battery date
3) Change UPS name
4) Change sensitivity
5) Change alarm delay
6) Change low battery warning delay
7) Change wakeup delay
8) Change shutdown delay
9) Change low transfer voltage
10) Change high transfer voltage
11) Change battery return threshold percent
12) Change output voltage when on batteries
13) Change the self test interval
14) Set EEPROM with conf file values
15) Quit

Select function number: 8

Enter new shutdown delay: 180

The old UPS shutdown delay is: 090
The new UPS shutdown delay is: 180

1) Print EEPROM values
2) Change Battery date
3) Change UPS name
4) Change sensitivity
5) Change alarm delay
6) Change low battery warning delay
7) Change wakeup delay
8) Change shutdown delay
9) Change low transfer voltage
10) Change high transfer voltage
11) Change battery return threshold percent
12) Change output voltage when on batteries
13) Change the self test interval
14) Set EEPROM with conf file values
15) Quit

Select function number: 15

2006-10-22 01:05:00 End EEPROM programming.

1) Query the UPS for all known values
2) Perform a Battery Runtime Calibration
3) Abort Battery Calibration
4) Monitor Battery Calibration progress
5) Program EEPROM
6) Enter TTY mode communicating with UPS
7) Quit

Select function number: 7

2006-10-22 01:05:05 End apctest.
#

5番のProgram EEPROMを選択し、続いて8番のshutdown delayを選択して180を入力する。

shutdownコマンドの変更

商用電源が切れた時の緊急shutdownはデフォルトだとshutdown -h nowなので、FreeBSDの場合はhaltしてしまう。
shutdown -p nowとして完全にサーバマシンの電源が落ちるように変更する。


# cd /usr/local/etc/apcupsd/
# vi apccontrol
doshutdown)
emergency)
remotedown)
のそれぞれ
${SHUTDOWN} -h now "apcupsd ******* shutdown"

${SHUTDOWN} -p now "apcupsd ******* shutdown"

BIOS設定

サーバのBIOS設定をする。
Power Management Setup → AC Loss Auto Restart [Disabled] → [Enabled]

Wakeup delayの書き換え

上記のapctestコマンドでeepromのWakeup delayを 0 → 180 に変更。

本家サイト

http://www.apcupsd.org/