2008-03-12 17:12:17 +00:00
< ? php
2009-01-09 15:00:17 +00:00
echo ( " Physical Inventory : " );
2011-03-15 11:39:50 +00:00
if ( $config [ 'enable_inventory' ]) {
2008-03-12 17:12:17 +00:00
2010-08-11 17:08:56 +00:00
echo ( " \n Caching OIDs: " );
$entity_array = array ();
echo ( " entPhysicalEntry " );
2011-04-26 22:25:35 +00:00
$entity_array = snmpwalk_cache_oid ( $device , " entPhysicalEntry " , $entity_array , " ENTITY-MIB:CISCO-ENTITY-VENDORTYPE-OID-MIB " );
2010-08-11 17:08:56 +00:00
echo ( " entAliasMappingIdentifier " );
$entity_array = snmpwalk_cache_twopart_oid ( $device , " entAliasMappingIdentifier " , $entity_array , " ENTITY-MIB:IF-MIB " );
2009-11-28 09:48:23 +00:00
2011-03-15 11:39:50 +00:00
foreach ( $entity_array as $entPhysicalIndex => $entry ) {
2008-03-12 17:12:17 +00:00
2011-09-20 14:22:34 +00:00
$entPhysicalDescr = $entry [ 'entPhysicalDescr' ];
$entPhysicalContainedIn = $entry [ 'entPhysicalContainedIn' ];
$entPhysicalClass = $entry [ 'entPhysicalClass' ];
$entPhysicalName = $entry [ 'entPhysicalName' ];
$entPhysicalSerialNum = $entry [ 'entPhysicalSerialNum' ];
$entPhysicalModelName = $entry [ 'entPhysicalModelName' ];
$entPhysicalMfgName = $entry [ 'entPhysicalMfgName' ];
$entPhysicalVendorType = $entry [ 'entPhysicalVendorType' ];
$entPhysicalParentRelPos = $entry [ 'entPhysicalParentRelPos' ];
$entPhysicalHardwareRev = $entry [ 'entPhysicalHardwareRev' ];
$entPhysicalFirmwareRev = $entry [ 'entPhysicalFirmwareRev' ];
$entPhysicalSoftwareRev = $entry [ 'entPhysicalSoftwareRev' ];
$entPhysicalIsFRU = $entry [ 'entPhysicalIsFRU' ];
$entPhysicalAlias = $entry [ 'entPhysicalAlias' ];
2009-11-28 09:48:23 +00:00
$entPhysicalAssetID = $entry [ 'entPhysicalAssetID' ];
2011-03-15 11:39:50 +00:00
if ( isset ( $entity_array [ '$entPhysicalIndex' ][ '0' ][ 'entAliasMappingIdentifier' ])) { $ifIndex = $entity_array [ '$entPhysicalIndex' ][ '0' ][ 'entAliasMappingIdentifier' ]; }
2009-11-10 19:28:24 +00:00
2011-03-15 11:39:50 +00:00
if ( ! strpos ( $ifIndex , " fIndex " ) || $ifIndex == " " ) { unset ( $ifIndex ); }
2009-05-11 13:43:59 +00:00
list (, $ifIndex ) = explode ( " . " , $ifIndex );
2008-03-12 17:12:17 +00:00
2010-01-10 16:03:48 +00:00
if ( $entPhysicalVendorTypes [ $entPhysicalVendorType ] && ! $entPhysicalModelName )
{
2008-03-12 17:12:17 +00:00
$entPhysicalModelName = $entPhysicalVendorTypes [ $entPhysicalVendorType ];
2011-03-16 17:53:20 +00:00
}
2008-03-12 17:12:17 +00:00
2012-05-25 12:24:34 +00:00
// FIXME - dbFacile
2012-05-02 17:23:27 +00:00
2010-01-10 16:03:48 +00:00
if ( $entPhysicalDescr || $entPhysicalName )
{
2014-01-13 17:43:58 +00:00
$entPhysical_id = dbFetchCell ( " SELECT entPhysical_id FROM `entPhysical` WHERE devicee_id = ? AND entPhysicalIndex = ? " , array ( $device [ 'device_id' ], $entPhysicalIndex ));
2010-01-10 16:03:48 +00:00
2011-03-15 11:39:50 +00:00
if ( $entPhysical_id ) {
2014-01-13 17:43:58 +00:00
dbUpdate ( array ( 'entPhysicalIndex' => $entPhysicalIndex , 'entPhysicalDescr' => $entPhysicalDescr , 'entPhysicalClass' => $entPhysicalClass , 'entPhysicalName' => $entPhysicalName , 'entPhysicalModelName' => $entPhysicalModelName , 'entPhysicalSerialNum' => $entPhysicalSerialNum , 'entPhysicalContainedIn' => $entPhysicalContainedIn , 'entPhysicalMfgName' => $entPhysicalMfgName , 'entPhysicalParentRelPos' => $entPhysicalParentRelPos , 'entPhysicalVendorType' => $entPhysicalVendorType , 'entPhysicalHardwareRev' => $entPhysicalHardwareRev , 'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev , 'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev , 'entPhysicalIsFRU' => $entPhysicalIsFRU , 'entPhysicalAlias' => $entPhysicalAlias , 'entPhysicalAssetID' => $entPhysicalAssetID ), 'entPhysical' , 'device_id=? AND entPhysicalIndex=?' , array ( $device [ 'device_id' ], $entPhysicalIndex ));
2010-01-10 16:03:48 +00:00
echo ( " . " );
} else {
2014-06-10 22:21:10 +01:00
dbInsert ( array ( 'device_id' => $device [ 'device_id' ], 'entPhysicalIndex' => $entPhysicalIndex , 'entPhysicalDescr' => $entPhysicalDescr , 'entPhysicalClass' => $entPhysicalClass , 'entPhysicalName' => $entPhysicalName , 'entPhysicalModelName' => $entPhysicalModelName , 'entPhysicalSerialNum' => $entPhysicalSerialNum , 'entPhysicalContainedIn' => $entPhysicalContainedIn , 'entPhysicalMfgName' => $entPhysicalMfgName , 'entPhysicalParentRelPos' => $entPhysicalParentRelPos , 'entPhysicalVendorType' => $entPhysicalVendorType , 'entPhysicalHardwareRev' => $entPhysicalHardwareRev , 'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev , 'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev , 'entPhysicalIsFRU' => $entPhysicalIsFRU , 'entPhysicalAlias' => $entPhysicalAlias , 'entPhysicalAssetID' => $entPhysicalAssetID , 'ifIndex' => $ifIndex ), 'entPhysical' );
2010-01-10 16:03:48 +00:00
echo ( " + " );
}
2009-11-10 19:28:24 +00:00
2010-01-10 16:03:48 +00:00
$valid [ $entPhysicalIndex ] = 1 ;
2009-05-06 16:50:51 +00:00
}
2008-03-12 17:12:17 +00:00
}
2009-01-09 15:00:17 +00:00
} else { echo ( " Disabled! " ); }
2009-05-06 16:50:51 +00:00
$sql = " SELECT * FROM `entPhysical` WHERE `device_id` = ' " . $device [ 'device_id' ] . " ' " ;
2014-01-13 17:43:58 +00:00
foreach ( dbFetchRows ( $sql ) as $test )
{
2009-05-11 13:43:59 +00:00
$id = $test [ 'entPhysicalIndex' ];
2011-03-15 11:39:50 +00:00
if ( ! $valid [ $id ]) {
2009-05-06 16:50:51 +00:00
echo ( " - " );
2014-06-10 22:21:10 +01:00
dbDelete ( 'entPhysical' , 'entPhysical_id = ?' , array ( $test [ 'entPhysical_id' ]));
2009-05-06 16:50:51 +00:00
}
}
2009-01-09 15:00:17 +00:00
echo ( " \n " );
2008-03-12 17:12:17 +00:00
?>