[SOLVED] NUT Client -> configuration SHUTDOWN Proxmox Host

Ronny1978

Member
Mar 13, 2023
66
14
8
Hello Together.

I hope you can help me?

I meet the following requirements:

- Synology DS918+ as NUT Server
- Proxmox host as NUT Client
- APC 1000 with USB connection to Synology DS918+

What works?

- the connection between DS918+ and Proxmox host is established and works
- sending emails from Proxmox host, when NUT connection is lost, established, on batt or online again

What doesn't works?

I want to shut down Proxmox host with "upsmon -c fsd" after 180 seconds after change to ONBATT, but the script doesn't starts. If I execute "upsmon -c fsd" in the Proxmox shell for testing, it works fine. So I think I have a problem with the upssched-cmd. Here me configurations:

nut.conf
Code:
MODE=netclient

upsmon.conf
Code:
RUN_AS_USER root
MONITOR ups@192.168.1.20 1 monuser Secret slave
NOTIFYCMD /etc/nut/notify

MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower

NOTIFYMSG ONLINE        "UPS %s ist wieder Online"
NOTIFYMSG ONBATT        "UPS %s ist im Akkumodus"
NOTIFYMSG LOWBATT       "UPS %s Batterie ist niedrig"
NOTIFYMSG FSD           "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK        "Kommunikation mit UPS %s ist wieder hergestellt"
NOTIFYMSG COMMBAD       "Kommunikation mit UPS %s unterbrochen"
NOTIFYMSG SHUTDOWN      "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT      "UPS %s Batterie muss ersetzt werden"
NOTIFYMSG NOCOMM        "UPS %s ist nicht erreichbar"
NOTIFYMSG NOPARENT      "upsmon Prozess  - shutdown ist unmöglich"

ONLINE   : UPS is back online
ONBATT   : UPS is on battery
LOWBATT  : UPS has a low battery (if also on battery, it's "critical")
FSD      : UPS is being shutdown by the master (FSD = "Forced Shutdown")
COMMOK   : Communications established with the UPS
COMMBAD  : Communications lost to the UPS
SHUTDOWN : The system is being shutdown
REPLBATT : The UPS battery is bad and needs to be replaced
NOCOMM   : A UPS is unavailable (can't be contacted for monitoring)
NOPARENT : The process that shuts down the system has died (shutdown impossible)

NOTIFYFLAG ONLINE       SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT       SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT      SYSLOG+WALL+EXEC
NOTIFYFLAG FSD          SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK       SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD      SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN     SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT     SYSLOG+WALL
NOTIFYFLAG NOCOMM       SYSLOG+WALL
NOTIFYFLAG NOPARENT     SYSLOG+WALL

RBWARNTIME 43200

NOCOMMWARNTIME 180

FINALDELAY 5

upssched.conf
Code:
CMDSCRIPT /etc/nut/upssched-cmd
PIPEFN /etc/nut/upssched.pipe
LOCKFN /etc/nut/upssched.lock

AT ONBATT * START-TIMER onbatt 180
AT ONBATT * EXECUTE onbatt
AT ONLINE * CANCEL-TIMER onbatt online
AT LOWBATT * EXECUTE onbatt
AT COMMBAD * START-TIMER commbad 120
AT COMMOK * CANCEL-TIMER commbad commok
AT NOCOMM * EXECUTE commbad
AT SHUTDOWN * EXECUTE powerdown

upssched-cmd
Code:
#!/bin/sh
 case $1 in
       onbatt)
          logger -t upssched-cmd "UPS running on battery"
          /usr/sbin/upsmon -c fsd
          ;;
       earlyshutdown)
          logger -t upssched-cmd "UPS on battery too long, early shutdown"
          /usr/sbin/upsmon -c fsd
          ;;
       shutdowncritical)
          logger -t upssched-cmd "UPS on battery critical, forced shutdown"
          /usr/sbin/upsmon -c fsd
          ;;
       upsgone)
          logger -t upssched-cmd "UPS has been gone too long, can't reach"
          ;;
       *)
          logger -t upssched-cmd "Unrecognized command: $1"
          ;;
 esac

For your help many thanks in advance. Have a nice weekend and please stay healthy.

Ronny
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!