2008-03-12 17:12:17 +00:00
< ? php
2009-01-09 15:00:17 +00:00
echo ( " Physical Inventory : " );
if ( $config [ 'enable_inventory' ]) {
2008-03-12 17:12:17 +00:00
2009-04-28 10:28:58 +00:00
$ents_cmd = $config [ 'snmpbulkwalk' ] . " -m ENTITY-MIB -O qn - " . $device [ 'snmpver' ] . " -c " . $device [ 'community' ] . " " . $device [ 'hostname' ] . " : " . $device [ '$port' ] . " " ;
2008-03-12 17:12:17 +00:00
$ents_cmd .= " 1.3.6.1.2.1.47.1.1.1.1.2 | sed s/.1.3.6.1.2.1.47.1.1.1.1.2.//g | cut -f 1 -d \" \" " ;
$ents = trim ( `$ents_cmd | grep -v o` );
2009-01-09 15:00:17 +00:00
foreach ( explode ( " \n " , $ents ) as $entPhysicalIndex ) {
2008-03-12 17:12:17 +00:00
2009-04-24 15:04:45 +00:00
$ent_data = $config [ 'snmpget' ] . " -m ENTITY-MIB -Ovqs - " ;
2009-02-02 16:00:11 +00:00
$ent_data .= $device [ 'snmpver' ] . " -c " . $device [ 'community' ] . " " . $device [ 'hostname' ] . " : " . $device [ 'port' ];
2008-03-12 17:12:17 +00:00
$ent_data .= " entPhysicalDescr. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalContainedIn. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalClass. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalName. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalSerialNum. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalModelName. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalMfgName. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalVendorType. " . $entPhysicalIndex ;
$ent_data .= " entPhysicalParentRelPos. " . $entPhysicalIndex ;
$ent_data .= " entAliasMappingIdentifier. " . $entPhysicalIndex . " .0 " ;
list ( $entPhysicalDescr , $entPhysicalContainedIn , $entPhysicalClass , $entPhysicalName , $entPhysicalSerialNum , $entPhysicalModelName , $entPhysicalMfgName , $entPhysicalVendorType , $entPhysicalParentRelPos , $ifIndex ) = explode ( " \n " , `$ent_data` );
if ( strpos ( $ifIndex , " o " ) || $ifIndex == " " ) { unset ( $ifIndex ); }
$entPhysicalModelName = trim ( $entPhysicalModelName );
$entPhysicalSerialNum = trim ( $entPhysicalSerialNum );
$entPhysicalMfgName = trim ( $entPhysicalMfgName );
$entPhysicalVendorType = trim ( $entPhysicalVendorType );
if ( $entPhysicalVendorTypes [ $entPhysicalVendorType ] && ! $entPhysicalModelName ) {
$entPhysicalModelName = $entPhysicalVendorTypes [ $entPhysicalVendorType ];
}
2008-03-22 23:09:35 +00:00
#echo("$entPhysicalIndex,$entPhysicalDescr,$entPhysicalContainedIn,$entPhysicalSerialNum,");
#echo("$entPhysicalClass,$entPhysicalName,$entPhysicalModelName,$entPhysicalMfgName,$entPhysicalVendorType,$entPhysicalParentRelPos\n");
2008-03-12 17:12:17 +00:00
if ( mysql_result ( mysql_query ( " SELECT COUNT(*) FROM `entPhysical` WHERE device_id = ' " . $device [ 'device_id' ] . " ' AND entPhysicalIndex = ' $entPhysicalIndex ' " ), 0 )) {
2008-03-22 23:09:35 +00:00
### TO DO : WRITE CODE FOR UPDATES!
echo ( " . " );
2008-03-12 17:12:17 +00:00
} else {
$sql = " INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `ifIndex` ) " ;
$sql .= " VALUES ( ' " . $device [ 'device_id' ] . " ', ' $entPhysicalIndex ', ' $entPhysicalDescr ', ' $entPhysicalClass ', ' $entPhysicalName ', ' $entPhysicalModelName ', ' $entPhysicalSerialNum ', ' $entPhysicalContainedIn ', ' $entPhysicalMfgName ',' $entPhysicalParentRelPos ' , ' $entPhysicalVendorType ', ' $ifIndex ') " ;
mysql_query ( $sql );
2008-03-22 23:09:35 +00:00
echo ( " + " );
2008-03-12 17:12:17 +00:00
}
}
2009-01-09 15:00:17 +00:00
} else { echo ( " Disabled! " ); }
echo ( " \n " );
2008-03-12 17:12:17 +00:00
?>