Discovery and Polling fetch different OID's

Hello,

Thanks in advance for the great project and taking the time to read this post.

I’m trying to add temperature sensor data to our FortiGate devices (also other environment data, but let’s keep the scope limited to temperature).
Depending on the model of FortiGate, there are different sensors in each hardware type, so FortiNet has put the sensor data in a table.

When discovery iterates over that table I get the correct values for the sensors.
Though, when it’s time for polling, it tries to read a different OID,which isn’t available, thus returning “0”.

I’m trying to figure out what’s wrong with my code so I can fix it an return the improvement with a PR back into LibreNMS.

The file I’m adding the code to is: includes/definitions/discovery/fortigate.yml.
The code I’m adding is the temperature block at the bottom of the file. The rest of the file is unchanged.

mib: FORTINET-FORTIGATE-MIB
modules:
    mempools:
        data:
            -
                ...
...
    sensors:
        pre-cache:
            data:
                -
                    oid:
                        - fgVpnTunEntPhase1Name
                        - fgVpnTunEntPhase2Name
                        - fgVpnTunEntRemGwyIp
                        - fgVdEntName
...
        temperature:
            data:
                -
                    oid:  fgHwSensors
                    num_oid: '.1.3.6.1.4.1.12356.101.4.3.2.1.{{ $index }}'
                    index: 'fgHwSensorEntIndex.{{ $index }}'
                    descr: fgHwSensorEntName
                    value:  fgHwSensorEntValue
                    skip_values:
                        -   oid: fgHwSensorEntName
                            op: 'regex'
                            value: '/^((?!Temp).)*$/'
                        -   oid: fgHwSensorEntValue
                            op: '='
                            value: -1

When running a discovery, the correct values are discovered and (temporarily, until polling) visible in the GUI.

Below is Discovery CLI output:

...
Temperature: Cur 23, Low: null, Low Warn: null, Warn: null, High: null
+Cur 24, Low: null, Low Warn: null, Warn: null, High: null
+
Tv_signal: 
...
Percent: 

>> Runtime for discovery module 'sensors': 6.4010 seconds with 175568 bytes
>> SNMP: [17/1.00s] MySQL: [2703/50.48s] RRD: [0/0.00s]  
#### Unload disco module sensors ####

This is the Discovery GUI output:
https://p.libren.ms/view/e3028762

While running Poller Capture, this is the output:

SQL[SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ["temperature",5] 0.75ms] 
  

SNMP['/usr/bin/snmpget' '-v2c' '-c' 'COMMUNITY' '-OUQntea' '-M' '/opt/librenms/mibs:/opt/librenms/mibs/fortinet' '-t' '5' 'udp:HOSTNAME:161' '.1.3.6.1.4.1.12356.101.4.3.2.1.33' '.1.3.6.1.4.1.12356.101.4.3.2.1.34']

.*.4.1.123*.2.1.33 = No Such Object available on this agent at this OID
.*.4.1.123*.2.1.34 = No Such Object available on this agent at this OID  

  

Checking (snmp) temperature PS1 Temp 1... 

Checking (snmp) temperature PS1 Temp 2... 
0 C
0 C


>> Runtime for poller module 'sensors': 0.8358 seconds with 22784 bytes
>> SNMP: [46/0.79s] MySQL: [29/0.34s]   
#### Unload poller module sensors ####

Note that it is trying to get invalid OID’s.

It is trying to fetch .*.4.1.123*.2.1.33 while it should have been trying to fetch .*.4.1.123*.2.1.1.33

I’ve verified with a manual snmpget that the correct value is availabe at the OID with the extra “.1”

Am I making an obvious mistake here?
Any help is much appreciated!

Thanks.

@MarkWest

Bump

I’ve tried some some more, but still no luck on resolving the issue.
Does anyone have some time to point me in the right direction?
Any help / response would be much appreciated.

Hello,
If you want to add new sensor yaml is not enough you also need script for that, check existing temp sensor stuff from some vendor and adopt it for you device, like this one

Hi @zombah ,
YAML is enough most of the time. Please avoid creating any PHP file unless strictly necessary.
Bye

Hi @MarkWest

According to the YAML file, only a single “one” is in the num_oid. So it is written as so when the sensor is created .

Cur 24, Low: null, Low Warn: null, Warn: null, High: null
Discover sensor: .1.3.6.1.4.1.12356.101.4.3.2.1.34, fgHwSensorEntIndex.34, fortigate, PS1 Temp 2, snmp, 1, 1, , 24, (limits: LL: , LW: , W: , H: ), rrd_type =

But looking at the MIB, it seems that the situation is different :

Name Sub children Sub Nodes Total Description
1.3.6.1.4.1.12356.101.4.3.2.1.1 fgHwSensorEntIndex 0 0 A unique identifier within the fgHwSensorTable
1.3.6.1.4.1.12356.101.4.3.2.1.2 fgHwSensorEntName 0 0 A string identifying the sensor by name
1.3.6.1.4.1.12356.101.4.3.2.1.3 fgHwSensorEntValue 0 0 A string representation of the value of the sensor. Because sensors can present data in different formats, string representatio…
1.3.6.1.4.1.12356.101.4.3.2.1.4 fgHwSensorEntAlarmStatus 0 0 If the sensor has an alarm threshold and has exceeded it, this will indicate its status. Not all sensors have alarms.

I only have access to one (old) fortinet which has 0 sensors so I cannot do any tests here.

But I would say this is definitely doable.

Please attach here the result of this command (replacing both xxxxxxxx with their respective values in your environnement:
'/usr/bin/snmpbulkwalk' '-v2c' '-c' 'xxxxxxxxxxx' '-m' 'all' '-M' '/opt/librenms/mibs:/opt/librenms/mibs/fortinet' 'udp:xxxxxxxxxxxxx:161' .1.3.6.1.4.1.12356.101.4.3

This should list all the sensors in the table, and from this, I should be able to help you fix.

My first guess, is adding a ‘3’ at the end of the num_oid to match the value fgHwSensorEntValue :

        temperature:
            data:
                -
                    oid:  fgHwSensors
                    num_oid: '.1.3.6.1.4.1.12356.101.4.3.2.1.3.{{ $index }}'
                    index: 'fgHwSensorEntIndex.{{ $index }}'
                    descr: fgHwSensorEntName
                    value:  fgHwSensorEntValue
                    skip_values:
                        -   oid: fgHwSensorEntName
                            op: 'regex'
                            value: '/^((?!Temp).)*$/'
                        -   oid: fgHwSensorEntValue
                            op: '='
                            value: -1

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