Libre reading incorrect light level values from Huawei switchports



Component Version
LibreNMS 21.12.1-430-g64d112ee7
DB Schema 2021_11_29_165436_improve_ports_search_index (229)
PHP 7.4.3
Python 3.8.10
MySQL 10.3.32-MariaDB-0ubuntu0.20.04.1
RRDTool 1.7.2
SNMP 5.8


[OK] Composer Version: 2.2.4
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

Just found an issue with LibreNMS reading the light levels from a Huawei switchport via SNMP.

The issue seems to occur when the value of the light level is a positive number.

If I SNMPWalk the switch the value is provided correctly:

snmpget -v 2c -c XXXXXXXXXXX XX.XXX.XX.XXX
iso. = INTEGER: 77

Switchport value via direct access -
Rx Power: 0.77dBm, Working range: [-14.400, 0.499]dBm
Tx Power: -3.73dBm, Working range: [-8.198, 0.499]dBm

Libre is reporting the value as totally different, I have this problem on multiple Huawei ATN 910C-B units, meanwhile any light level values with negative numbers are displayed correctly.

“sensor_oid”: “.”,
“sensor_descr”: “GigabitEthernet0/2/3 Rx”,
“group”: “GigabitEthernet0/2/3”,
“sensor_divisor”: 1,
“sensor_multiplier”: 1,
“sensor_current”: -11.549019599857,

For some reason, we’ve got 2 sensors for RX and TX and I’m not 100% sure why.

@PipoCanaja Any chance you could take a look?


Basically, Huawei is sometimes providing dbm, sometimes mW, for the same OID. So I had to declare it twice in the YAML, with some key to choose between the 2 and skip the wrong one.
It seems that the key set I used back then is not applicable to this device.
It is a combination of the existance of OIDs (whatever the value is), the fact that the hwEntityOpticalRxPower is positive or negative.

So basically, you need to play (and probably add a new condition) to avoid the double detection. And most importantly, avoid breaking other devices (that’s the tricky part really :smiley: )

Thanks @PipoCanaja

Would you have the old YAML file that used to work?

Might be useful to reference while I work on this.

There never been and old YAML that used to work. Previous was even more incomplete. The game here is that Huawei is wrong in their replies, and it is difficult to change it now because this mistake is all around.
So you have to play with snmpwalk and try to find better keys to choose between one model and the other. Basically, you need to eliminate the wrong value by adding a new skip condition.
And then the regression tests will check that you are not breaking any device from the huawei family.