[HOW TO] Set up NUT netclient mode on your TNAS to monitor a UPS
Posted: 21 Jul 2021, 01:40
Background
After recently buying a UPS and learning about the possibilities with NUT, I quickly began going insane trying to configure the TNAS to run as either:
If you're unsure how to set up the netserver, here's the guide I followed to set it up with multiple raspberry pis. Though in my case I used a raspberry pi as the netserver, and an OPNsense router as the netclient.
This would be much easier if there was a text editor in TNAS' linux install, but alas, nano and other text editors I know of are missing. So I copy the config files to a network share and then edit them from my laptop.
It would be easier again if Terra-Master provided these options in the web GUI UPS section.
I use PuTTY for SSH, and Notepad++ to edit the config files.
DO THIS AT YOUR OWN RISK
Prerequisites
1. Log in as admin via SSH
2. Elevate to super user
3. Copy the required config files to a location you can access from your PC/Mac
4. Rename the original config files to retain a backup
5. Change permissions on the config files so you can edit them
6. Open nut.conf and upsmon.conf in your text editor of choice
7. Update nut.conf
The second last line needs to be set to the right value (netclient). Mine was line 32, ymmv
Before:
After:
Save and close the file
8. Update upsmon.conf
Here you'll set the UPS name, netserver address, netclient username and password, and role of the TNAS as a slave.
Mine was line 88, ymmv
Before:
After:
eg.
Save and close the file
9. Copy the updated config files to /etc
10. Revert permissions on the config files
11. Reboot your TNAS
That's it!
When I turn off power to the UPS at the wall socket, the TNAS goes into hibernation/safe mode within a few seconds.
When I turn power back on to the UPS, the TNAS boots up within a few seconds.
Amazingly, my TNAS now reports that a UPS is connected: And weirdly, the UPS web GUI page says it's configured as a TNAS UPS server:
After recently buying a UPS and learning about the possibilities with NUT, I quickly began going insane trying to configure the TNAS to run as either:
- The netserver, or;
- A netclient
If you're unsure how to set up the netserver, here's the guide I followed to set it up with multiple raspberry pis. Though in my case I used a raspberry pi as the netserver, and an OPNsense router as the netclient.
This would be much easier if there was a text editor in TNAS' linux install, but alas, nano and other text editors I know of are missing. So I copy the config files to a network share and then edit them from my laptop.
It would be easier again if Terra-Master provided these options in the web GUI UPS section.
I use PuTTY for SSH, and Notepad++ to edit the config files.
DO THIS AT YOUR OWN RISK
Prerequisites
- A device on the same network set up as a NUT netserver
- IP address of the netserver
- UPS name on the netserver
- Username and password for the netclient
1. Log in as admin via SSH
2. Elevate to super user
Code: Select all
sudo suCode: Select all
cp /etc/nut.conf /mnt/md0/<NETWORK-SHARE>/
cp /etc/upsmon.conf /mnt/md0/<NETWORK-SHARE>/Code: Select all
mv /etc/nut.conf /etc/nut-old.conf
mv /etc/upsmon.conf /etc/upsmon-old.confCode: Select all
chmod 777 /mnt/md0/<NETWORK-SHARE>/nut.conf
chmod 777 /mnt/md0/<NETWORK-SHARE>/upsmon.conf7. Update nut.conf
The second last line needs to be set to the right value (netclient). Mine was line 32, ymmv
Before:
Code: Select all
MODE=netserverCode: Select all
MODE=netclient8. Update upsmon.conf
Here you'll set the UPS name, netserver address, netclient username and password, and role of the TNAS as a slave.
Mine was line 88, ymmv
Before:
Code: Select all
MONITOR ups@localhost 1 monuser secret masterCode: Select all
MONITOR <UPS-NAME>@<IP-ADDRESS-OF-NETSERVER> 1 <NETCLIENT-USERNAME> <NETCLIENT-PASSWORD> slaveCode: Select all
MONITOR [email protected] 1 clientusername clientpassword slave9. Copy the updated config files to /etc
Code: Select all
cp /mnt/md0/<NETWORK-SHARE>/nut.conf /etc/
cp /mnt/md0/<NETWORK-SHARE>/upsmon.conf /etc/Code: Select all
chmod 644 /etc/nut.conf
chmod 644 /etc/upsmon.confCode: Select all
rebootWhen I turn off power to the UPS at the wall socket, the TNAS goes into hibernation/safe mode within a few seconds.
When I turn power back on to the UPS, the TNAS boots up within a few seconds.
Amazingly, my TNAS now reports that a UPS is connected: And weirdly, the UPS web GUI page says it's configured as a TNAS UPS server: