From 0d15244c2e092f24f2bc7b956c58434acab67920 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Thu, 14 Jan 2016 19:05:39 +0100 Subject: [PATCH] Fix Cisco Temp Disco MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Existing disco was broken and did not work on the install’s I tested on. --- .../temperatures/cisco-envmon.inc.php | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/includes/discovery/temperatures/cisco-envmon.inc.php b/includes/discovery/temperatures/cisco-envmon.inc.php index 15b7577aa2..74408318d7 100644 --- a/includes/discovery/temperatures/cisco-envmon.inc.php +++ b/includes/discovery/temperatures/cisco-envmon.inc.php @@ -1,31 +1,22 @@ + * 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 + } +}