In part 1, I installed the nut package, and did my first edits to nut.conf and ups.conf in /etc/ups.
I decide to also set up the web status (on localhost), so I pull in two more packages.
su dnf install httpd dnf install nut-cgi systemctl start httpd.serviceThat's correct. I have never before run a web server on my home machine. I do get the Fedora webserver test page, so I am off to a decent start.
Note that the location "/etc/ups" is unique to Fedora and is where all the NUT configuration files are. Standard documentation would put these files in /etc/nut This hints of other undocumented Fedora tweaking that will need to be discovered.
After that I got into trouble. Some searching led me to this:
The preview of Techno Tims video showed the familiar display from the front of my CyberPower unit (wrong! See below). And the Fedora guide thanked him, so I probably ought to watch his video.
I had to remind myself that "t" puts youtube into "theater mode", so I get less distracted and annoyed by all of the videos I might possibly be interested in, displayed on the right. He works with an APC UPS -- and the display does look a lot like my CyberPower (I was fooled).
First, I note that he and other talk about their "home lab", which is a label I find interesting. He has several (three) UPS units, and a strategy that keeps his network gear powered up longer than his servers. He in fact does run NUT on a raspberry pi. He doesn't want NUT to be running on one of his servers that will be getting shut down. His raspberry pi is powered via POE.
Fedora does not have a separate nut-server package -- but nut-client is separate, but gets pulled in when you install "nut".
The Fedora guide says that there are 8 files you need to edit.
Here are my notes on each of them as I follow along in the video.
The video only discusses 5 of the 8. Notes on the others are from
the Fedora guide.
On Fedora these files are all in /etc/ups.
He adds these 2 lines to ups.conf
pollinterval = 1 maxretry = 3Maxretry was already set to 3 and pollinterval defaults to 2, so we are changing that. He includes the vendor and product ID -- which may be essential if you have several devices. I go ahead and add these to mine even though I have only one UPS device. The scanner also gave me a serial number, so I add this as well.
MONITOR cyberpower@localhost 1 homer axehelve masterHere "home" and "axehelve" are set up in upsd.users
Note: It is not clear if we want "homer" or "admin" here.
He also sets "RUN_AS_USER root" -- otherwise nut will use a special user of some sort with a variety of permission issues. I see that installing the Fedora packages created a "nut" user. (In addition, installing httpd created an "apache" user.)
[homer]
password = axehelve
admin master
I don't understand "admin master", I just copy techno tim here. He says there is
plenty of documentation that you can go find and read about this.
LISTEN 127.0.0.1 3493 #LISTEN 0.0.0.0 3493
MONITOR cyberpower@localhost "Local CyberPower UPS"
I_HAVE_SECURED_MY_CGI_DIRECTORY
ScriptAlias /nut-cgi-bin/ β/var/www/nut-cgi-bin/βYes, the nut-cgi-bin directory exists.AllowOverride None Options None Order allow,deny Allow from all
su firewall-cmd --add-service=nut firewall-cmd --add-service=http firewall-cmd --runtime-to-permanent
su systemctl restart nut-server.service #systemctl restart nut-client.service systemctl restart nut-monitor.service #upsdrvctl stop #upsdrvctl start #systemctl restart nut-driver.serviceFedora tells me there is no service for nut-client, even though I installed that package. It also scolds me for running upsdrvctl directly, claiming it will conflict with nut-driver.service, but there is no such thing. A peek at /usr/lib/systemd/system shows me all these:
nut-driver-enumerator-daemon-activator.path nut-driver-enumerator-daemon-activator.service nut-driver-enumerator-daemon.service nut-driver-enumerator.path nut-driver-enumerator.service nut-driver@.service nut-driver.target nut-logger.service nut-monitor.service nut-server.service nut.target nut-udev-settle.serviceWow! Maybe rebooting would be a good idea. It seems a pity, and I will lose my place in the video, but I go ahead and reboot. I use "ps" to look for nut processes and don't see any, which is worrisome.
As of Fedora 42, the rumor is that you only need to do this, but on my Fedora 44 system, there ain't no such thing!
systemctl enable nut-targetThe above should work (but doesn't) I type this command:
systemctl list-unit-files | grep nut. nut-driver-enumerator-daemon-activator.path disabled disabled nut-driver-enumerator.path disabled disabled nut-driver-enumerator-daemon-activator.service static - nut-driver-enumerator-daemon.service disabled disabled nut-driver-enumerator.service enabled disabled nut-driver@.service indirect disabled nut-logger.service disabled disabled nut-monitor.service enabled disabled nut-server.service enabled disabled nut-udev-settle.service static - nut-driver.target disabled disabled nut.target disabled disabledI don't know what is going on, so I did this:
su systemctl enable --now nut-driver-enumerator.service systemctl enable --now nut-server.service systemctl enable --now nut-monitor.service systemctl enable --now httpd.serviceI wait a bit and check these with:
systemctl status nut-driver-enumerator.service systemctl status nut-server.service systemctl status nut-monitor.service systemctl status httpd.serviceThese all look good. It looks like the enumerator service runs once then exits.
Among many other things it shows:
battery.charge: 100 battery.runtime: 5150 battery.status: 100% battery.voltage: 27.2 battery.voltage.nominal: 24 ups.load: 7 ups.power: 77 ups.power.nominal: 1500 ups.realpower: 78
journalctl -u nut-monitorTo trigger a forced shutdown without actually pulling the power cord, you can do this:
upsmon -c fsdThe log file mentions a file /etc/killpower, but there is no such file on my system.
Upsmon will directly issue system commands to produce a shutdown. There is no separate shutdown script. Everything is configured in upsmon.conf.
Note that there is a file /usr/lib/systemd/system-shutdown/nutshutdown
I check this address in a browser:
http://localhost/nut-cgi-bin/upsstats.cgiIt gives me a 403 permission error.
I tried a variety of things. Then I edited /etc/.../httpd.conf and added +ExecCGI to this section:
In that file, I also uncommented this line:AllowOverride None Options +ExecCGI Require all granted
AddHandler cgi-script .cgiThen I copied the files in /var/www/nut-cgi-bin to /var/www/cgi-bin
service httpd restartAnd now the CGI scripts work at these URL:
http://localhost/cgi-bin/upsstats.cgi http://localhost/cgi-bin/upsimage.cgi http://localhost/cgi-bin/upsset.cgiOnly "upsstats" is interesting.
Each of these is an ELF file (compiled executable).