From 465372b28dc290e52f02f614f57fbc6706f88a8d Mon Sep 17 00:00:00 2001 From: Oirbsiu Date: Mon, 6 Jul 2020 14:59:53 +0100 Subject: [PATCH] Correct interface names in response to the SNMP query of cpwVcName (#11851) * Update cisco-pw.inc.php To correct Interface names that use escaped '/' e.g. GigabitEthernet0_4_0_12 and translate the underscore back to a slash - e.g. GigabitEthernet0/4/0/12 * Update cisco-pw.inc.php * Update cisco-pw.inc.php * Update cisco-pw.inc.php * Update cisco-pw.inc.php --- includes/discovery/cisco-pw.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/includes/discovery/cisco-pw.inc.php b/includes/discovery/cisco-pw.inc.php index 4213175353..f3d56505ae 100644 --- a/includes/discovery/cisco-pw.inc.php +++ b/includes/discovery/cisco-pw.inc.php @@ -20,6 +20,13 @@ if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') { $pws = snmpwalk_cache_oid($device, 'cpwVcMplsPeerLdpID', $pws, 'CISCO-IETF-PW-MPLS-MIB'); foreach ($pws as $pw_id => $pw) { + // Added By Oirbsiu + // To correct Interface names that use escaped '/' e.g. GigabitEthernet0_4_0_12 + // and translate the underscore back to a slash - e.g. GigabitEthernet0/4/0/12 + // Thank you @murrant + $pw['cpwVcName'] = preg_replace('/(?<=\d)_(?=\d)/', '/', $pw['cpwVcName']); + // END + list($cpw_remote_id) = explode(':', $pw['cpwVcMplsPeerLdpID']); $cpw_remote_device = dbFetchCell('SELECT device_id from ipv4_addresses AS A, ports AS I WHERE A.ipv4_address=? AND A.port_id=I.port_id', array($cpw_remote_id)); $if_id = dbFetchCell('SELECT port_id from ports WHERE `ifDescr`=? AND `device_id`=?', array($pw['cpwVcName'], $device['device_id']));