What am I doing wrong here for custom OID?


I’m trying to show this OID in my for a 3rd party device, I have all the other values showing ok.

If I run a mib walk I get the 4 values I need:

snmpwalk -v2c -c public
iso. = STRING: "118,127,69,178"

This is what I see in LibreNMS though:


Here is the part of my yaml file, what is wrong?

oid: rPanelBacklight1
num_oid: ‘.{{ $index }}’
descr: ‘Panel Back Light’
index: ‘rPanelBacklight1.{{ $index }}’
divisor: 0
oid: rwVideoPort
num_oid: ‘.{{ $index }}’
descr: ‘Video Port Number’
index: ‘rwVideoPort.{{ $index }}’
divisor: 0
oid: rColorReadout1
** num_oid: ‘.{{ $index }}’**
** descr: ‘Colour Readout’**
** index: ‘rColorReadout1.{{ $index }}’**
** divisor: 0**

Hi @gonzo ,
You cannot get 4 values at once using YAML code. So the result you see here is “something”. Probably the code will try to “cast” the string to an int, resulting in a value which is not the one you expect.
Only solution here, write PHP code to extracts exactly the data you need.


Something like this for the sensor.php

Based it on my yaml info though

  • oid: rColorReadout1
    num_oid: ‘.{{ $index }}’
    descr: ‘Colour Readout’
    index: ‘rColorReadout1.{{ $index }}’
    divisor: 0

I would try this approach. First, you create a php file to do the discovery, with includes/discovery/sensors/count/dhcpatriot.inc.php as a model. And you discover 4 times your sensor, but you change the “index” value to keep them all:

 oid: rColorReadout1_1
 num_oid: ‘.{{ $index }}'
 descr: ‘Colour Readout_1’
 index: ‘rColorReadout1_1.{{ $index }}’

 oid: rColorReadout1_2
 num_oid: ‘.{{ $index }}'
 descr: ‘Colour Readout_2’
 index: ‘rColorReadout1_2.{{ $index }}’

 oid: rColorReadout1_3
 num_oid: ‘.{{ $index }}'
 descr: ‘Colour Readout_3’
 index: ‘rColorReadout1_3.{{ $index }}’

 oid: rColorReadout1_4
 num_oid: ‘.{{ $index }}'
 descr: ‘Colour Readout_4’
 index: ‘rColorReadout1_4.{{ $index }}’

And then you write a piece of PHP in includes/polling/sensors/count/ that does more or less the same idea as includes/polling/sensors/count/dhcpatriot.inc.php . Basically, you have a chance to “edit” the variable here before it gets written to the DB. And for each of the 4 copies, you remove the 3 “unnecessary” values.

You should end up with 4 count sensors holding each of the 4 values.

(this is a hint, but I never did that myself :slight_smile: )


I’ve not managed to get this to work yet, I think I’m close.

Can you see anything wrong with this?


 * OIDs obtained from GDS.

$oids = [
    0 => [
        'oid'     => 'rColorReadout1_1',
        'num_oid' => '.{{ $index }}',
        'descr'   => 'Colour Readout_1',
        'index'   => 'rColorReadout1_1.{{ $index }}',
    1 => [
        'oid'     => 'rColorReadout1_2',
        'num_oid' => '.{{ $index }}',
        'descr'   => 'Colour Readout_2',
        'index'   => 'rColorReadout1_2.{{ $index }}',
    2 => [
        'oid'     => 'rColorReadout1_3',
        'num_oid' => '.{{ $index }}',
        'descr'   => 'Colour Readout_3',
        'index'   => 'rColorReadout1_3.{{ $index }}',
    3 => [
        'oid'     => 'rColorReadout1_4',
        'num_oid' => '.{{ $index }}',
        'descr'   => 'Colour Readout_4',
        'index'   => 'rColorReadout1_4.{{ $index }}',

$class = 'count';

And the poller:


 * OIDs obtained from GDS.

if ($sensor['sensor_type'] === 'rColorReadout1') {
    $current_time = time();
    $epoch_time = explode(':', $sensor_value);
    $sensor_value = round((intval($epoch_time[1]) - $current_time) / (60 * 60 * 24));

You only kept the beginning of the file which defines variables. But all the “computing” that comes before, you removed it. The discovery file you came with does not do anything.

And the polling file needs to split the 4 values and put them in the 4 sensors you created in the discovery file. Right now, you copy pasted code that have no use for your situation. It deals with time/epoch for dhcpatriot.

I’m not sure what “computing” part you mean as I used dhcpatriot.inc.php as reference.

I really don’t know php, sadly I’m not sure I’ll be able to do this as it’s over my head I think.

The yaml files (discovery and definition) were ok and I’m glad they all work and have a 100s of devices using them, but getting these 4 addition string values to show that the snmp walk can seems too hard for me I think.

Are there any other php files I can reference?

By computing, I mean that you removed more than half of the model discovery file. You kept only the part that initialize variables. Useless without the actual code that deals with it.
And, in term of reference, the files in the same directories may help you as well. But I haven’t seen any device doing exactly what you want to do. So the options are:

  • You find a way to do it, and we continue helping you
  • You live without those values
  • Or you wait until somebody with the same devices improve the support.

I’ll keep researching, so I understand can you paste the computing part I’m missing as I’ve checked and can’t see this? That would be really helpful.

I continue then continue to have a look. The company that looks after this device told us to use Solarwinds as it just works on there but I don’t want to.

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