mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix Cisco Temp Disco
Existing disco was broken and did not work on the install’s I tested on.
This commit is contained in:
@@ -1,31 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2016 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// FIXME - dbFacile and fewer SNMP_GETs
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `sensor_class` = 'temperature' AND (`sensor_type` = 'cisco-entity-sensor' OR `sensor_type` = 'entity-sensor')", array($device['device_id'])) == '0' && ($device['os_group'] == 'cisco')) {
|
||||
echo 'CISCO-ENVMON-MIB: ';
|
||||
$oids = snmp_walk($device, '.1.3.6.1.4.1.9.9.13.1.3.1.2', '-Osqn', 'CISCO-ENVMON-MIB');
|
||||
$oids = str_replace('.1.3.6.1.4.1.9.9.13.1.3.1.2.', '', $oids);
|
||||
$oids = trim($oids);
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
list($index) = explode(' ', $data);
|
||||
$oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$index";
|
||||
$descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$index";
|
||||
$descr = snmp_get($device, $descr_oid, '-Oqv', 'CISCO-ENVMON-MIB');
|
||||
$temperature = snmp_get($device, $oid, '-Oqv', 'CISCO-ENVMON-MIB');
|
||||
if (!strstr($descr, 'No') && !strstr($temperature, 'No') && $temperature != '' && $descr != '') {
|
||||
$descr = str_replace('"', '', $descr);
|
||||
$descr = str_replace('temperature', '', $descr);
|
||||
$descr = str_replace('temperature', '', $descr);
|
||||
$descr = trim($descr);
|
||||
|
||||
if (!is_numeric($temperature)) {
|
||||
$temperature = stristr($temperature, ' degrees', true);
|
||||
}
|
||||
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'cisco', $descr, '1', '1', null, null, null, null, $temperature);
|
||||
}
|
||||
if ($device['os_group'] == 'cisco') {
|
||||
$temp = snmpwalk_cache_multi_oid($device, 'ciscoEnvMonTemperatureStatusTable', array(), 'CISCO-ENVMON-MIB');
|
||||
if (is_array($temp)) {
|
||||
$cur_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.';
|
||||
foreach ($temp as $index => $entry) {
|
||||
$descr = ucwords($temp[$index]['ciscoEnvMonTemperatureStatusDescr']);
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid.$index, $index, 'cisco', $descr, '1', '1', null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], null, $temp[$index]['ciscoEnvMonTemperatureStatusValue'], 'snmp', $index);
|
||||
}
|
||||
}//end foreach
|
||||
}//end if
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user