2010-07-03 17:02:39 +00:00
|
|
|
<?php
|
2022-02-14 23:06:34 +01:00
|
|
|
/*
|
|
|
|
* LibreNMS discovery module for junos Temperature
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @package LibreNMS
|
|
|
|
* @link https://www.librenms.org
|
|
|
|
*
|
|
|
|
* @author Peca Nesovanovic <peca.nesovanovic@sattrakt.com>
|
|
|
|
*/
|
2017-02-03 12:39:38 +00:00
|
|
|
echo 'JunOS ';
|
|
|
|
$oids = snmp_walk($device, '.1.3.6.1.4.1.2636.3.1.13.1.7', '-Osqn', 'JUNIPER-MIB', 'junos');
|
|
|
|
$oids = trim($oids);
|
|
|
|
foreach (explode("\n", $oids) as $data) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$data = trim($data);
|
2017-02-03 12:39:38 +00:00
|
|
|
$data = substr($data, 29);
|
|
|
|
if ($data) {
|
2020-09-21 15:40:17 +02:00
|
|
|
[$oid] = explode(' ', $data);
|
2017-02-03 12:39:38 +00:00
|
|
|
$temperature_oid = ".1.3.6.1.4.1.2636.3.1.13.1.7.$oid";
|
2020-09-21 15:40:17 +02:00
|
|
|
$descr_oid = ".1.3.6.1.4.1.2636.3.1.13.1.5.$oid";
|
|
|
|
$descr = snmp_get($device, $descr_oid, '-Oqv', 'JUNIPER-MIB', 'junos');
|
|
|
|
$temperature = snmp_get($device, $temperature_oid, '-Oqv', 'JUNIPER-MIB', 'junos');
|
|
|
|
if (! strstr($descr, 'No') && ! strstr($temperature, 'No') && $descr != '' && $temperature != '0') {
|
2017-02-03 12:39:38 +00:00
|
|
|
$descr = str_replace('"', '', $descr);
|
|
|
|
$descr = str_replace('temperature', '', $descr);
|
|
|
|
$descr = str_replace('temperature', '', $descr);
|
|
|
|
$descr = str_replace('sensor', '', $descr);
|
|
|
|
$descr = trim($descr);
|
2011-03-15 09:57:13 +00:00
|
|
|
|
2017-02-03 12:39:38 +00:00
|
|
|
discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $oid, 'junos', $descr, '1', '1', null, null, null, null, $temperature);
|
2015-07-10 13:36:21 +02:00
|
|
|
}
|
2010-07-03 17:02:39 +00:00
|
|
|
}
|
2017-02-03 12:39:38 +00:00
|
|
|
}
|
2016-06-29 00:14:21 +01:00
|
|
|
|
2017-02-03 12:39:38 +00:00
|
|
|
$multiplier = 1;
|
2020-09-21 15:40:17 +02:00
|
|
|
$divisor = 1;
|
2017-02-03 12:39:38 +00:00
|
|
|
foreach ($pre_cache['junos_oids'] as $index => $entry) {
|
|
|
|
if (is_numeric($entry['jnxDomCurrentModuleTemperature']) && $entry['jnxDomCurrentModuleTemperature'] != 0 && $entry['jnxDomCurrentModuleTemperatureLowAlarmThreshold']) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$oid = '.1.3.6.1.4.1.2636.3.60.1.1.1.1.8.' . $index;
|
2022-02-14 23:06:34 +01:00
|
|
|
$interface = get_port_by_index_cache($device['device_id'], $index)['ifDescr'];
|
|
|
|
$descr = $interface . ' Temperature';
|
2020-09-21 15:40:17 +02:00
|
|
|
$limit_low = $entry['jnxDomCurrentModuleTemperatureLowAlarmThreshold'] / $divisor;
|
|
|
|
$warn_limit_low = $entry['jnxDomCurrentModuleTemperatureLowWarningThreshold'] / $divisor;
|
|
|
|
$limit = $entry['jnxDomCurrentModuleTemperatureHighAlarmThreshold'] / $divisor;
|
|
|
|
$warn_limit = $entry['jnxDomCurrentModuleTemperatureHighWarningThreshold'] / $divisor;
|
2017-02-03 12:39:38 +00:00
|
|
|
$current = $entry['jnxDomCurrentModuleTemperature'];
|
|
|
|
$entPhysicalIndex = $index;
|
|
|
|
$entPhysicalIndex_measured = 'ports';
|
|
|
|
|
2020-09-21 15:40:17 +02:00
|
|
|
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'rx-' . $index, 'junos', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured);
|
2016-06-29 00:14:21 +01:00
|
|
|
}
|
2010-07-03 17:02:39 +00:00
|
|
|
}
|