New OS - Data shows in Discovery but not in poller

Hello!
I am in the process of adding a new OS to support ESPHome devices using the ESPHome SNMP Component.

The data from SNMP looks to be in the discovery output. However, it is missing from the poller and web UI.

What am I doing wrong here?

 ./validate.php
===========================================
Component | Version
--------- | -------
LibreNMS  | 24.8.1 (2024-08-22T02:50:00+00:00)
DB Schema | 2024_07_19_120719_update_ports_stack_table (296)
PHP       | 8.1.2-1ubuntu2.18
Python    | 3.10.12
Database  | MariaDB 10.6.18-MariaDB-0ubuntu0.22.04.1
RRDTool   | 1.7.2
SNMP      | 5.9.1
===========================================

[OK]    Composer Version: 2.7.9
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database connection successful
[OK]    Database Schema is current
[OK]    SQL Server meets minimum requirements
[OK]    lower_case_table_names is enabled
[OK]    MySQL engine is optimal
[OK]    Database and column collations are correct
[OK]    Database schema correct
[OK]    MySQL and PHP time match
[OK]    Active pollers found
[OK]    Dispatcher Service is enabled
[OK]    Locks are functional
[OK]    Python wrapper cron entry is not present
[OK]    Redis is unavailable
[OK]    rrdtool version ok
[OK]    Connected to rrdcached

OS definition

cat includes/definitions/esphome.yaml
os: esphome
text: 'ESP-Home'
type: appliance
icon: esphome
snmp_bulk: false
discovery:
    - sysDescr:
          - 'ESPHome'
poller_modules:
    sensors: true
discovery_modules:
    sensors: true

Discovery definition

cat includes/definitions/discovery/esphome.yaml
modules:
    sensors:
        dbm:
            data:
                -
                    oid: 1.3.9999.4.1.0
                    descr: RSSI
                    num_oid: 1.3.9999.4.1.0
./discovery.php -h 10.16.19.70 -d | ./pbin.sh

...
#### Load disco module sensors ####
Caching data: sensors SNMP[[0;36m'/usr/bin/snmpwalk' '-v2c' '-c' 'COMMUNITY' '-OteQUsa' '-Ih' '-M' '/opt/librenms/mibs' 'udp:HOSTNAME:161' '1.3.9999.4.1.0'[0m]
iso.3.99* = -56  
...
SQL[[1;33mSELECT * 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 = ? [0;33m["charge",13,"snmp"][0m 0.79ms]
 
 
Dbm: Dynamic Discovery (dbm):  
array (
  'data' =>
  array (
    0 =>
    array (
      'oid' => '1.3.9999.4.1.0',
      'descr' => 'RSSI',
      'num_oid' => '1.3.9999.4.1.0',
    ),
  ),
)  
Data 1.3.9999.4.1.0:  
array (
  '3.9999.4.1.0' =>
  array (
    'iso' => '-56',
  ),
)  
array (
)  
...

Full discovery logs:
https://p.libren.ms/view/1276c8ec

./poller.php -h 10.16.19.70 -r -f -d | ./pbin.sh

#### Load poller module sensors ####
 
Module enabled: Global + | OS + | Device   | Manual    
SQL[[1;33mSELECT `sensor_class` FROM `sensors` WHERE `device_id` = ? GROUP BY `sensor_class` [0;33m[13][0m 0.55ms]
 
 
>> [0;36mSNMP[0m: [0/0.00s] [1;33mMySQL[0m: [1/0.01s]  
>> Runtime for poller module 'sensors': 0.0017 seconds with 1960 bytes  
#### Unload poller module sensors ####

Full poller logs:
https://p.libren.ms/view/c5081db8

Your oid should start with a leading ..

Also add a value field and index (index is fine to be 0), value is used to calculate high/low values unless you specify them

@laf Updated: includes/definitions/discovery/esphome.yaml To include the leading .,very similar results.

modules:
    sensors:
        dbm:
            data:
                -
                    oid: .1.3.9999.4.1.0
                    descr: RSSI
                    num_oid: .1.3.9999.4.1.0
                    index: 0
                    value: .1.3.9999.4.1.0

./discovery.php -h 10.16.19.70 -d | ./pbin.sh
Discovery logs: Untitled - LibreNMS

./poller.php -h 10.16.19.70 -r -f -d | ./pbin.sh
Poller logs: Untitled - LibreNMS

In the discovery definition, just below desc, try adding:

snmp_flags: ['-OQn']

@laf Updated: includes/definitions/discovery/esphome.yaml
Looks slightly different but still not expected, right?

modules:
    sensors:
        dbm:
            data:
                -
                    oid: .1.3.9999.4.1.0
                    descr: 'RSSI'
                    snmp_flags: ['-OQn']
                    num_oid: .1.3.9999.4.1.0
                    index: 0
                    value: .1.3.9999.4.1.0

./discovery.php -h 10.16.19.70 -d | ./pbin.sh
Discovery logs: Untitled - LibreNMS

./poller.php -h 10.16.19.70 -r -f -d | ./pbin.sh
Poller logs: Untitled - LibreNMS

Hi @JacobWilliamsErnst
We are probably lacking a MIB file here. LibreNMS expects to work with textual OIDs (oid) and the equivalent numerical form (num_oid). Working with both in numerical form is not currently supported I would say.
And because it seems that this SNMP implementation does not follow the standard rules (they did not request a standard Private Enterprise Numbers (PENs)), building and distributing a MIB would not make sense.
You should probably tell them to create an official SNMP port, and only after try to integrate it with LibreNMS.

I think other devices make it work, avtech uses just numerical OIDs. Was trying to see how that works compared to this one.

@PipoCanaja I opened an issue on the ESPHome SNMP Component repo to see if the author has plans to support MIB and PENs. :crossed_fingers:

@laf went looking to see if avtech uses PHP includes for sensors and did not find any so it all has to be in the YAML.

They have a pre-cache file in includes/discovery/sensors/pre-cache/

@laf I was able to copy and strip down the includes/discovery/sensors/pre-cache/avtech.inc.php

I have created:
includes/discovery/sensors/pre-cache/esphome.inc.php

$data = trim(snmp_walk($device, '.1.3.9999', '-OQn'));
foreach (explode(PHP_EOL, $data) as $line) {
    [$oid, $value] = explode(' =', $line);
    $value = trim($value);
    $pre_cache[$oid] = [[$oid => $value]];
}

unset($data);

With the addition of the above file, polling is working as expected using the following yaml:
includes/definitions/discovery/esphome.yaml

modules:
    sensors:
        dbm:
            data:
                -
                    oid: .1.3.9999.4.1.0
                    descr: 'RSSI of {{ $.1.3.9999.4.3.0 }} connected to {{ $.1.3.9999.4.2.0 }} with IP: {{ $.1.3.9999.4.4.0 }}'
                    group: 'WiFi'
                    num_oid: .1.3.9999.4.1.0
        state:
            data:
                -
                    oid: .1.3.9999.2.1.0
                    descr: 'Chip Type'
                    num_oid: .1.3.9999.2.1.0
                    group: 'Chip'
                    #state_name: 'Chip Type'
                    states:
                        - { value: 32, generic: 0, graph: 0, descr: 'ESP32' }
                        - { value: 8266, generic: 0, graph: 0, descr: 'ESP8266' }
        frequency:
            data:
                -
                    oid: .1.3.9999.2.2.0
                    descr: 'Chip Frequency'
                    num_oid: .1.3.9999.2.2.0
                    group: 'Chip'
                    multiplier: 1000000

That said, the php seems to just pre-cache the values. Unlike the avtech.inc.php file, no virtual tables are constructed.

Other OS’s do pre-cache in the yaml like netgear.yaml. Here is the pre-cache section:

    sensors:
        pre-cache:
            data:
                -
                    oid:
                        - boxServicesNormalTempRangeMin
                        - boxServicesNormalTempRangeMax

I tried creating the equivalent pre-cache section in the esphome.yaml using both just the base OID and specific OID’s used in the sensors. Neither was successful.

You might just have to switch over to doing this via PHP instead of Yaml, you’ll get a lot more control.

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