我第一次在 ubuntu 上设置 UPS。我完全按照这里的说明进行操作:https://www.sobyte.net/post/2023-03/ups-nut-configuration-tutorial/
我的 UPS 是 PowerShield Defender 650。
正确的驱动程序是“blazer_usb”。
我已命名该设备屏蔽和命令如
upsc pshield
工作正常。
系统日志还显示系统确实可以识别电池电源何时被激活。例如:
01/12/2024 9:43:20 PM
Jan 12 21:43:19 barbelith upsmon[2624]: UPS pshield@localhost on battery
01/12/2024 9:43:20 PM
Jan 12 21:43:19 barbelith upssched[154701]: Timer daemon started
01/12/2024 9:43:20 PM
Jan 12 21:43:19 barbelith upssched[154701]: New timer: onbattwarn (10 seconds)
01/12/2024 9:43:20 PM
Jan 12 21:43:19 barbelith upssched[154700]: Executing command: onbattnoti
01/12/2024 9:43:20 PM
Jan 12 21:43:19 barbelith upssched[154700]: exec_cmd(/opt/scripts/upssched-cmd.sh onbattnoti) returned 1
01/12/2024 9:43:30 PM
Jan 12 21:43:29 barbelith upssched[154701]: Event: onbattwarn
01/12/2024 9:43:30 PM
Jan 12 21:43:29 barbelith upssched[154701]: exec_cmd(/opt/scripts/upssched-cmd.sh onbattwarn) returned 1
01/12/2024 9:43:45 PM
Jan 12 21:43:44 barbelith upssched[154701]: Timer queue empty, exiting
但实际的脚本(/opt/scripts/upssched-cmd.sh)似乎没有运行。即,系统没有关闭。 我怎样才能解决这个问题?
相关文件:
/opt/scripts/upssched-cmd.sh
#!/usr/bin/env bash
# from https://www.sobyte.net/post/2023-03/ups-nut-configuration-tutorial/
set -ex
exec >> /var/log/upssched-cmd.log 2>&1
# Functions mainly responsible for shutting down the system
function xpoweroff(){
logger -t upssched-cmd 'Preparing to shut down barbelith...'
logger -t upssched-cmd 'All necessary systems have been successfully shut down....'
}
# Determine the event triggered by upssched
case $1 in
onbattwarn)
logger -t upssched-cmd 'The UPS has switched to battery power, ready to safely shut down the system...'
xpoweroff
;;
ups-back-on-line)
logger -t upssched-cmd 'Municipal power has been restored...'
;;
lowbatt)
logger -t upssched-cmd 'UPS power is low, shut down the system immediately...'
xpoweroff
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
/etc/nut/ups.conf
[pshield]
driver = "blazer_usb"
port = "auto"
vendorid = "0665"
productid = "5161"
bus = "001"
/etc/nut/upsd.conf
LISTEN 0.0.0.0 3493
/etc/nut/upsmon.conf
SHUTDOWNCMD "/usr/sbin/poweroff"
MONITOR pshield@localhost 1 monuser PASSWORD master
NOTIFYCMD /usr/sbin/upssched
NOTIFYFLAG ONLINE SYSLOG+EXEC+WALL
NOTIFYFLAG ONBATT SYSLOG+EXEC+WALL
NOTIFYFLAG LOWBATT SYSLOG+EXEC
/etc/nut/upssched.conf
CMDSCRIPT /opt/scripts/upssched-cmd.sh
PIPEFN /run/nut/upssched.pipe
LOCKFN /run/nut/upssched.lock
AT ONBATT * START-TIMER onbattwarn 30
AT ONLINE * CANCEL-TIMER onbattwarn
AT ONBATT * EXECUTE onbattnoti