[SOLVED] How config NUT to shutdown Proxmox 7.1-12 ?? (exec_cmd(/etc/nut/upssched-cmd onbatt) returned 127)

tuyenda1985

Member
Feb 14, 2022
2
0
6
39
Hi everyone, hope you guys can help me

I have Proxmox : 7.1-12 vs cyperpower ut650e
I'm trying to install nut-client on pve, but when I check the system it gives me an error:

Oct 31 21:51:36 pve upsmon[101335]: UPS ups@192.168.10.1 on battery
Oct 31 21:51:36 pve upssched[111044]: Timer daemon started
Oct 31 21:51:36 pve upssched[111044]: New timer: onbatt (5 seconds)
Oct 31 21:51:41 pve upssched[111044]: Event: onbatt
Oct 31 21:51:41 pve upssched[111044]: exec_cmd(/etc/nut/upssched-cmd onbatt) returned 127
Oct 31 21:51:56 pve upssched[111044]: Timer queue empty, exiting
Oct 31 21:51:59 pve upsmon[101335]: UPS ups@192.168.10.1 on line power
Oct 31 21:51:59 pve upssched[111145]: Timer daemon started
Oct 31 21:51:59 pve upssched[111145]: Cancel onbatt, event: online
Oct 31 21:51:59 pve upssched[111145]: exec_cmd(/etc/nut/upssched-cmd online) returned 127

/etc/nut/upsmon.conf

Code:
MONITOR ups@192.168.10.1 1 ups_slave ups slave

MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h"
NOTIFYCMD /usr/sbin/upssched
POLLFREQ 2
POLLFREQALERT 1
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower

NOTIFYMSG ONLINE    "UPS %s on line power"
NOTIFYMSG ONBATT    "UPS %s on battery"
NOTIFYMSG LOWBATT   "UPS %s battery is low"
NOTIFYMSG FSD       "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK    "Communications with UPS %s established"
NOTIFYMSG COMMBAD   "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN  "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT  "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM    "UPS %s is unavailable"
NOTIFYMSG NOPARENT  "upsmon parent process died - shutdown impossible"

NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT  SYSLOG+WALL
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+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL

RBWARNTIME 43200

NOCOMMWARNTIME 600

FINALDELAY 5

/etc/nut/nut.conf

Code:
MODE=netclient

/etc/nut/upssched.conf

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

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

/etc/nut/upssched-cmd

Code:
#!/bin/sh
 case $1 in
       onbatt)
          logger -t upssched-cmd "UPS running on battery"
          /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

thank all

P/s: sorry for my language use google translate

Done:
- Because: my script has Windows line endings, which is confusing Linux.
Fix:
use Sublime Text on Windows or Mac to edit the scripts:

Click on View > Line Endings > Unix and save the file again.

jkZER.png
 
Last edited:
Check that your /etc/nut/upssched-cmd got linux compatible line endings. Also make sure that the nut user got the rights to execute /etc/nut/upssched-cmd. Maybe you also need to call "logger" with its full path.
 

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!