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.
Connect UPS using USP cable
$ sudo apt-get install nut |
Configure ups.conf
$ vi /etc/nut/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:
LISTEN 0.0.0.0 3493 |
Update Credentials
$ sudo vi /etc/nut/upsd.users |
[admin] password = 123456 actions = SET instcmds = ALL [upsmon] password = 123456 upsmon master [deepthought] password = 123456 upsmon slave |
Update Nut.Conf
$ sudo vi /etc/nut/nut.conf |
Set Mode=netserver
MODE=netserver |
UPSMON
$ vi /etc/nut/upsmon.conf |
Add the following line
MONITOR qnapups@localhost 1 upsmon 123456 master FINALDELAY 500 |
Here we are setting FINALDELAY to a very large value in an attempt to keep the master up until the battery is depleted. We are doing this to ensure that the low power consuming equipment (router, modem, raspberry pi) can run for as long as possible.
$ sudo upsdrvctl start |
$ sudo service nut-server restart |
$ 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 |
$ upsc qnapups@localhost $ upsc qnapups@192.168.1.52 battery.charge: 100 battery.charge.low: 10 ... ups.vendorid: 051d |
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 |
Install nut-client
$ sudo apt-get install nut-client |
Update nut-config
$ vi /etc/nut/nut.conf |
Set mode to netclient
MODE=netclient |
Update upsmon.conf
$ vi /etc/nut/upsmon.conf |
RUN_AS_USER root MONITOR qnapups@192.168.1.52 1 deepthought 123456 slave |
On our master we created a slave user called deepthought.
Restart nut client:
$ systemctl restart 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 Wed 2021-08-25 13:11:09 EDT; 2s ago Process: 376582 ExecStart=/sbin/upsmon (code=exited, status=0/SUCCESS) Main PID: 376585 (upsmon) Tasks: 2 (limit: 19043) Memory: 1.1M CGroup: /system.slice/nut-monitor.service ├─376583 /lib/nut/upsmon └─376585 /lib/nut/upsmon Aug 25 13:11:09 deepthought systemd[1]: Starting Network UPS Tools - power device monitor and shutdown controller... Aug 25 13:11:09 deepthought upsmon[376582]: fopen /run/nut/upsmon.pid: No such file or directory Aug 25 13:11:09 deepthought upsmon[376582]: Using power down flag file /etc/killpower Aug 25 13:11:09 deepthought upsmon[376582]: UPS: qnapups@192.168.1.52 (slave) (power value 1) Aug 25 13:11:09 deepthought systemd[1]: nut-monitor.service: Can't open PID file /run/nut/upsmon.pid (yet?) after start: Operati> Aug 25 13:11:09 deepthought upsmon[376583]: Startup successful Aug 25 13:11:09 deepthought systemd[1]: nut-monitor.service: Supervising process 376585 which is not our child. We'll most likel> Aug 25 13:11:09 deepthought systemd[1]: Started Network UPS Tools - power device monitor and shutdown controller. |
Check Connection:
$ upsc qnapups@192.168.1.52 |
Reference | URL |
---|---|
UPSMON Man Page | https://networkupstools.org/docs/man/upsmon.conf.html |
NUT Introduction to Network UPS Tools - Configuration Examples | http://rogerprice.org/NUT/ConfigExamples.A5.pdf |
Raspberry Pi Home Server v2: Network UPS Tools | https://melgrubb.com/2016/12/11/rphs-v2-ups/ |