Fetched correct value but stored another value

Hi all,
i have an issue while defining a new state sensor.
I have to fetch the OID

1.3.6.1.4.1.38111.7.1.9.0.{{index}}

Possible values are:

LosAlarm(0),
RAIAlarm(1),
AISAlarm(2),
SignalAlarm(3),
Active(4),
Disable(5)

LibreNMS correctly fetch value 4:

Data E1Port0:
array (
  0 =>
  array (
    'E1Port0' => '4',
  ),
)
Sensor fetched value: 4

But it stores in DB value 0 (LosAlarm)

SQL[INSERT IGNORE INTO `sensors_to_state_indexes` (`sensor_id`,`state_index_id`)  VALUES (:sensor_id,:state_index_id) {"sensor_id":497,"state_index_id":28} 0.43ms]

array (
  'E1Port0' =>
  array (
    'E1Port0.0' => 1,
  ),
)
SQL[SELECT * FROM sensors AS S, devices AS D WHERE S.sensor_class=? AND S.device_id = D.device_id AND D.device_id = ? AND S.poller_type = ? ["state",27,"snmp"] 0.37ms]

E1Port0.0 -> E1Port0

I can’t get rid of this.
I attach the YAML definition:

mib: VOIP-MTG2000-3000-MIB
modules:
    sensors:
        state:
            data:
                -
                    oid: 'E1Port0'
                    num_oid: '1.3.6.1.4.1.38111.7.1.9.0.{{ $index }}'
                    descr: 'E1Port0 Status'
                    state_name: E1Port0
                    index: 'E1Port0.{{ $index }}'
                    states:
                        - { descr: 'signal_alarm', value: 5, generic: 1, graph: 0 }
                        - { descr: 'normal', value: 4, generic: 0, graph: 0 }
                        - { descr: 'signal_alarm', value: 3, generic: 2, graph: 0 }
                        - { descr: 'ais_alarm', value: 2, generic: 2, graph: 0 }
                        - { descr: 'rai_alarm', value: 1, generic: 2, graph: 0 }
                        - { descr: 'los_alarm', value: 0, generic: 2, graph: 0 }

This table stores the translations, never the value. The value is stored in sensors.sensor_current.
Are you sure the oid field is set correctly? (I don’t have the MIB to check)

Hi,
this is the MIB definition for that OID

--   E1 Status
-- 
		-- 1.3.6.1.4.1.38111.7.1.9
		E1Status OBJECT IDENTIFIER ::= {MTGStatus  9 }
		

		-- 1.3.6.1.4.1.38111.7.1.9.0
		E1Port0 OBJECT-TYPE
    		SYNTAX     INTEGER
				{
					LosAlarm(0),
					RAIAlarm(1),
					AISAlarm(2),
					SignalAlarm(3),
					Active(4),
					Disable(5)
				}
			MAX-ACCESS read-only
			STATUS current
			DESCRIPTION
				"E1Port0Status."
			::= {E1Status 0 }

I tried to GET via shell oid 1.3.6.1.4.1.38111.7.1.9.0 and it returned “NoSuchInstance”;
If I try to get oid 1.3.6.1.4.1.38111.7.1.9.0.0 it correctly return 4

I tried to edit the yaml with all these OIDs but when librenms poll it always returns 0:

#### Load poller module sensors ####

Module enabled: Global + | OS   | Device   | Manual +
SQL[SELECT `sensor_class` FROM `sensors` WHERE `device_id` = ? GROUP BY `sensor_class` [27] 0.44ms]

SQL[SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ["state",27] 0.54ms]

SNMP['/usr/bin/snmpget' '-v2c' '-c' 'particularCommunity' '-OUQntea' '-M' '/opt/librenms/mibs' 'udp:192.168.0.251:161' '1.3.6.1.4.1.38111.7.1.9.0.0']
.1.3.6.1.4.1.38111.7.1.9.0.0 = 4

Checking (snmp) state E1Port0 Status...
SQL[SELECT `state_value`
                        FROM `state_translations` LEFT JOIN `sensors_to_state_indexes`
                        ON `state_translations`.`state_index_id` = `sensors_to_state_indexes`.`state_index_id`
                        WHERE `sensors_to_state_indexes`.`sensor_id` = ?
                        AND `state_translations`.`state_descr` LIKE ? [497,""] 0.45ms]

State value of  is
0 #
RRD[update /opt/librenms/rrd/192.168.0.251/sensor-state-E1Port0-E1Port0.0.rrd N:0]
RRDtool Output: OK u:0.00 s:0.01 r:1.05

>> SNMP: [1/0.01s] MySQL: [3/0.01s] RRD: [2/0.00s]
>> Runtime for poller module 'sensors': 0.0133 seconds with 99736 bytes
RRD[update /opt/librenms/rrd/192.168.0.251/poller-perf-sensors.rrd N:0.013263940811157]
RRDtool Output: OK u:0.00 s:0.01 r:1.07
#### Unload poller module sensors ####

In my opinion the problem is that state_translations.state_descr LIKE operation is valued “” (empty string).
How can i fix this?

I found the mistake!
in YAML definition I missed a dot at the start of num_oid parameter

I wrote:

'1.3.6.1.4.1.38111.7.1.9.0.{{ $index }}'

Instead of:

'.1.3.6.1.4.1.38111.7.1.9.0.{{ $index }}'

It was so easy! :slight_smile:
Now it works correctly

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