HowTo shutdown Proxmox Host with Nethserver NUT-Module?

I run a Nethserver VM on a Proxmox Host and would like to use Nethserver to shutdown the Host on a Power loss… I just installed the NUT-Module and the UPS is now communicating via USB…

[root@neth7srv1 ~]# upsc UPS
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.runtime: -1
battery.runtime.low: 150
battery.type: PbAc
battery.voltage: 61.2
battery.voltage.nominal: 48.0
device.mfr: American Power Conversion
device.model: Smart-UPS SRT
device.serial: XXXXXXXXXX
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 10
driver.parameter.port: /dev/ttyUSB0
driver.version: 2.7.2
driver.version.data: APC HID 0.95
driver.version.internal: 0.38
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: UPS 00.8 / ID=1024
ups.mfr: American Power Conversion
ups.mfr.date: 2021/10/13
ups.model: Smart-UPS SRT
ups.productid: 0003
ups.serial: XXXXXXXXXX
ups.status: OL
ups.timer.reboot: -1
ups.timer.shutdown: 65535
ups.vendorid: 051d

How can I configure the PVE shutdown and other parameters under the Nethserver VM?

P.S. Would be nice to have the ability to use a command like:
ssh root@host /sbin/shutdown -h now

Hi @fausp

Much easier the other way around.

NUT as server on Proxmox.
NUT as client in Nethserver…

Easy & fast to setup…

Actually, the NUT server on proxmox can correctly shut down all VMs, especially if VMs are using qemu-guest-agent… This is VERY reliable!

My 2 cents
Andy

Hi Andy,
it took me abt 2min to install the nut-module under nethserver… If the proxmox host would be the master I would not need to configure the nethserver vm as a client because the vms are shutdown automatically…

I just need a way to configure the nethserver vm to send out a shutdown command to a list of servers?

you can configure nut as server on neth - and nut as client on the others.
Much less ssh issues and headaches! NUT is very simple!

I have NethServer installed as NUT client - I can view all UPS data from the Web GUI - which proxmox does not have. I use Zabbix to montorr my USVs, but it’s still nice to have a local client installed.

1 Like

I was thinking abt that as a plan B… I think less configuration-work is to start a script, as I said…

Nice! How does it work on Nethserver, I guess with zabbix?

1 Like

Less work to start a script - remozely? You must be joking!

You need to assure password-less logins from Neth to Proxmox (And any other servers).
The script would also need to use another user than root (security reasons, it would work also with root), and then use sudo…

It works, but takes longer than the 3 Mins i need to set up NUT client & server… :slight_smile:

→ Touché!

1 Like

I have this on all of my servers…

In the shown use case, I have a RPI3 running only NUT as server.
Zabbix queries its values and displays them.

Proxmox, The Synology NAS and other VMs use either NUT client (Synology uses NUT out of the box, with hardcoded user/password, like Nethserver had a few years ago, still version 7!), or Proxmox qemu-guest-agent.

NUT has 6 config files, but most only need a single entry at the bottom.

1 Like

You still need to make sure you include the full paths to binaries like poweroff (/sbin/poweroff or /usr/sbin/poweroff)

1 Like

This could help, see “suspending linux” at the bottom:

…Good instructions for secure handling… :slight_smile:

1 Like

Hi @Andy_Wismer

Very interesting link.

Michel-André

1 Like

For those who don’t know Home Assistant and would like to test drive it say in a VM:

A great OpenSource Project, I’m using this since 2018 (replacing a commercial solution on Mac).

I use Home Assistant in a Raspberry PI4 and one in a Proxmox virtualized environment…

My balcony control panel:

Sorry for OT…

:slight_smile:

My 2 cents
Andy

3 Likes

OK, it worked “for me” with a script defined in - upsmon.conf

MyScript:

#!/bin/bash

ssh root@host1 shutdown -h now
ssh root@host2 shutdown -h now

exit 0

On the end I changed the battery charge low to 20:

upsrw -s battery.charge.low=20 -u admin -p xxMySecretxx UPS
3 Likes