Additional support for infortrend - drives state monitoring

hi guys,
i need a little bit help trying to nail this down, seems like i failing to understand the issue

im trying to modify this file here
/opt/librenms/resources/definitions/os_discovery/infortrend.yaml

with the following values

modules:
  os:
    serial:
      - IFT-SNMP-MIB::serialNum.0
    hardware:
      - IFT-SNMP-MIB::privateLogoModel.0
  sensors:
    temperature:
      data:
        -
          oid: luDevTable
          value: luDevValue
          num_oid: '.1.3.6.1.4.1.1714.1.1.9.1.9.{{ $index }}'
          divisor: 10
          index: 'temp{{ $index }}'
          descr: luDevDescription
          skip_values:
            -
              oid: luDevTypeCode
              op: '!='
              value: 3
    voltage:
      data:
        -
          oid: luDevTable
          value: luDevValue
          num_oid: '.1.3.6.1.4.1.1714.1.1.9.1.9.{{ $index }}'
          divisor: 1000
          index: 'voltage{{ $index }}'
          descr: luDevDescription
          skip_values:
            -
              oid: luDevTypeCode
              op: '!='
              value: 5
    state:
      data:
        -
          oid: luDevTable
          value: luDevValue
          num_oid: .1.3.6.1.4.1.1714.1.1.9.1.9.{{ $index }}
          index: 'disk{{ $index }}'
          descr: luDevDescription
          skip_values:
            -
              oid: luDevTypeCode
              op: '!='
              value: 17
          state_name: iftDiskState

states:
  iftDiskState:
    0: unknown
    1: warning
    2: critical
    3: ok
    4: offline
    5: rebuilding
    6: failed
    7: initializing
    8: degraded
    9: ok

error is :

Using Device Slot 1 from $pre_cache[$discovery_data['oid']][17][luDevDescription] for luDevDescription
PHP Error(2): Undefined array key "states" in /opt/librenms/includes/discovery/functions.inc.php:559
SQL[insert into `eventlog` (`reference`, `type`, `datetime`, `severity`, `message`, `username`, `device_id`) values (?, ?, ?, ?, ?, ?, ?) [null,"discovery","2025-08-04 12:33:03",5,"Error discovering sensors module. Check log file for more details.","",289] 0.21ms]

Exception: TypeError array_map(): Argument #2 ($array) must be of type array, null given @ /opt/librenms/includes/functions.php:426
#0 /opt/librenms/includes/functions.php(426): array_map()
#1 /opt/librenms/includes/discovery/functions.inc.php(559): create_state_index()
#2 /opt/librenms/includes/discovery/functions.inc.php(616): discovery_process()
#3 /opt/librenms/includes/discovery/sensors.inc.php(50): sensors()
#4 /opt/librenms/includes/discovery/functions.inc.php(172): include('/opt/librenms/i...')
#5 /opt/librenms/discovery.php(108): discover_device()
#6 {main}

i can see values when i perform the snmpwalk. but i don’t see them being added on the interface…any ideas what im doing wrong?

i kept testing to get the values but there are 2 problems , i face now.

  1. state description is not sorted , no matter what i do , i can’t affect that part (its slot device 1 , slot device 10, slot device 12, slot device 2 , instead of the 1,2,3…12)
  2. following @murrant advice , that the values where made-up, i tried to mirror another storage setup…(of another OS)

this is my code now with an additional infotrend.inc.php

but again there are no data to be graphed in librenms from this code , using the -vvv during discovery i can see , serial numbers from drives, i can see values which would correspond to the size of the LUNs for the storage , but again nothing that i could graph from there

<?php

global $valid;

if (!isset($valid['sensor'])) {
    $valid['sensor'] = [];
}

// --- Common: State Definitions ---

// Disk states based on enterprises.1714.1.1.5.1.6
$disk_health_states = [
    ['value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'],
    ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'],
    ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'],
    ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'],
    ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'offline'],
    ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'rebuilding'],
    ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'],
    ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'initializing'],
    ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'degraded'],
    ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'power saving'],
    ['value' => 10, 'generic' => 0, 'graph' => 0, 'descr' => 'powering up'],
];

// Physical Device Slot states based on luDevValue when luDevTypeCode = 17
$device_slot_states = [
    ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'],
    ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'],
    ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'],
    ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'],
    ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'offline'],
    ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'rebuilding'],
    ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'],
    ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'initializing'],
    ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'degraded'],
    ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'],
];


// --- Section 1: Discover RAID Controller Cache Size ---

$cache_size_oid = 'enterprises.1714.1.1.1.1.2.0';
$cache_size_value = snmp_get($device, $cache_size_oid, 'IFT-SNMP-MIB');

if ($cache_size_value !== null && $cache_size_value !== '') {
    $cache_size_bytes = $cache_size_value * 1024 * 1024;

    discover_sensor(
        $valid['sensor'],
        'current',
        $device,
        $cache_size_oid,
        'cacheSize',
        'iftCacheSize',
        'RAID Controller Cache Size',
        1, 1,
        null, null, null, null,
        $cache_size_bytes,
        'snmp',
        'cache'
    );
}


// --- Section 2: Discover Disk Health State Sensors ---

$disk_health_data = snmpwalk_cache_multi_oid($device, 'enterprises.1714.1.1.5', [], 'IFT-SNMP-MIB');

$disk_health_state_name = 'iftDiskHealthState';
$disk_health_state_index_id = create_state_index($disk_health_state_name, $disk_health_states);

foreach ($disk_health_data as $index => $entry) {
    $value = $entry['1.6'] ?? null;
    $descr = $entry['1.1'] ?? "Disk $index";

    if ($value === null || $value === '') {
        continue;
    }

    discover_sensor(
        $valid['sensor'],
        'state',
        $device,
        ".1.3.6.1.4.1.1714.1.1.5.1.6.$index",
        $index,
        $disk_health_state_name,
        $descr,
        1, 1,
        null, null, null, null,
        $value,
        'snmp',
        $index
    );
}


// --- Section 3: Discover Physical Device Slot State Sensors & Storage Pool Sensors ---

$lu_dev_table_data = snmpwalk_cache_multi_oid($device, 'luDevTable', [], 'IFT-SNMP-MIB');

// DEVICE SLOT STATE
$device_slot_state_name = 'iftDeviceSlotState';
$device_slot_state_index_id = create_state_index($device_slot_state_name, $device_slot_states);

$device_slot_data = [];
foreach ($lu_dev_table_data as $index => $entry) {
    if (isset($entry['luDevTypeCode']) && $entry['luDevTypeCode'] == 17) {
        $device_slot_data[$index] = $entry;
    }
}

$sorted_device_indexes = array_keys($device_slot_data);
natsort($sorted_device_indexes);
$sorted_device_indexes = array_map('intval', $sorted_device_indexes);

foreach ($sorted_device_indexes as $index) {
    $entry = $device_slot_data[$index];
    $oid = ".1.3.6.1.4.1.1714.1.1.9.1.9.$index";
    $value = $entry['luDevValue'] ?? null;
    $descr = $entry['luDevDescription'] ?? "Device Slot $index";

    if ($value === null || $value === '') {
        continue;
    }

    discover_sensor(
        $valid['sensor'],
        'state',
        $device,
        $oid,
        $index,
        $device_slot_state_name,
        $descr,
        1, 1,
        null, null, null, null,
        $value,
        'snmp',
        $index
    );
}

// STORAGE POOL
foreach ($lu_dev_table_data as $index => $entry) {
    if (!isset($entry['luDevTypeCode']) || $entry['luDevTypeCode'] != 12) {
        continue;
    }

    $oid_value = ".1.3.6.1.4.1.1714.1.1.9.1.9.$index";
    $value = $entry['luDevValue'] ?? null;
    $descr = $entry['luDevDescription'] ?? "Storage Pool $index";
    $value_unit = $entry['luDevValueUnit'] ?? 1;

    if ($value === null || $value === '') {
        continue;
    }

    $value_in_bytes = $value * ($value_unit === 1 ? 1024 : 1);

    discover_sensor(
        $valid['sensor'],
        'storage',
        $device,
        $oid_value,
        $index,
        'iftStoragePool',
        $descr,
        1, 1,
        null, null, null, null,
        $value_in_bytes,
        'snmp',
        $index
    );
}


// --- LUN Storage Capacity ---

$luDevValue_oid = '.1.3.6.1.4.1.1714.1.1.9.1.9';
$luDevValueUnit_oid = '.1.3.6.1.4.1.1714.1.1.9.1.10';

$luDevValues = snmpwalk_cache_multi_oid($device, $luDevValue_oid, [], 'IFT-SNMP-MIB');
$luDevUnits = snmpwalk_cache_multi_oid($device, $luDevValueUnit_oid, [], 'IFT-SNMP-MIB');

$lun_data = $luDevValues;

$sorted_lun_indexes = array_keys($lun_data);
natsort($sorted_lun_indexes);
$sorted_lun_indexes = array_map('intval', $sorted_lun_indexes);

foreach ($sorted_lun_indexes as $index) {
    $entry = $lun_data[$index];
    $value = isset($entry[0]) ? $entry[0] : $entry;
    $unit = isset($luDevUnits[$index][0]) ? $luDevUnits[$index][0] : $luDevUnits[$index];

    if (is_numeric($value) && is_numeric($unit) && $unit > 0) {
        $capacity = $value * $unit;
        $descr = "LUN Storage Capacity $index";

        discover_sensor(
            $valid['sensor'],
            'storage',
            $device,
            "$luDevValue_oid.$index",
            $index,
            'infortrend-lun-storage',
            $descr,
            1,
            1,
            null,
            null,
            null,
            null,
            $capacity
        );
    }
}

problem that i can’t sort these states is here :

i can see in the discovery.php

lunLdLvID.1 = 8E49EBC7D5FE8FC
lunLdLvID.2 = 4400FBF43E69FF0B
lunLdLvID.3 = 8E49EBC7D5FE8FC
lunLdLvID.4 = 8E49EBC7D5FE8FC
lunLdLvID.5 = 4400FBF43E69FF0B
lunLdLvID.6 = 4400FBF43E69FF0B
lunLdLvID.7 = 8E49EBC7D5FE8FC
lunLdLvID.8 = 8E49EBC7D5FE8FC
lunLdLvID.9 = 8E49EBC7D5FE8FC
lunLdLvID.10 = 4400FBF43E69FF0B
lunLdLvID.11 = 8E49EBC7D5FE8FC
lunLdLvID.12 = 8E49EBC7D5FE8FC
lunLdLvID.13 = 4400FBF43E69FF0B
lunLdLvID.14 = 4400FBF43E69FF0B
lunLdLvID.15 = 8E49EBC7D5FE8FC
lunLdLvID.16 = 8E49EBC7D5FE8FC
lunLdLvID.17 = 8E49EBC7D5FE8FC
lunLdLvID.18 = 4400FBF43E69FF0B
lunLdLvID.19 = 8E49EBC7D5FE8FC
lunLdLvID.20 = 8E49EBC7D5FE8FC
lunLdLvID.21 = 4400FBF43E69FF0B
lunLdLvID.22 = 4400FBF43E69FF0B
lunLdLvID.23 = 8E49EBC7D5FE8FC
lunLdLvID.24 = 8E49EBC7D5FE8FC
lunLdLvID.25 = 8E49EBC7D5FE8FC
lunLdLvID.26 = 4400FBF43E69FF0B
lunLdLvID.27 = 8E49EBC7D5FE8FC
lunLdLvID.28 = 8E49EBC7D5FE8FC
lunLdLvID.29 = 4400FBF43E69FF0B
lunLdLvID.30 = 4400FBF43E69FF0B
lunLdLvID.31 = 8E49EBC7D5FE8FC
lunLdLvID.32 = 8E49EBC7D5FE8FC

the above are the lun IDs but i don’t know how to extract the size now from those values.

FYI, if you want to submit upstream (or maintain this long term) you should use yaml, not PHP.

Those are sorted lexicographically.

For usage, you need to use the storage module, look at the yaml form netapp or something.

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