1. Install the APC UPS Daemon
apt install apcupsd -y
2. Modify the configuration file
vim /etc/apcupsd/apcupsd.conf
The following is an explanation of the configuration file, configured according to requirements
1.UPSCABLE:指定UPS设备与计算机之间使用的通信协议,可以是"usb"、"serial"或者"ethernet"等。例如:
UPSCABLE usb # 使用USB通信协议
2.UPSTYPE:指定UPS设备的类型usb
UPSTYPE usb # DEVICE /dev/ttyS0 这行要注释掉
#DEVICE /dev/ttyS0
3.ONBATTERYDELAY:UPS设备切换到电池供电模式后延迟执行一些特定操作的时间(秒)
ONBATTERYDELAY 6
4.BATTERYLEVEL:UPS电池电量的阈值,当UPS电池电量低于指定阈值时会关机(百分比值)
BATTERYLEVEL 90
5.MINUTES:UPS设备内部计算的剩余电池供电时间(分钟)低于MINUTES则关机。
MINUTES 5
6.TIMEOUT:在停电期间,UPS设备在电池供电模式下超过了TIMEOUT参数指定的时间(秒),就执行关机
TIMEOUT 10
注意:BATTERYLEVEL、MINUTES和TIMEOUT参数是相互关联的,
因此,其中任何一个参数首先达到阈值都会导致系统启动关机程序。
7.POLLTIME:设置apcupsd向UPS设备查询状态的时间间隔(以秒为单位)
POLLTIME 30
3. Start the apcupsd service
#启动apcupsd服务
systemctl start apcupsd.service
#apcupsd服务开机自动启动
systemctl enable apcupsd.service
#重启apcupsd服务
systemctl restart apcupsd.service
#查看apcupsd服务状态
systemctl status apcupsd.service
#查看ups状态
apcaccess
Other devices in the LAN can also use the apcupsd service
#编辑apcupsd的配置文件/etc/apcupsd/apcupsd.conf,确保以下参数设置正确:
NETSERVER on # 开启网络服务
NISIP 0.0.0.0 # 监听所有网络接口
NISPORT 3551 # 监听端口号
#如果只想允许特定的IP地址访问网络服务,则可以将NISIP参数设置为相应的IP地址
#重启apcupsd服务以使更改生效,使用以下命令:
systemctl restart apcupsd.service
Go to the apcupsd official website to download and install the software package corresponding to the system: www.apcupsd.org
The following is the configuration of windows as a network connection
C:\apcupsd\etc\apcupsd\apcupsd.conf
UPSCABLE ether
UPSTYPE net
DEVICE 192.168.0.253:3551
TIMEOUT 30
UPSCLASS shareslave
UPSMODE share