feature: Improve Dell OpenManage Discovery (#4957)

This commit is contained in:
Søren Rosiak
2016-11-09 17:59:31 +00:00
committed by Neil Lathwood
co-authored by Neil Lathwood
parent e514e6dc51
commit 00495cee00
3 changed files with 171 additions and 158 deletions
@@ -1,29 +1,29 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2016 Søren Friis Rosiak <[email protected]>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if ($device['os'] == 'linux') {
$oids = snmp_walk($device, 'coolingDevicechassisIndex.1', '-OsqnU', 'MIB-Dell-10892');
d_echo($oids."\n");
if (strstr($device['hardware'], 'Dell')) {
$temp = snmpwalk_cache_multi_oid($device, 'coolingDeviceTable', array(), 'MIB-Dell-10892');
$cur_oid = '.1.3.6.1.4.1.674.10892.1.700.12.1.6.';
$oids = trim($oids);
if ($oids) {
echo 'Dell ';
}
if (is_array($temp)) {
foreach ($temp as $index => $entry) {
$descr = $temp[$index]['coolingDeviceLocationName'];
$value = $temp[$index]['coolingDeviceReading'];
$lowlimit = $temp[$index]['coolingDeviceLowerCriticalThreshold'];
$low_warn_limit = $temp[$index]['coolingDeviceLowerNonCriticalThreshold'];
$warnlimit = $temp[$index]['coolingDeviceUpperNonCriticalThreshold'];
$limit = $temp[$index]['coolingDeviceUpperCriticalThreshold'];
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$kind) = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$fan_oid = ".1.3.6.1.4.1.674.10892.1.700.12.1.6.1.$index";
$descr_oid = "coolingDeviceLocationName.1.$index";
$limit_oid = "coolingDeviceLowerCriticalThreshold.1.$index";
$descr = trim(snmp_get($device, $descr_oid, '-Oqv', 'MIB-Dell-10892'), '"');
$descr = preg_replace('/(Board | MOD )/', '', $descr);
$current = snmp_get($device, $fan_oid, '-Oqv', 'MIB-Dell-10892');
$low_limit = snmp_get($device, $limit_oid, '-Oqv', 'MIB-Dell-10892');
$divisor = '1';
discover_sensor($valid['sensor'], 'fanspeed', $device, $fan_oid, $index, 'dell', $descr, $divisor, '1', $low_limit, null, null, null, $current);
discover_sensor($valid['sensor'], 'fanspeed', $device, $cur_oid . $index, $index, 'dell', $descr, '0', '1', $lowlimit, $low_warn_limit, $warnlimit, $limit, $value, 'snmp', $index);
}
}
}
+128 -81
View File
@@ -1,11 +1,8 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
* Modyfied by Peter TKATCHENKO https://github.com/Peter2121/ 2016
*
* Copyright (c) 2016 Søren Friis Rosiak <[email protected]>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
@@ -13,86 +10,136 @@
* the source code distribution for details.
*/
$oids = snmp_walk($device, 'virtualDiskDeviceName', '-Oesqn', 'StorageManagement-MIB');
$name_oid = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.3';
$main_oid = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.4.';
d_echo($oids."\n");
if (strstr($device['hardware'], 'Dell')) {
$tables = array(
// One could add more entrys from deviceGroup, but this will do as a start
array('processorDeviceStatusTable','.1.3.6.1.4.1.674.10892.1.1100.32.1.5.','processorDeviceStatusStatus','processorDeviceStatusLocationName','MIB-Dell-10892') ,
array('memoryDeviceTable','.1.3.6.1.4.1.674.10892.1.1100.50.1.5.','memoryDeviceStatus','memoryDeviceLocationName','MIB-Dell-10892') ,
array('powerSupplyTable','.1.3.6.1.4.1.674.10892.1.600.12.1.5.','powerSupplyStatus','powerSupplyLocationName','MIB-Dell-10892') ,
array('intrusionTable','.1.3.6.1.4.1.674.10892.1.300.70.1.5.','intrusionStatus','Intrusion','MIB-Dell-10892') ,
array('controllerTable','.1.3.6.1.4.1.674.10893.1.20.130.1.1.5.','controllerState','controllerName','StorageManagement-MIB') ,
array('arrayDiskTable','.1.3.6.1.4.1.674.10893.1.20.130.4.1.4.','arrayDiskState','arrayDiskName','StorageManagement-MIB') ,
array('virtualDiskTable','.1.3.6.1.4.1.674.10893.1.20.140.1.1.4.','virtualDiskState','virtualDiskDeviceName','StorageManagement-MIB') ,
array('batteryTable','.1.3.6.1.4.1.674.10893.1.20.130.15.1.4.','batteryState','batteryName','StorageManagement-MIB') ,
);
$oids = trim($oids);
if ($oids) {
echo 'Dell ';
foreach ($tables as $tablevalue) {
$temp = snmpwalk_cache_multi_oid($device, $tablevalue[0], array(), $tablevalue[4]);
$cur_oid = $tablevalue[1];
$state_name = 'dellVirtualDiskState';
$state_index_id = create_state_index($state_name);
/*
-- 1.3.6.1.4.1.674.10893.1.20.140.1.1.4
virtualDiskState
INTEGER
{
unknown(0),
ready(1),
failed(2),
online(3),
offline(4),
degraded(6),
verifying(7),
resynching(15),
regenerating(16),
failedRedundancy(18),
rebuilding(24),
formatting(26),
reconstructing(32),
initializing(35),
backgroundInit(36),
permanentlyDegraded(52)
}
*/
if ($state_index_id) {
$states = array(
array($state_index_id,'unknown',0,0,3) ,
array($state_index_id,'ready',1,1,0) ,
array($state_index_id,'failed',1,2,2) ,
array($state_index_id,'online',1,3,1) ,
array($state_index_id,'offline',1,4,2) ,
array($state_index_id,'degraded',1,6,2) ,
array($state_index_id,'verifying',1,7,1) ,
array($state_index_id,'resynching',1,15,1) ,
array($state_index_id,'regenerating',1,16,1) ,
array($state_index_id,'failedRedundancy',1,18,2) ,
array($state_index_id,'rebuilding',1,24,1) ,
array($state_index_id,'formatting',1,26,1) ,
array($state_index_id,'reconstructing',1,32,1) ,
array($state_index_id,'initializing',1,35,1) ,
array($state_index_id,'backgroundInit',1,36,1) ,
array($state_index_id,'permanentlyDegraded',1,52,2)
);
if (is_array($temp)) {
//Create State Index
$state_name = $tablevalue[2];
$state_index_id = create_state_index($state_name);
foreach ($states as $value) {
$insert = array(
'state_index_id' => $value[0],
'state_descr' => $value[1],
'state_draw_graph' => $value[2],
'state_value' => $value[3],
'state_generic_value' => $value[4]
);
dbInsert($insert, 'state_translations');
//Create State Translation
if ($state_index_id !== null) {
if ($state_name == 'processorDeviceStatusStatus' || $state_name == 'memoryDeviceStatus' || $state_name == 'powerSupplyStatus' || $state_name == 'intrusionStatus') {
$states = array(
array($state_index_id,'other',0,1,3) ,
array($state_index_id,'unknown',0,2,3) ,
array($state_index_id,'ok',0,3,0) ,
array($state_index_id,'nonCritical',0,4,1) ,
array($state_index_id,'critical',0,5,2) ,
array($state_index_id,'nonRecoverable',0,6,2)
);
} elseif ($state_name == 'controllerState') {
$states = array(
array($state_index_id,'ready',0,1,0) ,
array($state_index_id,'failed',0,2,2) ,
array($state_index_id,'online',0,3,0) ,
array($state_index_id,'offline',0,4,1) ,
array($state_index_id,'degraded',0,6,2)
);
} elseif ($state_name == 'arrayDiskState') {
$states = array(
array($state_index_id,'ready',0,1,0) ,
array($state_index_id,'failed',0,2,2) ,
array($state_index_id,'online',0,3,0) ,
array($state_index_id,'offline',0,4,2) ,
array($state_index_id,'degraded',0,5,2) ,
array($state_index_id,'recovering',0,6,1) ,
array($state_index_id,'removed',0,7,1) ,
array($state_index_id,'non-raid',0,8,3) ,
array($state_index_id,'notReady',0,9,1) ,
array($state_index_id,'resynching',0,10,1) ,
array($state_index_id,'replacing',0,11,1) ,
array($state_index_id,'spinningDown',0,12,1) ,
array($state_index_id,'rebuild',0,13,1) ,
array($state_index_id,'noMedia',0,14,1) ,
array($state_index_id,'formatting',0,15,1) ,
array($state_index_id,'diagnostics',0,16,1) ,
array($state_index_id,'predictiveFailure',0,17,2) ,
array($state_index_id,'initializing',0,18,1) ,
array($state_index_id,'foreign',0,19,1) ,
array($state_index_id,'clear',0,20,1) ,
array($state_index_id,'unsupported',0,21,2) ,
array($state_index_id,'incompatible',0,22,2) ,
array($state_index_id,'readOnly',0,23,2)
);
} elseif ($state_name == 'virtualDiskState') {
$states = array(
array($state_index_id,'unknown',0,0,3) ,
array($state_index_id,'ready',1,1,0) ,
array($state_index_id,'failed',1,2,2) ,
array($state_index_id,'online',1,3,1) ,
array($state_index_id,'offline',1,4,2) ,
array($state_index_id,'degraded',1,6,2) ,
array($state_index_id,'verifying',1,7,1) ,
array($state_index_id,'resynching',1,15,1) ,
array($state_index_id,'regenerating',1,16,1) ,
array($state_index_id,'failedRedundancy',1,18,2) ,
array($state_index_id,'rebuilding',1,24,1) ,
array($state_index_id,'formatting',1,26,1) ,
array($state_index_id,'reconstructing',1,32,1) ,
array($state_index_id,'initializing',1,35,1) ,
array($state_index_id,'backgroundInit',1,36,1) ,
array($state_index_id,'permanentlyDegraded',1,52,2)
);
} elseif ($state_name == 'batteryState') {
$states = array(
array($state_index_id,'ready',0,1,0) ,
array($state_index_id,'failed',1,2,2) ,
array($state_index_id,'degraded',1,6,2) ,
array($state_index_id,'reconditioning',1,7,1) ,
array($state_index_id,'high',1,9,1) ,
array($state_index_id,'low',1,10,1) ,
array($state_index_id,'charging',1,12,1) ,
array($state_index_id,'missing',1,21,2) ,
array($state_index_id,'learning',1,36,1)
);
}
foreach ($states as $value) {
$insert = array(
'state_index_id' => $value[0],
'state_descr' => $value[1],
'state_draw_graph' => $value[2],
'state_value' => $value[3],
'state_generic_value' => $value[4]
);
dbInsert($insert, 'state_translations');
}
}
foreach ($temp as $index => $entry) {
if (strpos($index, '54.') === false) { //Because Dell is buggy
if ($state_name == 'intrusionStatus') {
$descr = $tablevalue[3];
} elseif ($state_name == 'batteryState') {
$descr = str_replace('"', "", snmp_get($device, "batteryConnectionControllerName." .$index. "", "-Ovqn", $tablevalue[4])) . ' - ' .$temp[$index][$tablevalue[3]];
} elseif ($state_name == 'arrayDiskState') {
$descr = str_replace('"', "", snmp_get($device, "arrayDiskEnclosureConnectionEnclosureName." .$index. "", "-Ovqn", $tablevalue[4])) . ' - ' .$temp[$index][$tablevalue[3]];
} else {
$descr = clean($temp[$index][$tablevalue[3]]); // Use clean as virtualDiskDeviceName is user defined
}
//Discover Sensors
discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index);
//Create Sensor To State Index
create_sensor_to_state_index($device, $state_name, $index);
}
}
}
}
foreach (explode("\n", $oids) as $data) {
list($oid,$name) = explode(' ', $data, 2);
$name = trim($name, "\"");
if ($oid==$name_oid) {
continue; // Something goes wrong, we should have $name_oid.$num_index in $oid
} $split_oid = explode('.', $oid);
$num_index = $split_oid[(count($split_oid) - 1)];
$index = (int)$num_index+0;
$oid = $main_oid.$num_index;
$low_limit = 0.5;
$high_limit = 1.5;
$state_current = snmp_get($device, $oid, '-Oevq');
discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $name, '1', '1', $low_limit, $low_limit, $high_limit, $high_limit, $state_current, 'snmp', $index);
create_sensor_to_state_index($device, $state_name, $index);
}
}
@@ -1,64 +1,30 @@
<?php
/*
* LibreNMS
*
* This file is part of LibreNMS.
*
* @package LibreNMS
* @subpackage discovery
* @copyright (C) 2006 - 2012 Adam Armstrong
* Copyright (c) 2016 Søren Friis Rosiak <[email protected]>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
// MIB-Dell-10892::temperatureProbechassisIndex.1.1 = INTEGER: 1
// MIB-Dell-10892::temperatureProbeIndex.1.1 = INTEGER: 1
// MIB-Dell-10892::temperatureProbeStateCapabilities.1.1 = INTEGER: 0
// MIB-Dell-10892::temperatureProbeStateSettings.1.1 = INTEGER: enabled(2)
// MIB-Dell-10892::temperatureProbeStatus.1.1 = INTEGER: ok(3)
// MIB-Dell-10892::temperatureProbeReading.1.1 = INTEGER: 320
// MIB-Dell-10892::temperatureProbeType.1.1 = INTEGER: temperatureProbeTypeIsAmbientESM(3)
// MIB-Dell-10892::temperatureProbeLocationName.1.1 = STRING: "BMC Planar Temp"
// MIB-Dell-10892::temperatureProbeUpperCriticalThreshold.1.1 = INTEGER: 530
// MIB-Dell-10892::temperatureProbeUpperNonCriticalThreshold.1.1 = INTEGER: 480
// MIB-Dell-10892::temperatureProbeLowerNonCriticalThreshold.1.1 = INTEGER: 70
// MIB-Dell-10892::temperatureProbeLowerCriticalThreshold.1.1 = INTEGER: 30
// MIB-Dell-10892::temperatureProbeProbeCapabilities.1.1 = INTEGER: 0
if (strstr($device['hardware'], 'Dell')) {
// stuff partially copied from akcp sensor
$oids = snmp_walk($device, 'temperatureProbeStatus', '-Osqn', 'MIB-Dell-10892');
d_echo($oids."\n");
$temp = snmpwalk_cache_multi_oid($device, 'temperatureProbeTable', array(), 'MIB-Dell-10892');
$cur_oid = '.1.3.6.1.4.1.674.10892.1.700.20.1.6.';
$divisor = '10';
$oids = trim($oids);
if ($oids) {
echo 'Dell OMSA ';
if (is_array($temp)) {
foreach ($temp as $index => $entry) {
$descr = $temp[$index]['temperatureProbeLocationName'];
$value = $temp[$index]['temperatureProbeReading'] / $divisor;
$lowlimit = $temp[$index]['temperatureProbeLowerCriticalThreshold'] / $divisor;
$low_warn_limit = $temp[$index]['temperatureProbeLowerNonCriticalThreshold'] / $divisor;
$warnlimit = $temp[$index]['temperatureProbeUpperNonCriticalThreshold'] / $divisor;
$limit = $temp[$index]['temperatureProbeUpperCriticalThreshold'] / $divisor;
discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid . $index, $index, 'dell', $descr, $divisor, '1', $lowlimit, $low_warn_limit, $warnlimit, $limit, $value, 'snmp', $index);
}
}
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$status) = explode(' ', $data, 2);
d_echo('status : '.$status."\n");
if ($status == 'ok') {
// 2 = normal, 0 = not connected
$split_oid = explode('.', $oid);
$temperature_id = $split_oid[(count($split_oid) - 2)].'.'.$split_oid[(count($split_oid) - 1)];
$descr_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.8.$temperature_id";
$temperature_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$temperature_id";
$limit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.10.$temperature_id";
$warnlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.11.$temperature_id";
$lowwarnlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.12.$temperature_id";
$lowlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.13.$temperature_id";
$descr = trim(snmp_get($device, $descr_oid, '-Oqv', 'MIB-Dell-10892'), '"');
$temperature = snmp_get($device, $temperature_oid, '-Oqv', 'MIB-Dell-10892');
$lowwarnlimit = snmp_get($device, $lowwarnlimit_oid, '-Oqv', 'MIB-Dell-10892');
$warnlimit = snmp_get($device, $warnlimit_oid, '-Oqv', 'MIB-Dell-10892');
$limit = snmp_get($device, $limit_oid, '-Oqv', 'MIB-Dell-10892');
$lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', 'MIB-Dell-10892');
discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'dell', $descr, '10', '1', ($lowlimit / 10), ($low_warn_limit / 10), ($warnlimit / 10), ($limit / 10), ($temperature / 10));
}
}//end if
}//end foreach
}//end if
}