State sensor discovery with string values

I’m trying to add a state sensor. The issue I’m facing is that the value returned is a string instead of an integer and it seems that LibreNMS isn’t adding the sensor if the state index contains a string as value. Here’s what I mean:

# snmpwalk -v2c -c x 10.46.31.2 -M /opt/librenms/mibs/:/opt/librenms/mibs/arubaos-cx/ -m ARUBAWIRED-VSFv2-MIB arubaWiredVsfv2OperStatus
ARUBAWIRED-VSFv2-MIB::arubaWiredVsfv2OperStatus.0 = STRING: no_split

As one can see, value is of type string with value ‘no_split’. So, great… Over to YAML:

                oid: arubaWiredVsfv2OperStatus
                value: arubaWiredVsfv2OperStatus
                index: 'arubaWiredVsfv2OperStatus.{{ $index }}'
                num_oid: '.1.3.6.1.4.1.47196.4.1.1.3.15.1.1.1.{{ $index }}'
                descr: 'VSF Status'
                group: 'VSF'
                states:
                    - { descr: 'no_split',          graph: 0, value: no_split,          generic: 0 }
                    - { descr: 'fragment_active',   graph: 0, value: fragment_active,   generic: 1 }
                    - { descr: 'fragment_inactive', graph: 0, value: fragment_inactive, generic: 2 }

The issue is that with this sensor state index the sensor is ignored. Which makes sense, since the sensor_current column in the MySQL sensor table is of type ‘double’, which implies it’s incapable of holding a string value.

Does LibreNMS offer any way to convert these string values to numeric values? Or do I need to implement these sensors in PHP and do the conversion in PHP?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.