From d722bb6943d52202184dbe74b5c91cacba102f3a Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 30 Jul 2016 15:11:29 +0100 Subject: [PATCH] Update use of max repeaters to save mysql queries --- includes/discovery/functions.inc.php | 1 + includes/polling/functions.inc.php | 1 + includes/snmp.inc.php | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 0a135d2a63..0c2373cda7 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -89,6 +89,7 @@ function discover_device($device, $options = null) { $valid = array(); // Reset $valid array $attribs = get_dev_attribs($device['device_id']); + $device['snmp_max_repeaters'] = $attribs['snmp_max_repeaters']; $device_start = microtime(true); // Start counting device poll time diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index fb2d52271e..a6fbfa4594 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -152,6 +152,7 @@ function poll_device($device, $options) { global $config, $device, $polled_devices, $db_stats, $memcache; $attribs = get_dev_attribs($device['device_id']); + $device['snmp_max_repeaters'] = $attribs['snmp_max_repeaters']; $status = 0; unset($array); diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 13bf3de5d1..3404caa030 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -167,7 +167,7 @@ function snmp_walk($device, $oid, $options=null, $mib=null, $mibdir=null) { } else { $snmpcommand = $config['snmpbulkwalk']; - $max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters'); + $max_repeaters = $device['snmp_max_repeaters']; if ($max_repeaters > 0) { $snmpcommand .= " -Cr$max_repeaters "; } @@ -234,7 +234,7 @@ function snmpwalk_cache_cip($device, $oid, $array=array(), $mib=0) { } else { $snmpcommand = $config['snmpbulkwalk']; - $max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters'); + $max_repeaters = $device['snmp_max_repeaters']; if ($max_repeaters > 0) { $snmpcommand .= " -Cr$max_repeaters "; } @@ -309,7 +309,7 @@ function snmp_cache_ifIndex($device) { } else { $snmpcommand = $config['snmpbulkwalk']; - $max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters'); + $max_repeaters = $device['snmp_max_repeaters']; if ($max_repeaters > 0) { $snmpcommand .= " -Cr$max_repeaters "; } @@ -473,7 +473,7 @@ function snmpwalk_cache_twopart_oid($device, $oid, $array, $mib=0) { } else { $snmpcommand = $config['snmpbulkwalk']; - $max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters'); + $max_repeaters = $device['snmp_max_repeaters']; if ($max_repeaters > 0) { $snmpcommand .= " -Cr$max_repeaters "; } @@ -531,7 +531,7 @@ function snmpwalk_cache_threepart_oid($device, $oid, $array, $mib=0) { } else { $snmpcommand = $config['snmpbulkwalk']; - $max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters'); + $max_repeaters = $device['snmp_max_repeaters']; if ($max_repeaters > 0) { $snmpcommand .= " -Cr$max_repeaters "; } @@ -593,7 +593,7 @@ function snmp_cache_slotport_oid($oid, $device, $array, $mib=0) { } else { $snmpcommand = $config['snmpbulkwalk']; - $max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters'); + $max_repeaters = $device['snmp_max_repeaters']; if ($max_repeaters > 0) { $snmpcommand .= " -Cr$max_repeaters "; }