Location: PHPKode > projects > Network Asset Management Archive > nama/portarp2.php
<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";
$stmt = "Select * FROM switches where switch_type='3COM';";
$sth = ibase_query($dbh, $stmt);
while ($row = ibase_fetch_object($sth)) {
//$interface = snmpwalk($row->IP_ADDRESS, "$row->SNMPSTRING",".1.3.6.1.2.1.4.22.1.1");
$macaddress = snmpwalk($row->IP_ADDRESS, "$row->SNMPSTRING",".1.3.6.1.2.1.16.4.2.1.1");
//$ipaddress = snmpwalk($row->IP_ADDRESS, "$row->SNMPSTRING",".1.3.6.1.2.1.4.22.1.3");
$interfacetable = snmpwalk($row->IP_ADDRESS, "$row->SNMPSTRING",".1.3.6.1.2.1.2.2.1.2");
$now = date("m/j/y h:i:s",time());
$host = $row->IP_ADDRESS;
$community = "$row->SNMPSTRING";
$sysDescr = snmpget("$host","$community","system.sysDescr.0");
print '<META HTTP-EQUIV="refresh" CONTENT="600">';
print '<body bgcolor="#FFFFCC" text="#000000">';                                         
echo $now . "<br>";
print "<table border=1 bgcolor=#ffffcc><tr><td>$host</td></tr></table>
";
print "<table border=1 bgcolor=#ffffcc><tr><td>$sysDescr</td></tr></table>
";
print "<table border=1 bgcolor=#ffffcc>";
print "<tr> 
       <td>ifIndex</td>
       <td>MAC Address</td>
       <td>IP Integer</td>
       </tr>";
            
for ($i=0; $i<count($macaddress); $i++) {
       print "<tr>";
       print "<td>$interfacetable[$i]</td>";
       list ($junk, $mymac) = split("Hex: ", $macaddress[$i]);
       $mymac = ereg_replace(' ', '',$mymac);
       print "<td>" . $mymac . "</td>";
       for ($j=0; $j<count($interfacetable); $j++) {
          $thisinterface = explode(".", $interfacetable[$j]);
         list ($thisportnumber, $thisportname) = split("= ", $thisinterface[4]);
//         print $thisportnum; 
          if (trim($thisportnumber) == trim($portnum)) {
              $thisportdesc=$thisportname;
          }
       }
       print "<td>" . $thisportdesc . "</td>";
//       print "<td>" . $interfacetable[$i] . "</td>";
       if (($mymac != 'ffffffffffff') && ($mymac != ''))
       {
//            $stmt3 = "update arp_table set switch = '$host', switch_port = '$thisportdesc' where mac_address = '$mymac';";
//            $sth3 = ibase_query($dbh, $stmt3);

       }
 print "</tr>";
}            
print "</table>";

}
ibase_free_result($sth);
ibase_close($dbh);
?>

Return current item: Network Asset Management Archive