Nut 在切换到电池供电时立即关闭服务器,无需通知

Nut 在切换到电池供电时立即关闭服务器,无需通知

我在 Ubuntu 16.04 服务器上安装了 Nut,以便与我的 Eaton 5SC-750 进行连接,如下所示本指南。但是,当我从墙上拔下 UPS 时,服务器立即关闭,并且控制台上不显示任何消息。

我觉得这是发出了强制关机命令,而不是执行指南提供的脚本。为什么?我该如何修复它?

我希望它能用电池运行 2 分钟,然后再关机。我计划将第二台服务器(作为 Nut 中的从属服务器)连接到此 UPS。

以下是切换至电池关机的系统日志条目:

Feb  3 14:49:17 Hutch upsmon[1252]: UPS philip@localhost on battery
Feb  3 14:49:17 Hutch upsmon[1252]: Signal 10: User requested FSD
Feb  3 14:49:17 Hutch upsd[1235]: Client monuser@::1 set FSD on UPS [philip]
Feb  3 14:49:17 Hutch upsmon[1252]: Executing automatic power-fail shutdown
Feb  3 14:49:17 Hutch upsmon[1252]: Auto logout and shutdown proceeding 

配置文件内容(减去注释):

nut.conf

MODE=standalone

ups配置文件

[philip]
    driver = usbhid-ups
    port = auto
    desc = "Eaton 5SC750 UPS"

upsd.conf

LISTEN 127.0.0.1 3493
LISTEN ::1 3493
LISTEN 203.192.151.2 3493

upsd.用户

[admin]
   password = ********
   actions = SET
   instcmds = ALL

[monuser]
    password = *********
    instcmds = ALL
    upsmon master

[monuserc]
    password = ********
    upsmon slave

[monuserv]
    password = ********
    upsmon slave

upsmon配置文件

[monuser]
    password = ********
    #actions = SET FSD
    instcmds = ALL
    upsmon master

[monuserslave]
    password = ********
    upsmon slave

MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -P now"
NOTIFYCMD /etc/nut/notifycmd
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
NOTIFYFLAG ONLINE      SYSLOG+WALL
NOTIFYFLAG ONBATT      SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT     SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL
NOTIFYFLAG COMMOK      SYSLOG+WALL
NOTIFYFLAG COMMBAD     SYSLOG+WALL
NOTIFYFLAG SHUTDOWN    SYSLOG+WALL
NOTIFYFLAG REPLBATT    SYSLOG+WALL
NOTIFYFLAG NOCOMM      SYSLOG+WALL
NOTIFYFLAG NOPARENT    SYSLOG+WALL
FINALDELAY 5

/etc/nut/通知命令

#!/bin/bash
#
# NUT NOTIFYCMD script

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin

trap "exit 0" SIGTERM

if [ "$NOTIFYTYPE" = "ONLINE" ]
then
    echo $0: power restored | wall
    # Cause all instances of this script to exit.
    killall -s SIGTERM `basename $0`
fi

if [ "$NOTIFYTYPE" = "ONBATT" ]
then
    echo $0: 2 minutes till system powers down... | wall
    # Loop with one second interval to allow SIGTERM reception.
    let "n = 120"
    while [ $n -ne 0 ]
    do
            sleep 1
            let "n--"
    done
    echo $0: commencing shutdown | wall
    upsmon -c fsd
fi

谢谢

答案1

这个问题已经存在三年多了,但对于遇到同样问题的人来说:您是否检查过您的 UPS 是否有一个或多个输出没有电池备份?就我而言,我设法为 NUT 服务器选择了具有浪涌保护的单个插座,当模拟断电时,它当然会立即关闭,而从属电源保持开启状态。找出原因并更换插头后,一切都正常了。

相关内容