From 8b1dc95d834a11e5bf344c1ab7274caef3f3a5ff Mon Sep 17 00:00:00 2001 From: Rick Hodger Date: Fri, 20 Nov 2015 10:47:47 +0000 Subject: [PATCH 1/3] Issue 1865, Juniper hardware inventory fix --- includes/discovery/entity-physical.inc.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index 812be65ff..e8e1f8d8b 100644 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -37,6 +37,9 @@ if ($config['enable_inventory']) { $entPhysicalIsFRU = $entry['jnxFruType']; $entPhysicalAlias = $entry['entPhysicalAlias']; $entPhysicalAssetID = $entry['entPhysicalAssetID']; + // fix for issue 1865, $entPhysicalIndex, as it contains a quad dotted number on newer Junipers + // using str_replace to remove all dots should fix this even if it changes in future + $entPhysicalIndex = str_replace('.','',$entPhysicalIndex); } else { $entPhysicalDescr = $entry['entPhysicalDescr']; @@ -127,18 +130,19 @@ if ($config['enable_inventory']) { echo '+'; }//end if - if ($device['os'] == 'junos') { + // This entire if/else statement is no longer necessary as we fix $entPhysicalIndex at the start of the loop + //if ($device['os'] == 'junos') { // $entPhysicalIndex appears as a numeric OID fragment // (string), so convert it to an "integer" for the // validation step below since it is stored in the DB as // an integer. This should be fixed. - list($first,$second) = explode('.', $entPhysicalIndex); - $entPhysicalIndexNoDots = $first.$second; - $valid[$entPhysicalIndexNoDots] = 1; - } - else { + //list($first,$second) = explode('.', $entPhysicalIndex); + //$entPhysicalIndexNoDots = $first.$second; + //$valid[$entPhysicalIndexNoDots] = 1; + //} + //else { $valid[$entPhysicalIndex] = 1; - } + //} }//end if }//end foreach } From 8c4baaacfda1748f277791a35ddee352a509eca4 Mon Sep 17 00:00:00 2001 From: Rick Hodger Date: Fri, 20 Nov 2015 13:03:01 +0000 Subject: [PATCH 2/3] Removed commented code. --- includes/discovery/entity-physical.inc.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index e8e1f8d8b..caacb5be2 100644 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -130,19 +130,7 @@ if ($config['enable_inventory']) { echo '+'; }//end if - // This entire if/else statement is no longer necessary as we fix $entPhysicalIndex at the start of the loop - //if ($device['os'] == 'junos') { - // $entPhysicalIndex appears as a numeric OID fragment - // (string), so convert it to an "integer" for the - // validation step below since it is stored in the DB as - // an integer. This should be fixed. - //list($first,$second) = explode('.', $entPhysicalIndex); - //$entPhysicalIndexNoDots = $first.$second; - //$valid[$entPhysicalIndexNoDots] = 1; - //} - //else { - $valid[$entPhysicalIndex] = 1; - //} + $valid[$entPhysicalIndex] = 1; }//end if }//end foreach } From 22f8456d055a671108a7c882d6506a2a9e1967dc Mon Sep 17 00:00:00 2001 From: Rick Hodger Date: Fri, 20 Nov 2015 13:05:29 +0000 Subject: [PATCH 3/3] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 826311481..230f379a4 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -71,4 +71,5 @@ Contributors to LibreNMS: - Tony Murray (murrant) - Peter Lamperud (vizay) - Louis Bailleul (alucardfh) +- Rick Hodger (Tatermen) [1]: http://observium.org/ "Observium web site"