Skip to content

Instantly share code, notes, and snippets.

@InQuize
Last active March 16, 2024 13:25
  • Star 29 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save InQuize/ab99feb66822dc1a975c to your computer and use it in GitHub Desktop.
Proxomox - NUT Client.md

Configuring Proxmox VE node as client for remote NUT server


apt-get install nut
  • Edit /etc/nut/nut.conf:
MODE=netclient
  • Edit /etc/nut/upsmon.conf: MONITOR <system> <powervalue> <username> <password> ("master"|"slave"):
MONITOR ups@10.2.0.2 1 upsmon password slave
  • Start monitoring:
upsmon start
  • To check UPS status: upsc <name> for direct attached units or upsc <name>@<address> for remote
upsc ups@10.2.0.2
@KenwoodFox
Copy link

This is nice.

@Gu1llaum-3
Copy link

Thanks a lot for this !

@HASSNypon30
Copy link

Still works as i should on 7.2-5, thank you

@KidA001
Copy link

KidA001 commented Sep 19, 2022

Wow, this is way simpler than I thought. Looked everywhere for this, thank you!

@arronlorenz
Copy link

Thank you! Any tips for polling intervals?

@InQuize
Copy link
Author

InQuize commented Nov 27, 2022

Any tips for polling intervals?

client: upsmon.conf > POLLFREQ (5 sec by default)
server: ups.conf > pollinterval (2 sec by default)

Although, full doc is worth the time and not too long/complex as other man entries often get:
https://networkupstools.org/docs/man/ups.conf.html
https://networkupstools.org/docs/man/upsmon.conf.html

@docop
Copy link

docop commented May 25, 2023

For Proxmox running as client, is there a need for a shutdown script .. as is all vm do close and then the prox server shutdown or it's a panic shutdown of all ? thanks for precision.

@KidA001
Copy link

KidA001 commented May 26, 2023

For Proxmox running as client, is there a need for a shutdown script .. as is all vm do close and then the prox server shutdown or it's a panic shutdown of all ? thanks for precision.

It's not required but if you want it to run/do certain things before shutdown then this is where you would put it.

@docop
Copy link

docop commented May 26, 2023

So i did test over the cmd : upsmon -c fsd , and the proxmox box as client do shutdown. But if communication fail it don't do anything, it just if the ups get the battery dead. I do see other config as :

nano /etc/nut/upsmon.conf

MONITOR ups1@192.168.0.35 1 upsmon secret slave

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

# Notification message:
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"
# Notification events : go syslog - broadcast msg - exec .script?
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

-=-=-=-=-
sudo nano /etc/nut/upssched.conf

# scheduler to shutdown
CMDSCRIPT /etc/nut/upssched-cmd
PIPEFN /etc/nut/upssched.pipe
LOCKFN /etc/nut/upssched.lock

# timer in sec
AT ONBATT * START-TIMER onbatt 30
AT ONLINE * CANCEL-TIMER onbatt online
AT ONBATT * START-TIMER earlyshutdown 30
AT LOWBATT * EXECUTE onbatt
AT COMMBAD * START-TIMER commbad 30
AT COMMOK * CANCEL-TIMER commbad commok
AT NOCOMM * EXECUTE commbad
AT SHUTDOWN * EXECUTE powerdown
# AT SHUTDOWN * EXECUTE powerdown

is a script is needed ? Do you have an example or you just used nut at when no more power in the ups, then the proxmox box go for shutoff ?

@InQuize
Copy link
Author

InQuize commented May 27, 2023

No other scripts in my setup. It is a graceful shutdown including all VMs.
Client performs action based on server configuration.
My server is NUT service inside TrueNAS VM. It is configured to shutdown after N minutes of ONBATT state.

If communication is lost NUT should spam you with e-mails until it is fixed, but there must be a valid account configured for each system's e-mail MTA (e.g. postfix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment