Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Cisco Temp Disco #2765

Merged
merged 1 commit into from Jan 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 19 additions & 28 deletions includes/discovery/temperatures/cisco-envmon.inc.php
@@ -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
}
}