mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Don't do unneeded snmp queries (#7841)
* Don't do uneeded snmp queries sensors discovery 26 -> 16 wrapped some poller modules in db checks. The same could be done for some others, but more work is needed. * travis fix
This commit is contained in:
committed by
Neil Lathwood
parent
5405498ed6
commit
b9dc7773d7
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
$chip = snmp_get($device, '.1.3.6.1.2.1.1.1.0', '-Oqv');
|
||||
|
||||
if (preg_match("/(Linux).+(ntc)/", $chip)) {
|
||||
if (preg_match("/(Linux).+(ntc)/", $poll_device['sysDescr'])) {
|
||||
$sensor_type = "chip_battery_charge";
|
||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.112.111.119.101.114.45.115.116.97.';
|
||||
$lowlimit = 5;
|
||||
|
||||
@@ -6,7 +6,7 @@ if ($device['os_group'] == 'cisco') {
|
||||
$oids = array();
|
||||
echo 'Caching OIDs:';
|
||||
|
||||
if (!is_array($entity_array)) {
|
||||
if (empty($entity_array)) {
|
||||
$tmp_oids = array('entPhysicalDescr', 'entPhysicalName', 'entPhysicalClass', 'entPhysicalContainedIn', 'entPhysicalParentRelPos');
|
||||
$entity_array = array();
|
||||
foreach ($tmp_oids as $tmp_oid) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
$chip = snmp_get($device, '.1.3.6.1.2.1.1.1.0', '-Oqv');
|
||||
if (preg_match("/(Linux).+(ntc)/", $chip)) {
|
||||
if (preg_match("/(Linux).+(ntc)/", $poll_device['sysDescr'])) {
|
||||
$sensor_type = "chip_currents";
|
||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.112.111.119.101.114.45.115.116.97.';
|
||||
$lowlimit = 0;
|
||||
|
||||
@@ -5,31 +5,40 @@ if (empty($entity_array)) {
|
||||
$entity_array = array();
|
||||
echo ' entPhysicalDescr';
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalDescr', $entity_array, 'CISCO-ENTITY-SENSOR-MIB');
|
||||
echo ' entPhysicalName';
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalName', $entity_array, 'CISCO-ENTITY-SENSOR-MIB');
|
||||
if (!empty($entity_array)) {
|
||||
echo ' entPhysicalName';
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalName', $entity_array, 'CISCO-ENTITY-SENSOR-MIB');
|
||||
}
|
||||
}
|
||||
$oids = array();
|
||||
echo ' entPhySensorType';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorType', $oids, 'ENTITY-SENSOR-MIB');
|
||||
echo ' entPhySensorScale';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorScale', $oids, 'ENTITY-SENSOR-MIB');
|
||||
echo ' entPhySensorPrecision';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorPrecision', $oids, 'ENTITY-SENSOR-MIB');
|
||||
echo ' entPhySensorValue';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorValue', $oids, 'ENTITY-SENSOR-MIB');
|
||||
if ($device['os'] === 'arista_eos') {
|
||||
require 'includes/discovery/sensors/misc/arista-eos-limits.inc.php';
|
||||
|
||||
if (!empty($entity_array)) {
|
||||
$oids = array();
|
||||
echo ' entPhySensorType';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorType', $oids, 'ENTITY-SENSOR-MIB');
|
||||
echo ' entPhySensorScale';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorScale', $oids, 'ENTITY-SENSOR-MIB');
|
||||
echo ' entPhySensorPrecision';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorPrecision', $oids, 'ENTITY-SENSOR-MIB');
|
||||
echo ' entPhySensorValue';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorValue', $oids, 'ENTITY-SENSOR-MIB');
|
||||
if ($device['os'] === 'arista_eos') {
|
||||
require 'includes/discovery/sensors/misc/arista-eos-limits.inc.php';
|
||||
}
|
||||
}
|
||||
$entitysensor['voltsDC'] = 'voltage';
|
||||
$entitysensor['voltsAC'] = 'voltage';
|
||||
$entitysensor['amperes'] = 'current';
|
||||
$entitysensor['watts'] = 'power';
|
||||
$entitysensor['hertz'] = 'freq';
|
||||
$entitysensor['percentRH'] = 'humidity';
|
||||
$entitysensor['rpm'] = 'fanspeed';
|
||||
$entitysensor['celsius'] = 'temperature';
|
||||
$entitysensor['dBm'] = 'dbm';
|
||||
if (is_array($oids)) {
|
||||
|
||||
if (!empty($oids)) {
|
||||
$entitysensor = array(
|
||||
'voltsDC' => 'voltage',
|
||||
'voltsAC' => 'voltage',
|
||||
'amperes' => 'current',
|
||||
'watts' => 'power',
|
||||
'hertz' => 'freq',
|
||||
'percentRH' => 'humidity',
|
||||
'rpm' => 'fanspeed',
|
||||
'celsius' => 'temperature',
|
||||
'dBm' => 'dbm',
|
||||
);
|
||||
|
||||
foreach ($oids as $index => $entry) {
|
||||
$low_limit = null;
|
||||
$low_warn_limit = null;
|
||||
|
||||
@@ -42,9 +42,7 @@ if (starts_with($sysObjectId, '.1.3.6.1.4.1.232.')) {
|
||||
}
|
||||
}
|
||||
|
||||
$chip = snmp_get($device, '.1.3.6.1.2.1.1.1.0', '-Oqv');
|
||||
|
||||
if (preg_match("/(Linux).+(ntc)/", $chip)) {
|
||||
if (preg_match("/(Linux).+(ntc)/", $poll_device['sysDescr'])) {
|
||||
$sensor_type = "chip_axp209_temperature";
|
||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.112.111.119.101.114.45.115.116.97.';
|
||||
$lowlimit = -40;
|
||||
|
||||
@@ -65,8 +65,7 @@ foreach (explode("\n", $oids) as $data) {
|
||||
}//end if
|
||||
}
|
||||
|
||||
$chip = snmp_get($device, '.1.3.6.1.2.1.1.1.0', '-Oqv');
|
||||
if (preg_match("/(Linux).+(ntc)/", $chip)) {
|
||||
if (preg_match("/(Linux).+(ntc)/", $poll_device['sysDescr'])) {
|
||||
$sensor_type = "chip_volts";
|
||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.112.111.119.101.114.45.115.116.97.';
|
||||
$lowlimit = 3.8;
|
||||
|
||||
Reference in New Issue
Block a user