mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-03 00:11:49 +02:00
Add Juniper inventory support
This commit is contained in:
@@ -1,19 +1,48 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo("Physical Inventory : ");
|
|
||||||
|
|
||||||
if ($config['enable_inventory']) {
|
if ($config['enable_inventory']) {
|
||||||
|
|
||||||
|
echo("Physical Inventory : ");
|
||||||
|
|
||||||
echo("\nCaching OIDs:");
|
echo("\nCaching OIDs:");
|
||||||
|
|
||||||
|
if ($device['os'] == 'junos') {
|
||||||
|
|
||||||
|
$entity_array = array();
|
||||||
|
echo(" jnxBoxAnatomy");
|
||||||
|
$entity_array = snmpwalk_cache_oid($device, "jnxBoxAnatomy", $entity_array, "JUNIPER-MIB");
|
||||||
|
} else {
|
||||||
|
|
||||||
$entity_array = array();
|
$entity_array = array();
|
||||||
echo(" entPhysicalEntry");
|
echo(" entPhysicalEntry");
|
||||||
$entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, "ENTITY-MIB:CISCO-ENTITY-VENDORTYPE-OID-MIB");
|
$entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, "ENTITY-MIB:CISCO-ENTITY-VENDORTYPE-OID-MIB");
|
||||||
echo(" entAliasMappingIdentifier");
|
echo(" entAliasMappingIdentifier");
|
||||||
$entity_array = snmpwalk_cache_twopart_oid($device, "entAliasMappingIdentifier", $entity_array, "ENTITY-MIB:IF-MIB");
|
$entity_array = snmpwalk_cache_twopart_oid($device, "entAliasMappingIdentifier", $entity_array, "ENTITY-MIB:IF-MIB");
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($entity_array as $entPhysicalIndex => $entry) {
|
foreach ($entity_array as $entPhysicalIndex => $entry) {
|
||||||
|
|
||||||
|
if ($device['os'] == 'junos') {
|
||||||
|
|
||||||
|
// Juniper's MIB doesn't have the same objects as the Entity MIB, so some values
|
||||||
|
// are made up here.
|
||||||
|
$entPhysicalDescr = $entry['jnxContentsDescr'];
|
||||||
|
$entPhysicalContainedIn = $entry['jnxContainersWithin'];
|
||||||
|
$entPhysicalClass = $entry['jnxBoxClass'];
|
||||||
|
$entPhysicalName = $entry['jnxOperatingDescr'];
|
||||||
|
$entPhysicalSerialNum = $entry['jnxContentsSerialNo'];
|
||||||
|
$entPhysicalModelName = $entry['jnxContentsPartNo'];
|
||||||
|
$entPhysicalMfgName = 'Juniper';
|
||||||
|
$entPhysicalVendorType = 'Juniper';
|
||||||
|
$entPhysicalParentRelPos = -1;
|
||||||
|
$entPhysicalHardwareRev = $entry['jnxContentsRevision'];
|
||||||
|
$entPhysicalFirmwareRev = $entry['entPhysicalFirmwareRev'];
|
||||||
|
$entPhysicalSoftwareRev = $entry['entPhysicalSoftwareRev'];
|
||||||
|
$entPhysicalIsFRU = $entry['jnxFruType'];
|
||||||
|
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
||||||
|
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
||||||
|
} else {
|
||||||
|
|
||||||
$entPhysicalDescr = $entry['entPhysicalDescr'];
|
$entPhysicalDescr = $entry['entPhysicalDescr'];
|
||||||
$entPhysicalContainedIn = $entry['entPhysicalContainedIn'];
|
$entPhysicalContainedIn = $entry['entPhysicalContainedIn'];
|
||||||
$entPhysicalClass = $entry['entPhysicalClass'];
|
$entPhysicalClass = $entry['entPhysicalClass'];
|
||||||
@@ -29,6 +58,7 @@
|
|||||||
$entPhysicalIsFRU = $entry['entPhysicalIsFRU'];
|
$entPhysicalIsFRU = $entry['entPhysicalIsFRU'];
|
||||||
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
||||||
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'])) {
|
if (isset($entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'])) {
|
||||||
$ifIndex = $entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'];
|
$ifIndex = $entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'];
|
||||||
@@ -41,15 +71,13 @@
|
|||||||
$ifIndex = $ifIndex_array[1];
|
$ifIndex = $ifIndex_array[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName)
|
if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName) {
|
||||||
{
|
|
||||||
$entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType];
|
$entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType];
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - dbFacile
|
// FIXME - dbFacile
|
||||||
|
|
||||||
if ($entPhysicalDescr || $entPhysicalName)
|
if ($entPhysicalDescr || $entPhysicalName) {
|
||||||
{
|
|
||||||
$entPhysical_id = dbFetchCell("SELECT entPhysical_id FROM `entPhysical` WHERE device_id = ? AND entPhysicalIndex = ?",array($device['device_id'], $entPhysicalIndex));
|
$entPhysical_id = dbFetchCell("SELECT entPhysical_id FROM `entPhysical` WHERE device_id = ? AND entPhysicalIndex = ?",array($device['device_id'], $entPhysicalIndex));
|
||||||
|
|
||||||
if ($entPhysical_id) {
|
if ($entPhysical_id) {
|
||||||
@@ -102,15 +130,25 @@
|
|||||||
echo("+");
|
echo("+");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else { echo("Disabled!"); }
|
} else { echo("Disabled!"); }
|
||||||
|
|
||||||
$sql = "SELECT * FROM `entPhysical` WHERE `device_id` = '".$device['device_id']."'";
|
$sql = "SELECT * FROM `entPhysical` WHERE `device_id` = '".$device['device_id']."'";
|
||||||
foreach (dbFetchRows($sql) as $test)
|
foreach (dbFetchRows($sql) as $test) {
|
||||||
{
|
|
||||||
$id = $test['entPhysicalIndex'];
|
$id = $test['entPhysicalIndex'];
|
||||||
if (!$valid[$id]) {
|
if (!$valid[$id]) {
|
||||||
echo("-");
|
echo("-");
|
||||||
@@ -119,5 +157,4 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo("\n");
|
echo("\n");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user