Welcome to PCCS-Linux.COM Hello, and welcome to the PCCS-Linux Home Page.
Your last visit was !!!
Your Browser is running on Other
 
file snmp Functions

To get the IPs on your network

<?php

host -l yourdomain.com | awk '{print $4 }' | sort -t. > ipaddr



$ip = file("ipaddr"); 

OR

$ip = array (
"",
"",
"",
"",
"",
""
);

$total = count($ip);
print "
        <table cellspacing=2>
        <tr bgcolor=CCCCCC>
        <th align=left>Printer Type</th>
        <th align=left>Hostname</th>
        <th align=left>IP Addr</th></tr>";

for($i=0; $i < $total; $i++) {

$printer_model =
@snmpget("$ip[$i]","public",".");
$printer_vars = explode(";",$printer_model);

        $printer = $printer_vars[0] ."<BR>\n";
        $printer .= $printer_vars[1] ."<BR>\n";
        $printer .= $printer_vars[2] ."<BR>\n";
        $printer .= $printer_vars[3] ."<BR>\n";

        // $val = explode(";",$printer_vars);
        $printer = ereg_replace("\"","",$printer);

        print "
        <tr bgcolor=CCAACC>
        <td valign=top> $printer </td>
        <td valign=top> <b>";
        print gethostbyaddr($ip[$i]);
        print "</b> </td>
        <td valign=top> <b>$ip[$i]</b> </td>
        </tr>";
         print "<P>";
}
 print "</table>";
 echo "<br>";
 echo "Total Printers Queried:" . $total;
 echo "Please Note that you may not have recieved info from ALL
Printers";

############

$ip = array (
"",
"",
"",
"",
"",
""
);

$total = count($ip);
print  "
    <table cellspacing=2>
    <tr bgcolor=CCCCCC>
    <th align=left>Hostname</th>
    <th align=left>Location</th>
    <th align=left>DNS Name</th>
    <th align=left>IP address</th>";

for($i=0; $i < $total; $i++) {

    $mib_sysLocation =  "system.sysLocation.0";
    $mib_sysContact =  "system.sysContact.0";
    $mib_sysName =  "system.sysName.0";
    $mib_sysUptime =  "system.sysUpTime.0";
    $mib_sysDescr =  "system.sysDescr.0";

    $_contact = @snmpget( "$ip[$i]",  "public",  "$mib_sysContact");
    $_hostname = @snmpget( "$ip[$i]",  "public",  "$mib_sysName");
    $_location = @snmpget( "$ip[$i]",  "public",  "$mib_sysLocation");


    print  "
    <tr bgcolor=CCAACC>
    <td valign=top> $_hostname </td>
    <td> $_location </td>
    
    <td valign=top> <b>";
    print gethostbyaddr($ip[$i]);
    print  "</b> </td>
    <td valign=top> <b>$ip[$i]</b> </td>
    </tr>"; 
     print  "<P>";

}

 print  "</table>";
 echo  "<br>";
 echo  "Total Switches  Queried:" . $total;
 echo  "Please Note that you may not have recieved info from ALL
Printers";

############
$ip = array (
"",
"",
"",
"",
"",
""
);

$total = count($ip);
print  "
    <table cellspacing=2>
    <tr bgcolor=CCCCCC>
    <th align=left>Hostname</th>
    <th align=left>Location</th>
    <th align=left>Contact</th></tr>
    <th align=left>DNS Name</th>
    <th align=left>IP address</th>";

for($i=0; $i < $total; $i++) {

    $mib_sysLocation =  "system.sysLocation.0";
    $mib_sysContact =  "system.sysContact.0";
    $mib_sysName =  "system.sysName.0";
    $mib_sysUptime =  "system.sysUpTime.0";
    $mib_sysDescr =  "system.sysDescr.0";

    $_contact = @snmpget( "$ip[$i]",  "public",  "$mib_sysContact");
    $_hostname = @snmpget( "$ip[$i]",  "public",  "$mib_sysName");
    $_location = @snmpget( "$ip[$i]",  "public",  "$mib_sysLocation");


    print  "
    <tr bgcolor=CCAACC>
    <td valign=top> $_hostname </td>
    <td> $_location </td>
    <td> $_contact </td>
    
    <td valign=top> <b>";
    print gethostbyaddr($ip[$i]);
    print  "</b> </td>
    <td valign=top> <b>$ip[$i]</b> </td>
    </tr>"; 
     print  "<P>";

}
 print  "</table>";
 echo  "<br>";
 echo  "Total Switches  Queried:" . $total;
 echo  "Please Note that you may not have recieved info from ALL
Printers";


$ip = array (
"",
"",
"",
"",
"",
""
);

$total = count($ip);

for($i=0; $i < $total; $i++) {
        print gethostbyaddr($ip[$i]) . "<br>";

}

##############
$ip = file("ipaddr");
for($i=0; $i< count($ip); $i++) {
         $ipaddr = gethostbyaddr($ip[$i]);
        print "\n" . $ipaddr . "<br>";
}

?>


>> Comments/FeedBack

Page hits 64 last request on :12:46



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