Tweak detection of APC transfer switch?

Tags: #<Tag:0x00007fec7c6d1dc8> #<Tag:0x00007fec7c6d1d00>

I noticed that includes/discovery/sensors/current/ tests for the presence of atsConfigPhaseTableIndex to decide if it has APC PowerNet-MIB ATS snmp objects:

$oids = snmp_walk($device, 'atsConfigPhaseTableIndex', '-OsqnU', 'PowerNet-MIB');

At least the one device I have (“AP7750 02”) –

APC Web/SNMP Management Card (MB:v3.6.8 PF:v2.6.4 PN:apc_hw02_aos_264.bin AF1:v2.6.1 AN1:apc_hw02_ats_261.bin MN:AP9617 HR:A10 SN: ZA0625029245 MD:06/16/2006)

does not have atsConfigPhaseTableIndex, so it fails this test and doesn’t discover atsOutputCurrent etc.

If I manually change the test in to look for something else like atsConfigProductName instead, it discovers it OK and polls fine.

$oids = snmp_walk($device, ‘atsConfigProductName’, ‘-OsqnU’, ‘PowerNet-MIB’);

It’s a one line change but there’s probably a more correct way to do it and I don’t want to maintain a local modification, plus maybe this would help other people?

The question here, is to ensure that a change here would not break polling/discovery for other devices … This is the tricky part with those “funny” snmp implementations sometimes.

Surely. There is probably a better way to achieve this, hopefully without piling on lists of one-off tests and quirks. But this is already broken, in the sense that atsConfigPhaseTableIndex is not really the right object to test for whether a device is an Automatic Transfer Switch - not even most ATSs have this object, certainly none of the single-phase ones at any rate. This is a large set of devices that can never be discovered except as generic devices.

Another nms product tests for atsInputPhaseTable and atsInputTable as well as some others to make this test, so I wonder if it might make sense here to just expand the test to be more inclusive.

IMO if something will be probed wrong, it’s better to fail by looking for objects that aren’t present (a situation that librenms handles very well) rather than to fail by librenms not being able to recognize a device.