Commit version 24.12.13800
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -15,62 +15,69 @@
|
||||
|
||||
function custom_port_parser($port) {
|
||||
|
||||
if (safe_empty($port['ifAlias'])) { return []; }
|
||||
if (safe_empty($port['ifAlias'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
print_debug($port['ifAlias']);
|
||||
print_debug($port['ifAlias']);
|
||||
|
||||
$types = [ 'core', 'peering', 'transit', 'cust', 'server', 'l2tp', 'service' ];
|
||||
foreach ($GLOBALS['config']['int_groups'] as $custom_type) {
|
||||
$types[] = strtolower(trim($custom_type));
|
||||
}
|
||||
//$types = ['core', 'peering', 'transit', 'cust', 'server', 'l2tp', 'service'];
|
||||
$types = array_keys($GLOBALS['config']['ports']['descr_groups']); // base (still configurable) interface groups
|
||||
foreach ($GLOBALS['config']['int_groups'] as $custom_type) {
|
||||
$types[] = strtolower(trim($custom_type));
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['config']['port_descr_regexp'])) {
|
||||
$port_ifAlias = [];
|
||||
$params = [ 'type', 'descr', 'circuit', 'speed', 'notes' ];
|
||||
foreach ((array)$GLOBALS['config']['port_descr_regexp'] as $pattern) {
|
||||
if (preg_match($pattern, $port['ifAlias'], $matches)) {
|
||||
foreach ($params as $param) {
|
||||
if (!safe_empty($matches[$param])) {
|
||||
$port_ifAlias[$param] = $matches[$param];
|
||||
}
|
||||
if (isset($GLOBALS['config']['port_descr_regexp'])) {
|
||||
$port_ifAlias = [];
|
||||
$params = [ 'type', 'descr', 'circuit', 'speed', 'notes' ];
|
||||
foreach ((array)$GLOBALS['config']['port_descr_regexp'] as $pattern) {
|
||||
if (preg_match($pattern, $port['ifAlias'], $matches)) {
|
||||
foreach ($params as $param) {
|
||||
if (!safe_empty($matches[$param])) {
|
||||
$port_ifAlias[$param] = $matches[$param];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($port_ifAlias['type'], $port_ifAlias['descr']) && in_array($port_ifAlias['type'], $types, TRUE)) {
|
||||
return $port_ifAlias;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($port_ifAlias['type'], $port_ifAlias['descr']) && in_array($port_ifAlias['type'], $types, TRUE)) {
|
||||
return $port_ifAlias;
|
||||
|
||||
// Pull out Type and Description or abort
|
||||
if (!preg_match('/^([^:]+)[:_]([^\[\]\(\)\{\}]+)/', $port['ifAlias'], $matches)) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Pull out Type and Description or abort
|
||||
if (!preg_match('/^([^:]+)[:_]([^\[\]\(\)\{\}]+)/', $port['ifAlias'], $matches)) {
|
||||
return [];
|
||||
}
|
||||
$port_ifAlias = [];
|
||||
// Munge and Validate type
|
||||
$type = strtolower(trim($matches[1], " \t\n\r\0\x0B\\/\"'"));
|
||||
if (!in_array($type, $types, TRUE)) {
|
||||
return [];
|
||||
}
|
||||
$port_ifAlias['type'] = $type;
|
||||
|
||||
$port_ifAlias = [];
|
||||
// Munge and Validate type
|
||||
$type = strtolower(trim($matches[1], " \t\n\r\0\x0B\\/\"'"));
|
||||
if (!in_array($type, $types, TRUE)) { return []; }
|
||||
$port_ifAlias['type'] = $type;
|
||||
// Munge and Validate description
|
||||
$descr = trim($matches[2]);
|
||||
if (safe_empty($descr)) {
|
||||
return [];
|
||||
}
|
||||
$port_ifAlias['descr'] = $descr;
|
||||
|
||||
// Munge and Validate description
|
||||
$descr = trim($matches[2]);
|
||||
if (safe_empty($descr)) { return []; }
|
||||
$port_ifAlias['descr'] = $descr;
|
||||
if (preg_match('/\{(.*?)\}/', $port['ifAlias'], $matches)) {
|
||||
$port_ifAlias['circuit'] = $matches[1];
|
||||
}
|
||||
if (preg_match('/\[(.*?)\]/', $port['ifAlias'], $matches)) {
|
||||
$port_ifAlias['speed'] = $matches[1];
|
||||
}
|
||||
if (preg_match('/\((.*?)\)/', $port['ifAlias'], $matches)) {
|
||||
$port_ifAlias['notes'] = $matches[1];
|
||||
}
|
||||
|
||||
if (preg_match('/\{(.*?)\}/', $port['ifAlias'], $matches)) {
|
||||
$port_ifAlias['circuit'] = $matches[1];
|
||||
}
|
||||
if (preg_match('/\[(.*?)\]/', $port['ifAlias'], $matches)) {
|
||||
$port_ifAlias['speed'] = $matches[1];
|
||||
}
|
||||
if (preg_match('/\((.*?)\)/', $port['ifAlias'], $matches)) {
|
||||
$port_ifAlias['notes'] = $matches[1];
|
||||
}
|
||||
print_debug_vars($port_ifAlias);
|
||||
|
||||
print_debug_vars($port_ifAlias);
|
||||
|
||||
return $port_ifAlias;
|
||||
return $port_ifAlias;
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
Reference in New Issue
Block a user