Quick Router Device View
From NippAero
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: 1 | STRING: FastEthernet0/0 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (1478077436) 171 days, 1:46:14.36 |
| INTEGER: 2 | STRING: FastEthernet0/1 | INTEGER: down(2) | INTEGER: down(2) | Timeticks: (1478077502) 171 days, 1:46:15.02 |
| INTEGER: 3 | STRING: Null0 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (0) 0:00:00.00 |
| INTEGER: 4 | STRING: T1 0/0/0 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (0) 0:00:00.00 |
| INTEGER: 5 | STRING: Serial0/0/0:1 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (1719793898) 199 days, 1:12:18.98 |
| INTEGER: 6 | STRING: Loopback0 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (9466) 0:01:34.66 |
| INTEGER: 7 | STRING: FastEthernet0/0.10 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (337528646) 39 days, 1:34:46.46 |
| INTEGER: 8 | STRING: FastEthernet0/0.20 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (337528646) 39 days, 1:34:46.46 |
| INTEGER: 9 | STRING: FastEthernet0/0.30 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (337528646) 39 days, 1:34:46.46 |
| INTEGER: 10 | STRING: FastEthernet0/0.40 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (337528646) 39 days, 1:34:46.46 |
| INTEGER: 11 | STRING: T1 0/1/0 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (0) 0:00:00.00 |
| INTEGER: 12 | STRING: Serial0/1/0:1 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (1478077351) 171 days, 1:46:13.51 |
| INTEGER: 13 | STRING: Tunnel10000 | INTEGER: up(1) | INTEGER: up(1) | Timeticks: (1196339260) 138 days, 11:09:52.60 |
Categories: SNMP | Network Management | HTML | Shell | Script | Cisco
