Network UPS Tools (nut) setup

I am in need of help in getting “nut” set up in Rocky 8, trying with pretty much the same config setting that were working with these same UPSs in CentOS 6.

Killer #1: nut-server can’t connect with either UPS. upsd complains,
“Can’t connect to UPS [Cyber-2] (usbhid-ups-Cyber-2): No such file or directory”, and
Can’t connect to UPS [Cyber-1] (usbhid-ups-Cyber-1): No such file or directory".
But, when I run usbhid-ups manually with the same port, vendorid, and productid arguments that are in the /etc/ups/ups.conf file, it finds the devices just fine and sets up the sockets in /run (with the wrong SELinux context since I ran the command from unconfined_t, and nut_ups_t isn’t allowed to connect to it).

Killer #2:

Solved -- needs network-online.target

nut-server cannot listen on my LAN address. It only connects to my loopback address. I get the messages:
“nut-server[1492]: not listening on 192.168.43.1 port 3493”, and
“upsd[1492]: not listening on 192.168.43.1 port 3493”.
I’ve tried copying /usr/lib/systemd/system/nut-server.service to /etc/systemd/system/ and adding “After=network.target” in the [Unit] section, but to no avail.

This can’t be that hard. Lest this message become tl;dr, I’ll post a separate message with all the changes I’ve made in the supplied /etc/ups/ config files.

As promised, here are the changes from nut-2.8.0-3.el8.x86_64:

t--- hosts.conf.orig	2022-04-23 06:56:06.000000000 -0500
+++ hosts.conf	2023-02-17 21:59:46.670388101 -0600
@@ -27,3 +27,6 @@
 # MONITOR myups@localhost "Local UPS"
 # MONITOR su2200@10.64.1.1 "Finance department"
 # MONITOR matrix@shs-server.example.edu "Sierra High School data room #1"
+
+MONITOR Cyber-1 "System Power"
+MONITOR Cyber-2 "Phones"
--- nut.conf.orig	2022-04-23 06:56:06.000000000 -0500
+++ nut.conf	2023-02-17 22:02:16.733554371 -0600
@@ -30,7 +30,7 @@
 #  there is no guaranteed `export VAR=VAL` syntax) and by systemd on Linux.
 #  You MUST NOT use spaces around the equal sign!
 
-MODE=none
+MODE=netserver
 
 # Uncomment this to allow starting the service even if ups.conf has no device
 # sections at the moment. This environment variable overrides the built-in
--- ups.conf.orig	2022-04-26 17:03:31.000000000 -0500
+++ ups.conf	2023-02-17 22:11:49.882026935 -0600
@@ -200,3 +200,17 @@
 #
 # To find out if your driver supports any extra settings, start it with
 # the -h option and/or read the driver's documentation.
+
+[Cyber-1]
+	driver=usbhid-ups
+	port=auto
+	vendorid=0764
+	productid=0601
+	product=CP1500PFCLCDa
+
+[Cyber-2]
+	driver=usbhid-ups
+	port=auto
+	vendorid=0764
+	productid=0501
+	product=CRCA102.AF1
--- upsd.conf.orig	2022-04-23 06:56:07.000000000 -0500
+++ upsd.conf	2023-02-18 16:12:30.734138055 -0600
@@ -54,6 +54,8 @@
 # =======================================================================
 # LISTEN <IP address or name> [<port>]
 # LISTEN 127.0.0.1 3493
+LISTEN 127.0.0.1 3493
+#LISTEN omega-3x 3493
 # LISTEN ::1 3493
 # LISTEN myhostname 83493
 # LISTEN myhostname.mydomain
--- upsd.users.orig	2022-04-23 06:56:07.000000000 -0500
+++ upsd.users	2023-02-17 22:20:32.673485979 -0600
@@ -73,3 +73,10 @@
 #
 # See comments in the upsmon.conf(.sample) file for details about this
 # keyword and the difference of NUT secondary and primary systems.
+
+[xxxxxx]
+    password = xxxxxx
+    actions = SET
+    instcmds = beeper.disable beeper.enable beeper.mute \
+    	 test.battery.start.deep test.battery.start.quick test.battery.stop
+    upsmon master
--- upsmon.conf.orig	2022-12-12 16:16:52.000000000 -0600
+++ upsmon.conf	2023-02-17 22:30:55.193186185 -0600
@@ -115,6 +115,8 @@
 # MONITOR myups@bigserver 1 upswired blah primary
 # MONITOR su700@server.example.com 1 upsmon secretpass secondary
 # MONITOR myups@localhost 1 upsmon pass primary	# (or secondary)
+MONITOR Cyber-1 1 xxxxxx xxxxxx primary
+MONITOR Cyber-2 0 xxxxxx xxxxxx primary
 
 # --------------------------------------------------------------------------
 # MINSUPPLIES <num>
--- upsset.conf.orig	2022-04-23 06:56:07.000000000 -0500
+++ upsset.conf	2023-02-17 22:47:09.261762889 -0600
@@ -32,5 +32,5 @@
 #
 
 ###
-### I_HAVE_SECURED_MY_CGI_DIRECTORY
+I_HAVE_SECURED_MY_CGI_DIRECTORY
 ###

Anyone with a similar issue might want to connect with this bug report.

I just finished up on a Cacti UPS plugin called apcupsd that will monitor and chart various UPS’. Not quite released yet though. Maybe this week. I was looking at adding NUT support, but the new release is not in many distros yet.

After much discussion with the developer, I finally found the answer. It is necessary to run
systemctl enable nut-driver-enumerator.service
in addition to enabling nut.target. An alternative is to manually run
systemctl start nut-driver-enumerator.service
initially, and whenever there is a change in the set of configured devices.

There is no hint in the supplied documentation that this step is needed. In fact, the documentation indicates that the enumerator is run automatically.

Anyone with masochistic tendencies is invited to review the above-linked bug report.

TheWitness " I was looking at adding NUT support, but the new release is not in many distros yet."

Please release!

We’ve released it today. There are still a number of features that we will introduce, but you can test drive it from here.

I stepped on a hoe.
I have to wait before returning information.
For now I’m waiting for released cacti-1.2.24.el8.noarch.rpm

Plugin Management:
[Apcupsd] UPS Monitor Plugin for Cacti Not Compatible, Requires: Cacti >= 1.2.24 The Cacti Group 1.0

My cacti version: Version 1.2.23

cat /etc/redhat-release
Rocky Linux release 8.7 (Green Obsidian)

rpm -qa | grep cacti
cacti-spine-1.2.23-1.el8.x86_64
cacti-1.2.23-1.el8.noarch

Cacti is instaled from rpm.

Just edit the INFO file and switch it to 1.2.23. It should work.

INFO file edited.
Plug-in installed and Activated.
Template imported.
Issue is missing table apcupsd_ups in to DB
Log
CMDPHP ERROR: A DB Cell Failed!, Error: Table ‘cacti.apcupsd_ups’ doesn’t exist
CMDPHP SQL Backtrace: (/script_server.php[293]:ss_upsd(), /var/lib/cacti/scripts/ss_upsd.php[67]:db_fetch_cell_prepared(), /lib/database.php[568]:db_execute_prepared())

Exist only table apcupsd_ups_stats
Any hint?

Try to reinstall the plugin the immediately look for a SQL error in the cacti.log

From Configuration → Plugins → Plugin Management
Disable Plugin
Uninstall Plugin
Log => Purge
I’m waiting for the next check
Check Log
All OK !
From Configuration → Plugins → Plugin Management
Install Plugin
Activate Plugin
Iimmediately look Log for error:

CMDPHP ERROR: A DB Exec Failed!, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘unsigned NOT NULL DEFAULT 2000, status int(10) unsigned NOT NULL DEFAULT 0,…’ at line 1

CMDPHP SQL Backtrace: (/plugins.php[78]:api_plugin_install(), /lib/plugins.php[733]:plugin_apcupsd_install(), /plugins/apcupsd/setup.php[37]:apcupsd_setup_table(), /plugins/apcupsd/setup.php[99]:db_execute(), /lib/database.php[355]:db_execute_prepared())

Look again:
MariaDB [cacti]> show tables;
. . . . .
apcupsd_ups_stats
. . . . .

Only apcupsd_ups_stats table exist.

It’s fixed in GitHub now.

Setup is OK. Work!

Cacti host:
locate apcaccess
/usr/sbin/apcaccess
From console# apcaccess -h remoute_host:port

APC : 001,037,0956
DATE : 2023-03-02 17:39:28
. . . . .
END APC : 2023-03-02 17:39:29

Return status UPS, but Cacti reported in to section UPSes: DOWN

Any hint?

Post a screen shot of your setup UPSes page. Any errors in the Cacti Log?

Also post the full output of the apcaccess.

No errors in the Cacti Log.

[root@monit:~] apcaccess -h remoute_host:3551

APC : 001,036,0878
DATE : 2023-03-03 09:05:01
HOSTNAME : host
VERSION : 3.14.14 (31 May 2016) redhat
UPSNAME : test-ups
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2023-03-02 17:21:20
MODEL : Back-UPS RS 1500G
STATUS : ONLINE
LINEV : 233.0 Volts
LOADPCT : 6.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 376.8 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : High
LOTRANS : 175.0 Volts
HITRANS : 288.0 Volts
ALARMDEL : 30 Seconds
BATTV : 27.4 Volts
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : 4B1817P37365
BATTDATE : 2021-11-29
NOMINV : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 865 Watts
FIRMWARE : 878.L5 .I USB FW:L5
END APC : 2023-03-03 09:05:03

That all looks right. Can you check your cacti log and verify that the pollers are running? Also you can go to the Consoleband then to Configuration an Plugins and ensure that the plugin is not only installed but it’s enabled.

Check, check and check.
All right. Status - DOWN.
For now I’m waiting for released cacti-1.2.24.el8.noarch.rpm

Should not be too long. Cacti is real easy to deploy these days. For rookies, you just have to take your time.