:::| 目前位置圖示目前位置:首頁圖示回首頁 | 主功能頁圖示相關問答
FREEBSD 安裝APC UPS

[日期]:2022/04/25  [瀏覽人數]:458

FREEBSD 的PORT已經有支援APC的UPS的功能

apcupsd

1.安裝apcupsd

#cd /usr/ports/sysutils/apcupsd

make install clean

若使用USB連接方式,選項要勾選[X]Compile with USB Support driver

至於SNMP_DRV及SNMP_DRV_OLD若UPS未使用網卡的SNMP方式偵測時,可不用安裝.

----------------------------

Sample files and scripts are installed in /usr/local/etc/apcupsd.
You need to modify /usr/local/etc/apcupsd/apcupsd.conf as follows:

For serial cable: DEVICE /dev/cuadX (or /dev/cuaaX for [45.]x)
For USB cable: DEVICE (yes, leave it blank after DEVICE)
NOTE that for USB cable you need uhid support.

Add apcupsd_enable=YES to your /etc/rc.conf[.local] to have apcupsd
starting up at boot time.

For default, apcupsd starts with `--kill-on-powerfail` parameter.
Please, read its man page, and if this is not the intended behavior you want,
change it accordingly.

If connected via USB and apcaccess reports incomplete data consider enabling
the USB_REPORTING options via 'make config'. This contains an experimental
patch that may fix some USB attach APC UPS. PR #249041

In some systems where the shutdown can take a while (like in bhyve environment),
you may want to change this behavior as follows:

Set apcupsd_flags="--term-on-powerfail" on your /etc/rc.conf[.local].

Add this to /etc/rc.shutdown, after the "Insert other shutdown procedures here"
line:
test -f /var/run/powerfail && /usr/local/sbin/apcupsd --hibernate
or
test -f /var/run/powerfail && /usr/local/sbin/apcupsd --power-off

===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/sbin/apcaccess
/usr/local/sbin/apcupsd
/usr/local/sbin/apctest

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://www.apcupsd.com

--------------------

2.安裝完成後更改/etc/rc.conf

新增apcupsd_enable="YES"

3.設定apcupsd.conf

#cd /usr/local/etc/apcupsd

#ee apcupsd.conf

UPSNAME SUA1500
UPSCABLE usb
UPSTYPE usb
DEVICE
LOCKFILE /var/spool/lock
SCRIPTDIR /usr/local/etc/apcupsd
PWRFAILDIR /var/run
NOLOGINDIR /var/run
ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 10 #電力剩餘多少時間就自動關機
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 300 #狀態寫入檔案的時間
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

4.啟動apcupsd

/usr/local/etc/rc.d/apcupsd start

5.測試

#apcaccess

會出現UPS的狀態訊息就表示成功了.

第2台主機設定被控

1.安裝apcupsd

#cd /usr/ports/sysutils/apcupsd

#make install clean

可以只選CLIENT_ONLY Only NIS client (no network server or drivers)

若選擇這個選項時其他*_DRV的都不能選,否則會出現錯誤.

也可以和主控主機一樣的選項

2.安裝完成後更改/etc/rc.conf

新增apcupsd_enable="YES"

3.設定apcupsd.conf

#cd /usr/local/etc/apcupsd

#ee apcupsd.conf

UPSNAME SUA1500
UPSCABLE ether
UPSTYPE net
DEVICE 192.168.1.10:3551 #主控主機IP
LOCKFILE /var/spool/lock
SCRIPTDIR /usr/local/etc/apcupsd
PWRFAILDIR /var/run
NOLOGINDIR /var/run
ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 10 #電力剩餘多少時間就自動關機
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER off
NISIP 192.168.1.10 #主控主機的IP

EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 300 #狀態寫入檔案的時間
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

4.啟動apcupsd

/usr/local/etc/rc.d/apcupsd start

當市電停電時2台主機皆會出現停電訊息