Overview
For this setup, we will be setting up our UPS master on a raspberry pi with slaves setup on a QNAP NAS and a Ubuntu Server.
Master Setup on Raspberry Pi
Connect UPS using USP cable
Installation
$ sudo apt-get install nut |
Setup
Configure ups.conf
Add the following config
[qnapups]
driver = usbhid-ups
port = auto
desc = "Back-UPS ES 750" |
Configure upsd.conf
$ sudo vi /etc/nut/upsd.conf |
Add the following config:
Update Credentials
$ sudo vi /etc/nut/upsd.users |
[admin]
password = 123456
actions = SET
instcmds = ALL
[upsmon]
password = 123456
upsmon master |
Update Nut.Conf
$ sudo vi /etc/nut/nut.conf |
Set Mode=netserver
Setup upsmon.conf
$ vi /etc/nut/upsmon.conf |
Add the following line
MONITOR qnapups@localhost 1 upsmon 123456 master |
Verify Hardware Config
Restart the Service
$ sudo service nut-server restart |
Get Status
$ sudo service nut-server status
● nut-server.service - Network UPS Tools - power devices information server
Loaded: loaded (/lib/systemd/system/nut-server.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-24 20:28:53 EDT; 7s ago
Process: 12995 ExecStart=/sbin/upsd (code=exited, status=0/SUCCESS)
Main PID: 12996 (upsd)
Tasks: 1 (limit: 877)
CGroup: /system.slice/nut-server.service
└─12996 /lib/nut/upsd
Aug 24 20:28:53 pihole systemd[1]: Starting Network UPS Tools - power devices information server...
Aug 24 20:28:53 pihole upsd[12995]: fopen /var/run/nut/upsd.pid: No such file or directory
Aug 24 20:28:53 pihole upsd[12995]: listening on 127.0.0.1 port 3493
Aug 24 20:28:53 pihole upsd[12995]: listening on ::1 port 3493
Aug 24 20:28:53 pihole upsd[12995]: listening on 127.0.0.1 port 3493
Aug 24 20:28:53 pihole upsd[12995]: Connected to UPS [homeups]: usbhid-ups-homeups
Aug 24 20:28:53 pihole upsd[12995]: listening on ::1 port 3493
Aug 24 20:28:53 pihole upsd[12995]: Connected to UPS [homeups]: usbhid-ups-homeups
Aug 24 20:28:53 pihole systemd[1]: Started Network UPS Tools - power devices information server.
Aug 24 20:28:53 pihole upsd[12996]: Startup successful |
Query the UPS
$ upsc qnapups@localhost
$ upsc qnapups@192.168.1.52
battery.charge: 100
battery.charge.low: 10
...
ups.vendorid: 051d |
Client Setup QNAP
From the QNAP UI, open the control panel and navigate to External Sevices → UPS
Select Remote UPS Slave and enter the IP address of the master.
Click apply. The UPS information should now be updated. See screenshots below.
From a shell connection on the QNAP server, you can verify connection via the following command: (not required)
$ upsc qnapups@192.168.1.52
battery.charge: 100
...
ups.vendorid: 051d |
Client Setup (Ubuntu)
Installation
Install nut-client
$ sudo apt-get install nut-client
|
Configure
Update nut-config
Set mode to netclient
Update upsmon.conf
$ vi /etc/nut/upsmon.conf |
RUN_AS_USER root
MONITOR qnapups@192.168.1.52 1 upsmon 123456 slave |
For our QNAP master
- upsname = qnapups
- user = upsmon
- password = 123456
Restart Nut Client
Restart nut client:
$ systemctl restart nut-client |
Get Status of Nut Client
Get Status:
$ systemctl status nut-client |
● nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller
Loaded: loaded (/lib/systemd/system/nut-monitor.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-24 12:39:49 EDT; 2s ago
Process: 162230 ExecStart=/sbin/upsmon (code=exited, status=0/SUCCESS)
Main PID: 162234 (upsmon)
Tasks: 2 (limit: 19043)
Memory: 1.1M
CGroup: /system.slice/nut-monitor.service
├─162231 /lib/nut/upsmon
└─162234 /lib/nut/upsmon
Aug 24 12:39:49 deepthought systemd[1]: Starting Network UPS Tools - power device monitor and shutdown controller...
Aug 24 12:39:49 deepthought upsmon[162230]: fopen /run/nut/upsmon.pid: No such file or directory
Aug 24 12:39:49 deepthought upsmon[162230]: UPS: qnapups@192.168.1.60 (slave) (power value 1)
Aug 24 12:39:49 deepthought upsmon[162230]: Using power down flag file /etc/killpower
Aug 24 12:39:49 deepthought systemd[1]: nut-monitor.service: Can't open PID file /run/nut/upsmon.pid (yet?) after start: Operation not permi>
Aug 24 12:39:49 deepthought upsmon[162231]: Startup successful
Aug 24 12:39:49 deepthought systemd[1]: nut-monitor.service: Supervising process 162234 which is not our child. We'll most likely not notice>
Aug 24 12:39:49 deepthought systemd[1]: Started Network UPS Tools - power device monitor and shutdown controller. |
Check connection
Check Connection:
$ upsc qnapups@192.168.1.52 |
References