Quick Router Device View

From NippAero

Jump to: navigation, search

Quick and dirty.

Code

<?php
$host = "testrouter";
$community = "public";
                    
$sysDescr = snmpget("$host","$community","system.sysDescr.0");
$ifDescr = snmpwalk("$host","$community","interfaces.ifTable.ifEntry.ifDescr");
$ifIndex = snmpwalk("$host","$community","interfaces.ifTable.ifEntry.ifIndex");
$ifAdminStatus = snmpwalk("$host","$community","interfaces.ifTable.ifEntry.ifAdminStatus");
$ifOperStatus = snmpwalk("$host","$community","interfaces.ifTable.ifEntry.ifOperStatus");
$ifLastChange = snmpwalk("$host","$community","interfaces.ifTable.ifEntry.ifLastChange");
                                         
print "<table border=1 bgcolor=#ffffff><tr><td>$host</td></tr></table><br>";
print "<table border=1 bgcolor=#ffffff><tr><td>$sysDescr</td></tr></table><br>";
print "<table border=1 bgcolor=#ffffff>";
print "<tr>
        <td>ifIndex</td>
        <td>ifDescr</td>
        <td>ifAdminStatus</td>
        <td>ifOperStatus</td>
        <td>ifLastChange</td>
        </tr>";
            
for ($i=0; $i<count($ifIndex); $i++) {
        print "<tr>";
        print "<td>$ifIndex[$i]</td>";
        print "<td>$ifDescr[$i]</td>";
        print "<td>$ifAdminStatus[$i]</td>";
        print "<td>$ifOperStatus[$i]</td>";
        print "<td>$ifLastChange[$i]</td>";
        print "</tr>";
}           
print "</table>";

?>

Output

testrouter

STRING: Cisco IOS Software, 2800 Software (C2800NM-ADVIPSERVICESK9-M), Version 12.4(5b), RELEASE SOFTWARE (fc2)

Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2006 by Cisco Systems, Inc.

Compiled Wed 19-Apr-06 06:52 by ssearch

ifIndex ifDescr ifAdminStatus ifOperStatus ifLastChange
INTEGER: 1STRING: FastEthernet0/0INTEGER: up(1)INTEGER: up(1)Timeticks: (1478077436) 171 days, 1:46:14.36
INTEGER: 2STRING: FastEthernet0/1INTEGER: down(2)INTEGER: down(2)Timeticks: (1478077502) 171 days, 1:46:15.02
INTEGER: 3STRING: Null0INTEGER: up(1)INTEGER: up(1)Timeticks: (0) 0:00:00.00
INTEGER: 4STRING: T1 0/0/0INTEGER: up(1)INTEGER: up(1)Timeticks: (0) 0:00:00.00
INTEGER: 5STRING: Serial0/0/0:1INTEGER: up(1)INTEGER: up(1)Timeticks: (1719793898) 199 days, 1:12:18.98
INTEGER: 6STRING: Loopback0INTEGER: up(1)INTEGER: up(1)Timeticks: (9466) 0:01:34.66
INTEGER: 7STRING: FastEthernet0/0.10INTEGER: up(1)INTEGER: up(1)Timeticks: (337528646) 39 days, 1:34:46.46
INTEGER: 8STRING: FastEthernet0/0.20INTEGER: up(1)INTEGER: up(1)Timeticks: (337528646) 39 days, 1:34:46.46
INTEGER: 9STRING: FastEthernet0/0.30INTEGER: up(1)INTEGER: up(1)Timeticks: (337528646) 39 days, 1:34:46.46
INTEGER: 10STRING: FastEthernet0/0.40INTEGER: up(1)INTEGER: up(1)Timeticks: (337528646) 39 days, 1:34:46.46
INTEGER: 11STRING: T1 0/1/0INTEGER: up(1)INTEGER: up(1)Timeticks: (0) 0:00:00.00
INTEGER: 12STRING: Serial0/1/0:1INTEGER: up(1)INTEGER: up(1)Timeticks: (1478077351) 171 days, 1:46:13.51
INTEGER: 13STRING: Tunnel10000INTEGER: up(1)INTEGER: up(1)Timeticks: (1196339260) 138 days, 11:09:52.60
Personal tools