Skip to content

drivers/ietf-mib.c: read UPS-MIB line tables indexed from 0, ignore zero ratings - #3872

Open
inode64 wants to merge 3 commits into
networkupstools:masterfrom
inode64:snmp-ups-ietf-zero-index
Open

inode64 wants to merge 3 commits into
networkupstools:masterfrom
inode64:snmp-ups-ietf-zero-index

Conversation

@inode64

@inode64 inode64 commented Nov 27, 2026 •

Copy link
Copy Markdown

Problem

An "RTCS version 03.02.00" SNMP card on a SRVPM6KRI UPS (snmp-ups, which
picks the ietf_mib table for it and reports it as tripplite) published no
single-phase line readings at all: no input.voltage, input.frequency,
output.voltage, output.current, ups.load or input.bypass.voltage.
It also published 0 for every rating and transfer point it does not
implement.

Two causes, one commit each:

  1. The card numbers the rows of upsInputTable, upsOutputTable and
    upsBypassTable from 0 instead of 1. RFC 1628 starts the line index at 1,
    and ietf-mib.c asks for .1, which this agent does not answer.
  2. It returns 0 for the upsConfig objects it does not implement, so the
    driver published input.voltage.nominal: 0, input.frequency.nominal: 0,
    output.voltage.nominal: 0, output.frequency.nominal: 0,
    output.realpower.nominal: 0, input.transfer.low: 0 and
    input.transfer.high: 0. Only upsConfigOutputVA (6000) is real.

Device

  • UPS: SRVPM6KRI, upsIdentUPSSoftwareVersion 456.00DT.I, single phase
  • Card: sysDescr "RTCS version 03.02.00", upsIdentAgentSoftwareVersion
    1.0, sysObjectID .0.0 (so no vendor MIB is matched)
  • SNMP v1

Evidence

The line tables answer at index .0 only:

.1.3.6.1.2.1.33.1.3.3.1.2.0 = INTEGER: 499     upsInputFrequency
.1.3.6.1.2.1.33.1.3.3.1.3.0 = INTEGER: 234     upsInputVoltage
.1.3.6.1.2.1.33.1.3.3.1.4.0 = INTEGER: 0       upsInputCurrent
.1.3.6.1.2.1.33.1.3.3.1.5.0 = INTEGER: 0       upsInputTruePower
.1.3.6.1.2.1.33.1.4.4.1.2.0 = INTEGER: 229     upsOutputVoltage
.1.3.6.1.2.1.33.1.4.4.1.3.0 = INTEGER: 14      upsOutputCurrent
.1.3.6.1.2.1.33.1.4.4.1.4.0 = INTEGER: 0       upsOutputPower
.1.3.6.1.2.1.33.1.4.4.1.5.0 = INTEGER: 2       upsOutputPercentLoad
.1.3.6.1.2.1.33.1.5.3.1.2.0 = INTEGER: 234     upsBypassVoltage
.1.3.6.1.2.1.33.1.5.3.1.3.0 = INTEGER: 0       upsBypassCurrent
.1.3.6.1.2.1.33.1.5.3.1.4.0 = INTEGER: 0       upsBypassPower

and the configuration group returns 0 for everything but the VA rating:

.1.3.6.1.2.1.33.1.9.1.0 = INTEGER: 0           upsConfigInputVoltage
.1.3.6.1.2.1.33.1.9.2.0 = INTEGER: 0           upsConfigInputFreq
.1.3.6.1.2.1.33.1.9.3.0 = INTEGER: 0           upsConfigOutputVoltage
.1.3.6.1.2.1.33.1.9.4.0 = INTEGER: 0           upsConfigOutputFreq
.1.3.6.1.2.1.33.1.9.5.0 = INTEGER: 6000        upsConfigOutputVA
.1.3.6.1.2.1.33.1.9.6.0 = INTEGER: 0           upsConfigOutputPower
.1.3.6.1.2.1.33.1.9.7.0 = INTEGER: 0           upsConfigLowBattTime
.1.3.6.1.2.1.33.1.9.9.0 = INTEGER: 0           upsConfigLowVoltageTransferPoint
.1.3.6.1.2.1.33.1.9.10.0 = INTEGER: 0          upsConfigHighVoltageTransferPoint

The card does not measure input current, input power or output power either:
those cells are always 0.

Change

drivers/ietf-mib.c, three commits:

  1. Line tables indexed from 0 (IETF_MIB_VERSION 1.56). Each of the 11
    single-phase entries (SU_INPUT_1, SU_OUTPUT_1, SU_BYPASS_1) gets a
    copy at .0, placed before it.
    • On an RFC 1628 agent the .0 copy fails on the initial walk and
      snmp-ups disables it ("Disabling var"): one extra GET per entry at
      startup. On this card the .1 entries are disabled the same way.
    • The .1 entry stays last, so an agent answering both publishes the RFC
      instance.
    • The .0 copies keep their zeros, like the .1 entries. This card
      publishes input.current, input.realpower and output.realpower as
      0, since it does not measure them (see the third commit).
  2. Zero ratings and transfer points (IETF_MIB_VERSION 1.57).
    SU_FLAG_ZEROINVALID for the six ratings and the two voltage transfer
    points, as voltronic-mib.c already does for its ratings. A UPS cannot be
    rated for 0 V, 0 Hz, 0 VA or 0 W, nor transfer at 0 V.
    upsConfigLowBattTime keeps its zero, which can be a real setting.
  3. Zero live readings kept (IETF_MIB_VERSION 1.58), from review. The
    first commit used to flag the .0 copies of input.current,
    input.realpower and output.realpower with SU_FLAG_ZEROINVALID. The
    first 0 then disabled the entry until the driver restarted, so a
    published value stayed frozen and one that started at 0 never appeared.
    The flag is dropped from those three. The card above cannot be
    identified reliably (sysObjectID .0.0, generic sysDescr), so the
    filter is not kept as a device quirk either.

NEWS.adoc gets one bullet per commit under "snmp-ups driver updates",
and docs/nut.dict the new words (RTCS, SRVPM, KRI, upsConfig).

SU_FLAG_ZEROINVALID disables an entry on its first 0 until the driver
restarts (snmp-ups.c, su_ups_get()), so it is only used for the static
ratings and transfer points, never for a live reading.

Not addressed: this card reports upsEstimatedMinutesRemaining = 65535 as
"unknown", which becomes battery.runtime: 3932100. snmp-ups has no flag
for sentinel values, so that would need a core change.

Testing on real hardware

Tested and verified against the real SRVPM6KRI UPS described above.

  • Before (stock NUT, git 1c4ab78c6, tripplite MIB 1.55): no
    input.voltage, input.frequency, input.current, input.realpower,
    output.voltage, output.current, output.realpower, ups.load,
    input.bypass.voltage, input.bypass.current or input.bypass.realpower;
    and the seven zero ratings and transfer points listed above.
  • First commit, dump mode next to the production driver: those 11
    variables appear (input.voltage 228, input.frequency 49.90,
    output.voltage 228, output.current 1.40, ups.load 2,
    input.bypass.voltage 228, the rest 0) and none is lost.
  • Second commit: the zero ratings, the two zero transfer points and the
    three unmeasured zeros go away (53 to 43 variables); nothing else changes.
  • Third commit: input.current, input.realpower and
    output.realpower are published again, as 0 on this card, as in the
    first-commit run. Not yet re-run on the hardware; make check passes
    (--with-snmp).
  • In production since 2026-11-09, with both commits on top of
    1c4ab78c6, on that UPS, and since 2026-11-27 on top of master
    (984c382c1), installed from the build described next.
  • 2026-11-27, this branch's code: built on the host of each UPS from our Gentoo ebuild
    (sys-power/nut-9999, see below): NUT master at 984c382c1 with the
    overlay patches (this PR, drivers/eaton-ups-pwnm2-mib.c: read xupsBypassVoltage.1, add the transfer points #3873 and drivers/mge-mib.c: also read the input line cells published as scalars #3874), compiled there (each host its own binary), not installed, and run
    once in dump mode next to the production driver
    (snmp-ups -s test -x port=... -u root -d 1, plus a -DDDD run to list
    the entries disabled at startup).
    Result: the same variables as the production driver, none lost or added;
    input.voltage 233, input.frequency 50, output.voltage 229,
    output.current 1.50, ups.load 3, input.bypass.voltage 233,
    output.power.nominal 6000, ups.status OL. With -DDDD, each .1
    instance and each zero-valued entry shows up once as "Disabling var".
  • RFC 1628 agents: run with mibs=ietf against two Eaton cards that
    number the lines from 1 (the devices of drivers/eaton-ups-pwnm2-mib.c: read xupsBypassVoltage.1, add the transfer points #3873). Each .0 entry gets one GET at startup and is disabled,
    the .1 values are published, and the non-zero ratings (220 V, 50 Hz,
    6000 VA, 6000 W) and transfer points (100 and 276 V) are kept.

Local checks, on Gentoo Linux x86_64 (gcc 16.2.1, Net-SNMP 5.9.5.2), with the
three related branches applied together on master (984c382c1):
make check, make spellcheck and make distcheck-light pass, and the
added lines are plain ASCII (git diff --check clean).

Our overlay

These patches are also carried in our public Gentoo overlay,
https://github.com/inode64/inode64-overlay (sys-power/nut/files/, applied
by sys-power/nut-9999), which several of our servers use to build NUT.
This pair has been in production on the host with this UPS since
2026-11-09.
Since 2026-11-27 all our servers with a UPS run that build (NUT master
984c382c1 with the patches of this PR, #3873 and #3874), with USB,
serial and SNMP drivers: usbhid-ups, nutdrv_qx, apcmicrolink, and
snmp-ups with the apcc, eaton_pw_nm2, ietf and mge subdrivers. No
variable was lost on any of them, except an input.transfer.reason that
usbhid-ups no longer reports on one host upgraded from NUT 2.8.2, which is
unrelated to these patches.
We will drop them from the overlay once this is merged.

AI disclosure

The analysis, the patches and this text were prepared with Claude Code
(model: Claude Opus 5.5) under my direction; the commits carry a
Co-Authored-By trailer for it. I reviewed and signed off each commit. The
SNMP data and the test output above come from the real devices.

Checklist

  • Described the changes, the hardware they were developed and tested
    against, and the limitations.
  • Three commits: one per functional change, plus the review fix.
  • Use of AI disclosed (above).
  • Code and docs follow the NUT style; plain ASCII in C sources and
    AsciiDoc.
  • Existing driver family: subdriver of snmp-ups, no obsolete driver
    extended.
  • IETF_MIB_VERSION bumped (1.55 to 1.56, 1.57 and 1.58).
  • Data mapping aligned with docs/nut-names.txt: no new variable names.
  • data/driver.list.in: not changed, the devices are covered by the
    existing snmp-ups entries.
  • Bullet added to NEWS.adoc; nothing for UPGRADING.adoc.
  • Passed make spellcheck; added RTCS, SRVPM, KRI and upsConfig to docs/nut.dict.
  • make distcheck-light passes locally.
  • NUT DDL dumps: can follow up if useful.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Preparing a ZIP file with standard source tarball and another tarball with pre-built docs for commit bfcf4e2 ...

inode64 and others added 2 commits November 29, 2026 14:29
Some RFC 1628 agents (an RTCS 03.02.00 card, for one) number the
upsInputTable, upsOutputTable and upsBypassTable rows from 0 instead
of 1, so the single-phase voltages, currents, powers and load were
never published. Read index .0 as well. Whichever instance does not
answer is disabled at startup, and the .1 entry stays last so that it
wins on an agent answering both.

That card returns 0 for the input current, input power and output
power, which it does not measure, so those three .0 entries treat 0
as invalid. The bypass current and power keep their zeros: 0 is the
normal reading while the load runs on the inverter.

Bump IETF_MIB_VERSION to 1.56.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fco Javier Felix <ffelix@inode64.com>
A UPS cannot be rated for 0 V, 0 Hz, 0 VA or 0 W, nor transfer to
battery at 0 V, yet some agents (an RTCS 03.02.00 card, for one)
return 0 for the upsConfig objects they do not implement, so the
driver published input.voltage.nominal: 0, input.transfer.low: 0 and
the like. Treat 0 as invalid for the six ratings and the two voltage
transfer points, as voltronic-mib.c does for its ratings and transfer
limits. upsConfigLowBattTime keeps its zero, which can be a real
setting.

Bump IETF_MIB_VERSION to 1.57.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fco Javier Felix <ffelix@inode64.com>
@inode64
inode64 force-pushed the snmp-ups-ietf-zero-index branch from 9b97947 to 130fae2 Compare November 29, 2026 14:23
@github-actions github-actions Bot deleted a comment from AppVeyorBot Nov 29, 2026
@user01010111

Copy link
Copy Markdown
Contributor

I reproduced the zero-handling limitation described in the PR on 130fae2967 with a loopback SNMP fixture and the real snmp-ups → upsd → upsc path. On a single-phase agent whose measurements are available only at index 0, I sent input.current 1.70 A → 0 → 2.90 A, input.realpower 345 W → 0 → 567 W and output.realpower 300 W → 0 → 500 W. upsc kept showing 1.70 A, 345 W and 300 W through two recovery polls, and the driver made no more GETs for those cells. When it started at zero, all three variables stayed absent after positive readings became available. The output-current and bypass readings displayed zero and recovered in the same process. Index 1 still took precedence when both instances responded, and the RTCS-like zero ratings were suppressed while 6000 VA and a zero low-battery time were retained.

Could we keep the index-0 fallback and static-rating filtering, and allow zero on these three live readings by default? If the fixed-zero cells need hiding on the reported RTCS firmware, could we bound that to a reliably identified device or firmware quirk? The reproduction is synthetic and uses both ietf and tripplite selectors.

@github-actions github-actions Bot deleted a comment from AppVeyorBot Dec 1, 2026
SU_FLAG_ZEROINVALID on the .0 copies of input.current, input.realpower
and output.realpower disabled each entry on its first 0 until the
driver restarted: a value already published stayed frozen, and one that
started at 0 never appeared. A 0 is a valid live reading (no load, or
input power while on battery), so publish it, as the .1 entries do.

The RTCS 03.02.00 card, which does not measure these three, now
publishes them as 0 again. It cannot be told apart reliably (sysObjectID
.0.0, generic sysDescr), so there is no quirk to bound the filter to.

Bump IETF_MIB_VERSION to 1.58.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fco Javier Felix <ffelix@inode64.com>
@inode64

inode64 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Thanks for the reproduction. You're right: SU_FLAG_ZEROINVALID clears SU_FLAG_OK on the first 0 (su_ups_get()), so a published reading stays frozen and one that starts at 0 never appears. That is worse than the zeros it was hiding.

bfcf4e2 drops the flag from the .0 copies of input.current, input.realpower and output.realpower and bumps IETF_MIB_VERSION to 1.58. The index-0 fallback and the static rating/transfer-point filtering are unchanged.

I don't see a reliable way to bound it to the RTCS card: it reports sysObjectID .0.0 and a generic sysDescr, so that card will now show those three as 0. They are what it reports, so I think that's acceptable. I've updated the description.

@AppVeyorBot

Copy link
Copy Markdown

✅ Build nut 2.8.5.6140-master completed (commit 23a10bb01a by @inode64)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants