CyberPower UPS
本文档介绍如何安装 CyberPower UPS 守护程序 PowerPanel,或者 Network-UPS-Tools。 使用 CyberPower UPS 的主要优点是它价格便宜,并且可以通过 RS-232 或 USB 串行连接与您的 Linux 计算机进行通信。 如果发生长时间的断电,CyberPower UPS 电池容量即将耗尽时,它可以告知 Linux 计算机执行安全关机。
使用 PowerPanel
安装
安装 powerpanelAUR 软件包。
配置
编辑 /etc/pwrstatd.conf
可以通过编辑 /etc/powerpanel/pwrstatd-powerfail.sh
和 /etc/powerpanel/pwrstatd-lowbatt.sh
来实现电子邮件通知
/etc/powerpanel/pwrstatd-email.sh
而不是上游预期的 /etc/pwrstatd-email.sh
。运行
启动/启用 pwrstatd.service
。
要验证,运行
# pwrstat -status
The UPS information shows as following: Properties: Model Name................... Value 1500E Firmware Number.............. BFF7104#7N5 Rating Voltage............... 230 V Rating Power................. 900 Watt Current UPS status: State........................ Normal Power Supply by.............. Utility Power Utility Voltage.............. 230 V Output Voltage............... 230 V Battery Capacity............. 100 % Remaining Runtime............ 61 min. Load......................... 126 Watt(14 %) Line Interaction............. None Test Result.................. Unknown Last Power Event............. None
自定义
您可以使用 pwrstat
命令检查和更改当前设置。(但是,除非守护程序已启动并运行,否则该命令将不起作用。)
该服务在两种不同的情况下执行可配置的操作
- 当外部电源故障持续至少一定时间(默认 60 秒)时
- 当电池电量低时,由以下两种情况之一确定
- 电池容量低于预定百分比(默认 35%),或者
- 剩余运行时间(根据当前功耗估算)少于预定秒数(默认 300 秒,即 5 分钟)
要检查当前设置,请使用 pwrstat -config
。 例如
# pwrstat -config
Daemon Configuration: Alarm .............................................. On Hibernate .......................................... Off Action for Power Failure: Delay time since Power failure ............. 60 sec. Run script command ......................... On Path of script command ..................... /etc/powerpanel/pwrstatd-powerfail.sh Duration of command running ................ 0 sec. Enable shutdown system ..................... Off Action for Battery Low: Remaining runtime threshold ................ 300 sec. Battery capacity threshold ................. 35 %. Run script command ......................... On Path of command ............................ /etc/powerpanel/pwrstatd-lowbatt.sh Duration of command running ................ 0 sec. Enable shutdown system ..................... On
pwrstat
命令还提供了更改设置的界面。 例如,要配置 UPS 在发生电源故障但电池电量仍然充足时 *不* 自动关机
# pwrstat -pwrfail -shutdown off
请参阅 pwrstat(8) 或 PDF 用户手册,以获取有关如何配置设置的更多信息。
桌面通知
您可以修改 pwrstatd-powerfail.sh
和 pwrstatd-lowbatt.sh
脚本,以便在电源故障或电池电量低时(分别)发送 桌面通知。 例如,将以下行添加到任一文件
systemd-run --machine=target_user@.host --user notify-send "Warning: Utility power has failed. Now running on battery." --icon=battery-caution
使用 Network UPS Tools
如果您不想使用 PowerPanel,则 Network UPS Tools (NUT) 是另一种选择。 只需要其中一个程序(PowerPanel 或 NUT)来监控和关闭系统。 您不应同时使用两者,因为它们可能会相互干扰。
使用 Network UPS Tools 的 Wiki 页面中的说明。