mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: only run pre-cache for the current OS (#6453)
Change powerwalker to use the $pre_cache array
This commit is contained in:
committed by
Neil Lathwood
parent
2ced131cf5
commit
c88c677a16
@@ -3,7 +3,14 @@
|
|||||||
$valid['sensor'] = array();
|
$valid['sensor'] = array();
|
||||||
|
|
||||||
// Pre-cache data for later use
|
// Pre-cache data for later use
|
||||||
require 'includes/discovery/sensors/pre-cache.inc.php';
|
$pre_cache = array();
|
||||||
|
$pre_cache_file = 'includes/discovery/sensors/pre-cache/' . $device['os'] . '.inc.php';
|
||||||
|
if (is_file($pre_cache_file)) {
|
||||||
|
echo "Pre-cache {$device['os']}: ";
|
||||||
|
include $pre_cache_file;
|
||||||
|
echo PHP_EOL;
|
||||||
|
d_echo($pre_cache);
|
||||||
|
}
|
||||||
|
|
||||||
// Run custom sensors
|
// Run custom sensors
|
||||||
require 'includes/discovery/sensors/cisco-entity-sensor.inc.php';
|
require 'includes/discovery/sensors/cisco-entity-sensor.inc.php';
|
||||||
|
@@ -35,13 +35,13 @@ if ($device['os'] === 'powerwalker') {
|
|||||||
discover_sensor($valid['sensor'], 'current', $device, $oid, 1, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'current', $device, $oid, 1, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($pw_oids['upsInputCurrent'][1])) {
|
if (is_numeric($pre_cache['powerwalker']['upsInputCurrent'][1])) {
|
||||||
$descr = 'Input Voltage';
|
$descr = 'Input Voltage';
|
||||||
$oid = '.1.3.6.1.2.1.33.1.3.3.1.4.1.0';
|
$oid = '.1.3.6.1.2.1.33.1.3.3.1.4.1.0';
|
||||||
discover_sensor($valid['sensor'], 'current', $device, $oid, 2, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'current', $device, $oid, 2, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($pw_oids['upsOutputCurrent'][1])) {
|
if (is_numeric($pre_cache['powerwalker']['upsOutputCurrent'][1])) {
|
||||||
$descr = 'Output Voltage';
|
$descr = 'Output Voltage';
|
||||||
$oid = '.1.3.6.1.2.1.33.1.4.4.1.3.1.0';
|
$oid = '.1.3.6.1.2.1.33.1.4.4.1.3.1.0';
|
||||||
discover_sensor($valid['sensor'], 'current', $device, $oid, 3, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'current', $device, $oid, 3, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
if ($device['os'] === 'powerwalker') {
|
if ($device['os'] === 'powerwalker') {
|
||||||
echo("PowerWalker ");
|
echo("PowerWalker ");
|
||||||
|
|
||||||
if (is_numeric($pw_oids['upsInputFrequency'][1])) {
|
if (is_numeric($pre_cache['powerwalker']['upsInputFrequency'][1])) {
|
||||||
$descr = 'Input Voltage';
|
$descr = 'Input Voltage';
|
||||||
$oid = '.1.3.6.1.2.1.33.1.3.3.1.2.1';
|
$oid = '.1.3.6.1.2.1.33.1.3.3.1.2.1';
|
||||||
discover_sensor($valid['sensor'], 'frequency', $device, $oid, 2, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'frequency', $device, $oid, 2, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* LibreNMS
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016 Neil Lathwood <neil@lathwood.co.uk>
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo 'Pre-cache: ';
|
|
||||||
|
|
||||||
// Include all discovery modules
|
|
||||||
$include_dir = 'includes/discovery/sensors/pre-cache';
|
|
||||||
require 'includes/include-dir.inc.php';
|
|
||||||
|
|
||||||
echo "\n";
|
|
@@ -23,8 +23,8 @@
|
|||||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'aos-emu2') {
|
echo 'emsStatusSysTempUnits ';
|
||||||
$pre_cache['emu2_temp_scale'] = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB');
|
$pre_cache['emu2_temp_scale'] = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB');
|
||||||
$pre_cache['emu2_temp'] = snmpwalk_cache_oid($device, 'emsProbeStatusEntry', array(), 'PowerNet-MIB');
|
|
||||||
d_echo($pre_cache);
|
echo 'emsProbeStatusEntry ';
|
||||||
}
|
$pre_cache['emu2_temp'] = snmpwalk_cache_oid($device, 'emsProbeStatusEntry', array(), 'PowerNet-MIB');
|
||||||
|
@@ -23,7 +23,5 @@
|
|||||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'apc') {
|
echo 'coolingUnitStatusAnalogEntry ';
|
||||||
$pre_cache['cooling_unit_analog'] = snmpwalk_cache_oid($device, 'coolingUnitStatusAnalogEntry', array(), 'PowerNet-MIB');
|
$pre_cache['cooling_unit_analog'] = snmpwalk_cache_oid($device, 'coolingUnitStatusAnalogEntry', array(), 'PowerNet-MIB');
|
||||||
d_echo($pre_cache);
|
|
||||||
}
|
|
||||||
|
@@ -10,7 +10,5 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'comware') {
|
echo 'hh3cTransceiverInfoTable ';
|
||||||
$pre_cache['comware_oids'] = snmpwalk_cache_multi_oid($device, 'hh3cTransceiverInfoTable', array(), 'HH3C-TRANSCEIVER-INFO-MIB');
|
$pre_cache['comware_oids'] = snmpwalk_cache_multi_oid($device, 'hh3cTransceiverInfoTable', array(), 'HH3C-TRANSCEIVER-INFO-MIB');
|
||||||
d_echo($pre_cache);
|
|
||||||
}
|
|
||||||
|
@@ -1,6 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ($device['os'] === 'datacom') {
|
echo 'ddTransceiversEntry ';
|
||||||
$pre_cache['datacom_oids'] = snmpwalk_cache_multi_oid($device, 'ddTransceiversEntry', array(), 'DMswitch-MIB');
|
$pre_cache['datacom_oids'] = snmpwalk_cache_multi_oid($device, 'ddTransceiversEntry', array(), 'DMswitch-MIB');
|
||||||
d_echo($pre_cache);
|
|
||||||
}
|
|
||||||
|
@@ -23,6 +23,5 @@
|
|||||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'fabos') {
|
echo 'swSensorEntry ';
|
||||||
$pre_cache['fabos_sensors'] = snmpwalk_cache_multi_oid($device, 'swSensorEntry', array(), 'SW-MIB');
|
$pre_cache['fabos_sensors'] = snmpwalk_cache_multi_oid($device, 'swSensorEntry', array(), 'SW-MIB');
|
||||||
}
|
|
||||||
|
@@ -23,7 +23,5 @@
|
|||||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'hpe-ipdu') {
|
echo 'mpduOutputEntry ';
|
||||||
$pre_cache['hpe_ipdu'] = snmpwalk_cache_oid($device, 'mpduOutputEntry', array(), 'CPQPOWER-MIB');
|
$pre_cache['hpe_ipdu'] = snmpwalk_cache_oid($device, 'mpduOutputEntry', array(), 'CPQPOWER-MIB');
|
||||||
d_echo($pre_cache);
|
|
||||||
}
|
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
d_echo('outletConfigDesc ');
|
echo 'outletConfigDesc ';
|
||||||
$pre_cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $pre_cache['ipoman']['out'], 'IPOMANII-MIB');
|
$pre_cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $pre_cache['ipoman']['out'], 'IPOMANII-MIB');
|
||||||
d_echo('outletConfigLocation ');
|
|
||||||
|
echo 'outletConfigLocation ';
|
||||||
$pre_cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $pre_cache['ipoman']['out'], 'IPOMANII-MIB');
|
$pre_cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $pre_cache['ipoman']['out'], 'IPOMANII-MIB');
|
||||||
d_echo('inletConfigDesc ');
|
|
||||||
|
echo 'inletConfigDesc ';
|
||||||
$pre_cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $pre_cache['ipoman']['in'], 'IPOMANII-MIB');
|
$pre_cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $pre_cache['ipoman']['in'], 'IPOMANII-MIB');
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'junos') {
|
echo 'JnxDomCurrentEntry ';
|
||||||
$pre_cache['junos_oids'] = snmpwalk_cache_multi_oid($device, 'JnxDomCurrentEntry', array(), 'JUNIPER-DOM-MIB', 'junos');
|
$pre_cache['junos_oids'] = snmpwalk_cache_multi_oid($device, 'JnxDomCurrentEntry', array(), 'JUNIPER-DOM-MIB', 'junos');
|
||||||
$pre_cache['junos_multilane_oids'] = snmpwalk_cache_multi_oid($device, 'JnxDomCurrentLaneEntry', array(), 'JUNIPER-DOM-MIB', 'junos');
|
|
||||||
d_echo($pre_cache);
|
echo 'JnxDomCurrentLaneEntry ';
|
||||||
}
|
$pre_cache['junos_multilane_oids'] = snmpwalk_cache_multi_oid($device, 'JnxDomCurrentLaneEntry', array(), 'JUNIPER-DOM-MIB', 'junos');
|
||||||
|
@@ -9,7 +9,5 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'pbn') {
|
echo 'ifSfpParameterTable ';
|
||||||
$pre_cache['pbn_oids'] = snmpwalk_cache_multi_oid($device, '.1.3.6.1.4.1.11606.10.9.63.1.7', array(), 'NMS-IF-MIB', 'pbn');
|
$pre_cache['pbn_oids'] = snmpwalk_cache_multi_oid($device, '.1.3.6.1.4.1.11606.10.9.63.1.7', array(), 'NMS-IF-MIB', 'pbn');
|
||||||
d_echo($pre_cache);
|
|
||||||
}
|
|
||||||
|
@@ -10,7 +10,5 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (isset($config['os'][$device['os']]['rfc1628_compat']) && $config['os'][$device['os']]['rfc1628_compat']) {
|
echo 'tlUpsSnmpCardSerialNum ';
|
||||||
$pre_cache['poweralert_serial'] = trim(snmp_get($device, '.1.3.6.1.4.1.850.100.1.1.4.0', '-Ovq', 'TRIPPLITE-MIB'), '"');
|
$pre_cache['poweralert_serial'] = trim(snmp_get($device, '.1.3.6.1.4.1.850.100.1.1.4.0', '-Ovq', 'TRIPPLITE-MIB'), '"');
|
||||||
d_echo($pre_cache);
|
|
||||||
}
|
|
||||||
|
@@ -23,12 +23,8 @@
|
|||||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'powerwalker') {
|
echo 'upsInputEntry ';
|
||||||
echo 'Pre-cache PowerWalker: ';
|
$pre_cache['powerwalker'] = snmpwalk_cache_index($device, 'upsInputEntry', array(), 'UPS-MIB');
|
||||||
|
|
||||||
$pw_oids = array();
|
echo 'upsOutputEntry ';
|
||||||
echo 'Caching OIDs:';
|
$pre_cache['powerwalker'] = snmpwalk_cache_index($device, 'upsOutputEntry', $pre_cache['powerwalker'], 'UPS-MIB');
|
||||||
|
|
||||||
$pw_oids = snmpwalk_cache_index($device, 'upsInputEntry', array(), 'UPS-MIB');
|
|
||||||
$pw_oids = snmpwalk_cache_index($device, 'upsOutputEntry', $pw_oids, 'UPS-MIB');
|
|
||||||
}
|
|
||||||
|
@@ -23,9 +23,11 @@
|
|||||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] === 'vrp') {
|
echo 'hwEntityStateEntry ';
|
||||||
$pre_cache['vrp_oids'] = snmpwalk_cache_index($device, '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1', array(), 'HUAWEI-ENTITY-EXTENT-MIB');
|
$pre_cache['vrp_oids'] = snmpwalk_cache_index($device, '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1', array(), 'HUAWEI-ENTITY-EXTENT-MIB');
|
||||||
$pre_cache['vrp_oids'] = snmpwalk_cache_index($device, '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1', $pre_cache['vrp_oids'], 'HUAWEI-ENTITY-EXTENT-MIB');
|
|
||||||
$pre_cache['vrp_oids'] = snmpwalk_cache_index($device, '.1.3.6.1.2.1.47.1.1.1.1.7', $pre_cache['vrp_oids'], 'HUAWEI-ENTITY-EXTENT-MIB');
|
echo 'hwOpticalModuleInfoEntry ';
|
||||||
d_echo($pre_cache);
|
$pre_cache['vrp_oids'] = snmpwalk_cache_index($device, '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1', $pre_cache['vrp_oids'], 'HUAWEI-ENTITY-EXTENT-MIB');
|
||||||
}
|
|
||||||
|
echo 'entPhysicalName ';
|
||||||
|
$pre_cache['vrp_oids'] = snmpwalk_cache_index($device, '.1.3.6.1.2.1.47.1.1.1.1.7', $pre_cache['vrp_oids'], 'HUAWEI-ENTITY-EXTENT-MIB');
|
||||||
|
@@ -35,13 +35,13 @@ if ($device['os'] === 'powerwalker') {
|
|||||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 1, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 1, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($pw_oids['upsInputVoltage'][1])) {
|
if (is_numeric($pre_cache['powerwalker']['upsInputVoltage'][1])) {
|
||||||
$descr = 'Input Voltage';
|
$descr = 'Input Voltage';
|
||||||
$oid = '.1.3.6.1.2.1.33.1.3.3.1.3.1';
|
$oid = '.1.3.6.1.2.1.33.1.3.3.1.3.1';
|
||||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 2, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 2, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($pw_oids['upsOutputVoltage'][1])) {
|
if (is_numeric($pre_cache['powerwalker']['upsOutputVoltage'][1])) {
|
||||||
$descr = 'Output Voltage';
|
$descr = 'Output Voltage';
|
||||||
$oid = '.1.3.6.1.2.1.33.1.4.4.1.2.1';
|
$oid = '.1.3.6.1.2.1.33.1.4.4.1.2.1';
|
||||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 3, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 3, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
|
||||||
|
Reference in New Issue
Block a user