Welcome to PCCS-Linux.COM Hello, and welcome to the PCCS-Linux Home Page.
Your last visit was !!!
Your Browser is running on Other
 
snmptable getmac
Some of the data gets mangled but you have a db of MAC-IPS
USAGE: getips.sh router community


Create a MySQL table:

DROP TABLE IF EXISTS ipmac;
CREATE TABLE ipmac (
  ipaddr varchar(25),
  macaddr varchar(25)
);


#!/bin/sh

insert() {
 mysql test -uuserid -ppassword -e "INSERT INTO ipmac VALUES('$2','$1')"
}

snmptable $1 $2 at.atTable| grep -v at | awk '{print $2 $3 $4 $5 $6 $7 "\t" $9}' | \
 sed 's/"//g' | grep -v at |  while read ipmacs; do

   insert $ipmacs

done



PHP front end to data



<?php

$f=mysql_connect("localhost","userid","password") or die("Database is DOWN");
if($submit) {
 if($mode == "all") {
$query = "SELECT * from ipmac";
} else {
$query = "SELECT * from ipmac WHERE macaddr = '$macaddr'";
}
$res=mysql_db_query("test",$query);
$totalips = mysql_numrows($res);

if(!$res) {
 print "ERROR: " . mysql_error();
} else {
 print "<TABLE>";
 print "<TR><TH>Ipaddress</TH><TH>MAC Address</TH></TR>";
 while($row=mysql_fetch_array($res)) {
   print "<tr><td>" . $row[0] . "</td><td>" . $row[1] . "</td></tr>";
 }
 print "</TABLE>";
}
} else {
  print "Search for a MAC address";
  print "<FORM ACTION=$PHP_SELF METHOD=post>";
  print "MAC ADDR: <INPUT TYPE=text NAME=macaddr>";
  print "Display ALL: <INPUT TYPE=checkbox NAME=mode VALUE=all>";
  print "<INPUT TYPE=submit NAME=submit VALUE=\"GET IPADDR\">";
}

?>


>> Comments/FeedBack


Page hits 52 on :12:09



This web site is prepared and maintained by Chauncey Thorn.
The information contained in this site was valid at the time of posting.
Chauncey Thorn, assumes no liability for damages incurred directly or indirectly as a result of errors, omissions or discrepancies.

Remember most of the content here are my notes...

All logos and trademarks in this site are property of their respective owner. All the rest © by PCCS-Linux.COM

PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002