From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Fco Javier Felix <ffelix@inode64.com>
Date: Wed, 11 Nov 2026 17:20:00 +0100
Subject: [PATCH] drivers/mge-mib.c: also read the input line cells published
 as scalars

Some agents publish upsmgInputVoltage and upsmgInputFrequency of the
single input line with a ".0" appended to the row index
(.1.3.6.1.4.1.705.1.6.2.1.2.1.0 and .1.3.6.1.4.1.705.1.6.2.1.3.1.0), as
if the table cells were scalars, and answer noSuchName for the instance
that the MIB defines. An Eaton 9SX 5000i (firmware 02.20.0042, agent
"Network Management Card V6.00 JL") does, so input.voltage and
input.frequency were never published for it, while its output table
uses the regular index.

Read those two instances as well. Whichever instance does not answer
is disabled at startup, and the regular entry stays last so that it
wins on an agent answering both.

Bump MGE_MIB_VERSION to 0.57.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
Upstream: proposed to NUT from branch snmp-ups-mge-input-scalar-instance of github.com/inode64/nut.
Overlay copy of that commit without its NEWS.adoc and docs/nut.dict hunks.

 drivers/mge-mib.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mge-mib.c b/drivers/mge-mib.c
index 8895f6d88..1a6e9b062 100644
--- a/drivers/mge-mib.c
+++ b/drivers/mge-mib.c
@@ -27,7 +27,7 @@
 
 #include "mge-mib.h"
 
-#define MGE_MIB_VERSION	"0.56"
+#define MGE_MIB_VERSION	"0.57"
 
 /* TODO:
  * - MGE PDU MIB and sysOID (".1.3.6.1.4.1.705.2") */
@@ -205,10 +205,18 @@ static snmp_info_t mge_mib[] = {
 
 	/* Input page */
 	snmp_info_default("input.phases", 0, 1.0, ".1.3.6.1.4.1.705.1.6.1.0", "", 0, NULL),
+	/* Some agents (an Eaton 9SX 5000i, firmware 02.20.0042, for one) publish
+	 * the voltage and frequency cells of the single input line with a ".0"
+	 * appended to the row index, as if they were scalars, and do not answer
+	 * the instance the MIB defines. The ".0" entries come first so that an
+	 * agent answering both still publishes the MIB instance, read last; the
+	 * one that does not answer is disabled at startup. */
+	snmp_info_default("input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1.0", "", SU_INPUT_1, NULL),
 	snmp_info_default("input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_1, NULL),
 	snmp_info_default("input.L1-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L2-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.2", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L3-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.3", "", SU_INPUT_3, NULL),
+	snmp_info_default("input.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.1.0", "", SU_INPUT_1, NULL),
 	snmp_info_default("input.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.1", "", SU_INPUT_1, NULL),
 	snmp_info_default("input.L1.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.1", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L2.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.2", "", SU_INPUT_3, NULL),
