mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
snmp_walk remove multiple No more variables (#8050)
Optimize code so it is a faster when no more variables is not present. Only saving 10s of microseconds, but better than an increase.
This commit is contained in:
@@ -381,11 +381,9 @@ function snmp_walk($device, $oid, $options = null, $mib = null, $mibdir = null)
|
||||
if (is_string($data) && (preg_match('/No Such (Object|Instance)/i', $data))) {
|
||||
$data = false;
|
||||
} else {
|
||||
if (preg_match('/No more variables left in this MIB View \(It is past the end of the MIB tree\)$/', $data)) {
|
||||
// Bit ugly :-(
|
||||
$d_ex = explode("\n", $data);
|
||||
unset($d_ex[(count($d_ex) - 1)]);
|
||||
$data = implode("\n", $d_ex);
|
||||
if (ends_with($data, '(It is past the end of the MIB tree)')) {
|
||||
$no_more_pattern = '/.*No more variables left in this MIB View \(It is past the end of the MIB tree\)[\n]?/';
|
||||
$data = preg_replace($no_more_pattern, '', $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user