|
 
|
1#
发表于 2005-9-17 14:24
| 只看该作者
网络中利用APC的Network Information Server实现多台主机自动关机(接在同一个UPS上)
下文只是个简单的例子,欢迎指正.
作者:congli
日期:2005.9.14
实验环境:
APC UPS 1000W
主机A IP:10.0.0.200 COM1接UPS
主机B IP:10.0.0.202 (运行在VM中)
PS:主机A及主机B均由UPS供电.
主机A:
1.安装apcupsd
# cd /usr/ports/sysutils/apcupsd
# make install clean
代码:
[ ] CLIENT_ONLY Build apcupsd client only (no network server)
[X] CGI Compile with CGI programms to show status
[ ] USB Compile with USB Support (READ MANUAL!!!)
[X] SNMP Compile with SNMP Support (READ MANUAL!!!
2.设置apcupsd
# cd /usr/local/etc/rc.d
# mv apcupsd.sh.sample apcupsd.sh
# vi /etc/rc.conf
代码:
apcupsd_enable="YES"
3.设置配置文件
# cd /usr/local/etc/apcupsd
# vi apcupsd.conf
代码:
DEVICE /dev/cuaa0 # COM1
NISIP 10.0.0.200 # NISIP
BATTERYLEVEL 5 # 电量百分比,到达此数值,计算机自动关闭
4.启动apcupsd
# /usr/local/etc/rc.d/apcupsd.sh start
5.测试
# apcaccess
代码:
APC : 001,052,1236
DATE : Wed Sep 14 15:22:43 CST 2005
HOSTNAME : FreeBSD
RELEASE : 3.10.17a
VERSION : 3.10.17a (22 April 2005) freebsd
UPSNAME : UPS_IDEN
CABLE : Custom Cable Smart
MODEL : SMART-UPS 1000
UPSMODE : Stand Alone
STARTTIME: Wed Sep 14 15:17:14 CST 2005
STATUS : ONLINE
LINEV : 219.7 Volts
LOADPCT : 46.8 Percent Load Capacity
BCHARGE : 059.0 Percent
TIMELEFT : 13.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
MAXLINEV : 221.0 Volts
MINLINEV : 215.8 Volts
OUTPUTV : 219.7 Volts
SENSE : High
DWAKE : 000 Seconds
DSHUTD : 020 Seconds
DLOWBATT : 02 Minutes
LOTRANS : 196.0 Volts
HITRANS : 253.0 Volts
RETPCT : 000.0 Percent
ITEMP : 40.0 C Internal
ALARMDEL : 5 seconds
BATTV : 27.1 Volts
LINEFREQ : 50.0 Hz
LASTXFER : Line voltage notch or spike
NUMXFERS : 0
TONBATT : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STESTI : 336
STATFLAG : 0x02000008 Status Flag
DIPSW : 0x00 Dip Switch
REG1 : 0x00 Register 1
REG2 : 0x00 Register 2
REG3 : 0x00 Register 3
MANDATE : 02/12/97
SERIALNO : GS9707073087
BATTDATE : 02/12/97
NOMOUTV : 230
NOMBATTV : 24.0
EXTBATTS : 0
FIRMWARE : 60.9.I
APCMODEL : IWI
END APC : Wed Sep 14 15:23:20 CST 2005
如果apcupsd启动后马上运行apcaccess,可能会出现如下错误,应该是主机与UPS通信未完成的关系,多等一会就好了.
代码:
FATAL ERROR in apcaccess.c at line 243
tcp_open: cannot connect to server 10.0.0.200 on port 3551.
ERR=Connection refused
主机B:
1.安装apcupsd
# cd /usr/ports/sysutils/apcupsd
# make install clean
代码:
[X] CLIENT_ONLY Build apcupsd client only (no network server)
[ ] CGI Compile with CGI programms to show status
[ ] USB Compile with USB Support (READ MANUAL!!!)
[ ] SNMP Compile with SNMP Support (READ MANUAL!!!
2.设置apcupsd
# cd /usr/local/etc/rc.d
# mv apcupsd.sh.sample apcupsd.sh
# vi /etc/rc.conf
代码:
apcupsd_enable="YES"
3.设置配置文件
# cd /usr/local/etc/apcupsd
# vi apcupsd.conf
代码:
UPSCABLE ether
UPSTYPE net
DEVICE 10.0.0.200:3551
NETSERVER off
NISIP 10.0.0.200 # NISIP
4.启动apcupsd
# /usr/local/etc/rc.d/apcupsd.sh start
测试:
关闭UPS外部电源,并过几秒后重新打开UPS外部电源,主机A及主机B均显示信息,当UPS电量低致BATTERYLEVEL指定值,主机A,B及UPS会自动关闭.
主机A:
代码:
Broadcast Message from root@FreeBSD
(no tty) at 14:25 CST...
Warning power loss detected.
Broadcast Message from root@FreeBSD
(no tty) at 14:26 CST...
Power failure. Running on UPS batteries.
Broadcast Message from root@FreeBSD
(no tty) at 14:26 CST...
Power has returned...
主机B:
代码:
vm-freebsd# Sep 14 14:26:28 vm-freebsd apcupsd[497]: Power failure.
Broadcast Message from root@vm-freebsd
(no tty) at 14:26 CST...
Warning power loss detected.
Sep 14 14:26:34 vm-freebsd apcupsd[497]: Running on UPS batteries.
Broadcast Message from root@vm-freebsd
(no tty) at 14:26 CST...
Power failure. Running on UPS batteries.
Sep 14 14:26:46 vm-freebsd apcupsd[497]: Mains returned. No longer on UPS batteries.
Sep 14 14:26:46 vm-freebsd apcupsd[497]: Power is back. UPS running on mains.
Broadcast Message from root@vm-freebsd
(no tty) at 14:26 CST...
Power has returned... |
|