This post covers the steps I followed to get the Network UPS Tools project software, referred to as NUT for the rest of this post, running on one of my Gentoo machines in support of a CyberPower Systems OR1500LCDRT2U UPS. I am hoping the tasks below are repeatable for other UPS devices as I need to repeat the tasks below on a MintBox Mini 2 which is using another model of UPS.
Software Installation
I already installed the UPS in rack, connected it to my Gentoo machine via provided USB cable. A quick search on the Gentoo Wiki, turned up this guide to installing NUT which I used while installing and creating this post. The configurations below at time also draw heavily from NUT Introduction to Network UPS Tools Configuration Examples particularly with regard to heartbeat monitoring setup Chapter 6.
The NUT software is available through the Gentoo Portage system so I installed it in the usual way using emerge. I had already installed NUT before I thought to capture the command output. Output from the fresh install was similar to, but not exactly as below.
Configuration
Scan for UPS
Does NUT see the UPS? Seems that the answer is yes.
Add NUT User to USB Group
My UPS is attached to computer by USB cable, so nut user needs to be added to usb group for things to work properly.
NUT.CONF
The UPS is directly connected to this machine, and this is the machine where I am running NUT, so I am going to edit /etc/nut/nut.conf and set the mode to ‘'’standalone’’’ for now. I use Vim to edit things, but you can use any text editor to make changes to the files below.
FILE
/etc/nut/nut.conf
Setting
MODE=standalone
UPS.CONF
Create an /etc/nut/ups.conf describing the UPS and how to control it. Compatibility guidance here. Before making changes I backed up the example file by moving it to a new name. I then used the output of nut-scanner to create a base for the new file. Finally I opened the new file in my text editor, trimming out the noise and changing the name of the UPS device, until what I was left with was information in the table. The [heartbeat] section is from 6.1 of NUT Introduction to Network UPS Tools.
UPSD.USERS
At least one user needs to be configured for upsmon to launch. upsd creates a TCP connection which upsmon uses to check the status of the UPS. I set two accounts, one for upsmon to use, and an admin account to manage the UPS. I stripped all the comments from the example file and just left the entries as follows below.
UPSMON.CONF
This is the file which controls how monitoring of the UPS works. Edit it with a text editor to apply the setting you require. The provided example file is heavily commented, and what I wound up with below is essentially default, though I opted not to mess with certificates at this time. I will probably revisit that decision after I am happy things are working as I want, but for now I am using the values in the table below. Monitor dummy line from 6.3 of NUT Introduction to Network UPS Tools is for heartbeat monitoring.
UPSSCHED.CONF
This file is where operations are defined which will be carried out on the basis of upsmon findings as to the current conditions for the UPS. As above, so below. Edit with text editor to suit needed responses. My initial setup in table below is effectively direct transcription from Gentoo Wiki guide entry, then additions were made and some slight modifications as per 6.4 of NUT Introduction to support heartbeat checking.
Make path the store scheduling control files and make sure nut user can create and remove files in the directory.
UPSSCHED-CMD
This is the file which takes actions at the behest up upsmon. Change up as need with a text editor. Though not reflected in the code block bellow, I commented out the mail statements and added notify-send commands, which will let me see the action being invoked but not fill up my email in box whilst testing. The script below is heavily modified based on NUT Introduction to Network UPS Tools and my own needs.
Services
This is where I need to set aside the Gentoo Wiki guide on NUT. I have embraced Systemd as my init system and the rest of the guidance on the wiki is related to OpenRC managed services. Upon review of /lib/systemd/system, it does appear that some fairly basic systemd service files are installed for NUT. There are three files installed nut-server.service, nut-monitor.service, and nut-driver.service__. I enabled nut-server and nut-monitor, started nut-server which seems to take care of starting everything needed. Again the provided files are basic, but looks like they will do until I start trying to manage multiple UPS devices from the same system.
Testing
With the software now installed and working at least to a certain extent, it is time to test a fesw things, in preparation for the first pull the plug test.
Does NUT client see the UPS?
What can NUT client see about the UPS?
What might happen if power was lost?
Chrls is currently a technology transformation leader at one of the oldest American investment banking services holding companies, headquartered in New York City. Previous roles at current employer include project manager, front office support, retail and enterprise global Windows server support. Currently residing in Tennessee on the Cumberland Plateau and enjoying life, family and open source.