After several power outages I finally decided to by a small UPS (USV) for my homelab. I don’t like when my IT infrastructur, especially the Synology NAS, gets switched off without a normal shutdown. So I bought a new EATON 5P 650 UPS to cover my NAS and server.
I started trying to use the Synology Diskstation as a NUT server. Usually the NAS can do this by default. You just attache the UPS via usb to the NAS and activate the function. Everything seems working fine. The problem was, it works locally. But you could not connect to the NUT server from another machine. I tried to connect from an ESXi 6.7 U3 host with installed NUT-Client and from an Windows Server 2019, both couldn’t connect. The ESXi hosts said „Error: Access denied“ so I tried to connect via telnet.
telnet nut-server-ip-address 3493
With telnet I get a connection, but when it comes to login with the username, there is also an access denied. After many hours trying to fix thie access problem I gave up. The funny thing is, after all this I setup a new NUT Server on an Debian VM in under 15 min.
NUT package (nutd and upsmon)
- Plug-In the UPS USB-Connection to the host. In my case I connected it to the ESXi host and configured a this new virtual usb device in the Debain VM. You also can use a normal computer with Debian 10 installed.
- Install the NUT package with the apt package manager
sudo apt-get install nut
- Make some configurations and changes in the nut directory /etc/nut
# /etc/nut/ drwxr-xr-x 2 root nut 4096 Jan 11 00:49 . drwxr-xr-x 94 root root 4096 Jan 10 23:54 .. -rw-r----- 1 root nut 1543 Jan 11 00:01 nut.conf -rw-r----- 1 root nut 5571 Jan 11 00:12 ups.conf -rw-r----- 1 root nut 4595 Jan 11 00:01 upsd.conf -rw-r----- 1 root nut 2177 Jan 11 00:03 upsd.users -rw-r----- 1 root nut 15362 Jan 11 00:16 upsmon.conf -rw-r----- 1 root nut 3887 Jun 1 2018 upssched.conf
- In the nut.conf file we change the MODE to netserver
# /etc/nut/nut.conf MODE=netserver
- In the ups.conf we need to configure the right drivers for the UPS. In my case I knew what to configure, because the Synology NAS made the right configuration. You can get a compatibility list from the NUT-Server on https://networkupstools.org/stable-hcl.html
We make a new section for the UPS like in this example. As my UPS is connected via usb the port configuration can be set to auto. If you connect the UPS via a serial cable you need to configure it different.# /etc/nut/ups.conf [eaton] driver = usbhid-ups port = auto
The name in the brackets can be anything you like to identify the ups. I used eaton as the name related to the manufacturer. In bigger setups you may like to name it like [serverups] …
After setting up the right drivers we can make sure that the NUT-Server detects the UPS.upsdrvctl start
The output should look like this
Network UPS Tools - UPS driver controller 2.7.4 Network UPS Tools - Generic HID driver 0.41 (2.7.4) USB communication driver 0.33
- The upsd.conf has a LISTEN section. We need to configure it with the server ip-address so we can connect to the NUT-Server from other clients.
# /etc/nut/upsd.conf LISTEN 192.168.0.123 LISTEN 127.0.0.1 3493 LISTEN ::1 3493
In my example I’ve added the first ip-address (192.168.0.123). There is no need to write the port behind the address (3493) unless you want to change the default port.
- After that we need to make a new user in the upsd.user file
# /etc/nut/upsd.user [upsmon] password = supersecretpassword upsmon master
You should add multiple users for the server an client. See the man page for upsd.users for more information.
- Now we configure the upsmon.conf there we need to add a MONITOR master
# /etc/nut/upsmon.conf # MONITOR
("master"|"slave") # # is an integer - the number of power supplies that this UPS # feeds on this system. Most computers only have one power supply, so this # is normally set to 1. You need a pretty big or special box to have any # other value here. # MONITOR eaton@192.168.0.123 1 monuser supersecretpassword master # POWERDOWNFLAG /etc/killpower SHUTDOWNCMD "/sbin/shutdown -h now" As the system name us us the value in the brackets you made in the ups.conf the user and password was configured in the upsd.user file.
- Since we don’t want that other users can read this secret files we fix the permissions for our needs.
$ sudo chown root:nut /etc/nut/* $ sudo chmod 640 /etc/nut/*
- At the end whe should reload both services upsd and upsmon. This can be done like this
Testing a local Client request
- Now we can test if the NUT-Server works locally. In my case the name of my instance is [eaton]. Therfore I’ll make client request to this the instance name eaton.
upsc eaton
If everything works fine we get an output similar like this
Init SSL without certificate database battery.capacity: 9.00 battery.charge: 100 battery.charge.low: 20 battery.charge.restart: 0 battery.charger.status: floating battery.energysave: no battery.energysave.delay: 300 battery.energysave.load: 5 battery.protection: yes battery.runtime: 1575 battery.type: PbAc battery.voltage: 13.7 battery.voltage.nominal: 12 device.mfr: EATON device.model: 5P 650 device.serial: G114L41071 device.type: ups driver.name: usbhid-ups driver.parameter.pollfreq: 30 driver.parameter.pollinterval: 2 driver.parameter.port: auto driver.parameter.synchronous: no driver.version: 2.7.4 driver.version.data: MGE HID 1.39 driver.version.internal: 0.41 input.current: 0.70 input.frequency: 49.9 input.frequency.extended: no input.frequency.nominal: 50 input.sensitivity: normal input.transfer.boost.low: 184 input.transfer.high: 294 input.transfer.low: 160 input.transfer.trim.high: 265 input.voltage: 235.9 input.voltage.extended: no input.voltage.nominal: 230 outlet.1.autoswitch.charge.low: 0 outlet.1.delay.shutdown: 65535 outlet.1.delay.start: 3 outlet.1.desc: PowerShare Outlet 1 outlet.1.id: 1 outlet.1.status: on outlet.1.switchable: yes outlet.2.autoswitch.charge.low: 0 outlet.2.delay.shutdown: 65535 outlet.2.delay.start: 6 outlet.2.desc: PowerShare Outlet 2 outlet.2.id: 2 outlet.2.status: on outlet.2.switchable: yes outlet.desc: Main Outlet outlet.id: 0 outlet.switchable: no output.current: 0.60 output.frequency: 49.9 output.frequency.nominal: 50 output.powerfactor: 0.53 output.voltage: 235.9 output.voltage.nominal: 230 ups.beeper.status: enabled ups.delay.shutdown: 20 ups.delay.start: 30 ups.efficiency: 86 ups.firmware: 02.14.0026 ups.load: 21 ups.load.high: 105 ups.mfr: EATON ups.model: 5P 650 ups.power: 142 ups.power.nominal: 650 ups.productid: ffff ups.realpower: 76 ups.realpower.nominal: 420 ups.serial: G114L41071 ups.shutdown: enabled ups.start.auto: yes ups.start.battery: yes ups.start.reboot: yes ups.status: OL CHRG ups.test.interval: 2592000 ups.test.result: Done and passed ups.timer.shutdown: 0 ups.timer.start: 0 ups.type: offline / line interactive ups.vendorid: 0463
I hope I could help you make a basic NUT-Server setup for your homelab.
Eintrag teilen