在 Linux 設定監控一台不斷電設備 APC

APC 官網並不提供 Linux 的軟體,所以找了一個 ↓↓

apcupsd http://www.apcupsd.org/
A daemon for controlling APC UPSes

下載它然後安裝

tar zxvf apcupsd-3.14.14.tar.gz
cd apcupsd-3.14.14
make clean
./configure --enable-usb
make
make install

接著,先確認 USB 資訊有抓到 APC 設備

cat /proc/bus/usb/devices

T: Bus=02 Lev=02 Prnt=02 Port=03 Cnt=01 Dev#= 4 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=051d ProdID=0002 Rev= 0.90
S: Manufacturer=American Power Conversion
S: Product=Back-UPS RS 700G FW:856.L3 .D USB FW:L3 
S: SerialNumber=3B-----1 
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 2mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=100ms

安裝完 apcupsd 後,它的設定檔,官網有提到的基本的設定 (照預設即可,我這邊是用 USB 連接)

more /etc/apcupsd/apcupsd.conf

# Simple USB Configuration
# If you have a USB UPS, the essential elements of your apcupsd.conf file should look like the following:
## apcupsd.conf v1.1 ##
UPSCABLE usb
UPSTYPE usb
DEVICE
LOCKFILE /var/lock
UPSCLASS standalone
UPSMODE disable
EVENTSFILE /var/log/apcupsd.events # 事件記錄

啟動 apcupsd

service apcupsd start

驗證 apcupsd

執行

apcaccess

就可以看到現在 APC 的資訊

APC : 001,036,0854
DATE : 2019-06-11 07:23:44 +0800 
HOSTNAME : ssorc.tw
VERSION : 3.14.14 (31 May 2016) redhat
UPSNAME : APC
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2019-06-11 07:02:32 +0800 
MODEL : Back-UPS RS 700G 
STATUS : ONLINE 
LINEV : 116.0 Volts
LOADPCT : 1.0 Percent # 現在負載多少
BCHARGE : 59.0 Percent # 電池可用容量
TIMELEFT : 57.0 Minutes # 電池可持續多久時間
MBATTCHG : 5 Percent # 同設定檔的 BATTERYLEVEL ,剩 5% 時就正常關機
MINTIMEL : 3 Minutes # 同設定檔的 MINUTE ,剩 3 分鐘時就正常關機
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 88.0 Volts
HITRANS : 141.0 Volts
ALARMDEL : 30 Seconds
BATTV : 13.7 Volts
LASTXFER : Low line voltage
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : 3B-----1 
BATTDATE : 2016-04-17
NOMINV : 120 Volts
NOMBATTV : 12.0 Volts
NOMPOWER : 420 Watts
FIRMWARE : 856.L3 .D USB FW:L3
END APC : 2019-06-11 07:24:32 +0800

apcupsd 有提供 apctest 指令,可作一些系統測試,但前提要先停掉 apcuspd

apcupsd 也有 web CGI 可用 ↓↓

http://ssorc.tw/apcupsd/upsstats.cgi
http://ssorc.tw/apcupsd/multimon.cgi
http://ssorc.tw/apcupsd/upsfstats.cgi
http://ssorc.tw/apcupsd/upsimage.cgi

設定一下 apache config

more /etc/httpd/conf.d/apcupsd.conf

ScriptAlias /apcupsd/ /var/www/apcupsd/
<Directory /var/www/apcupsd/>
    DirectoryIndex upsstats.cgi
    Options ExecCGI
    order deny,allow
    deny from all
    allow from 127.0.0.1
    allow from all
</Directory>

apcupsdapcupsd apcupsd

參考 http://www.apcupsd.org/manual/manual.html

 

其它

System Shutdown Test
This is an intermediate test that you can do, for all UPS models before doing the Full Power Down Test. First modify the /etc/apcupsd/apccontrol file so that in the killpower case, the line that re-executes apcupsd with the –killpower option is commented out. The original line probably looks something like:

${APCUPSD} –killpower

Related posts 相關文章
php apc 備註
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。