| 1 |
use SNMP; |
| 2 |
$SNMP::use_enums = 1; |
| 3 |
|
| 4 |
my $host = shift; |
| 5 |
my $comm = shift; |
| 6 |
$sess = new SNMP::Session(DestHost => $host, Community => $comm); |
| 7 |
|
| 8 |
$vars = new SNMP::VarList( ['ipRouteIfIndex'], ['ipRouteType'], |
| 9 |
['ipRouteProto'], ['ipRouteMask'], |
| 10 |
['ipRouteNextHop'], ['ipRouteAge'], |
| 11 |
['ipRouteMetric1']); |
| 12 |
|
| 13 |
format STDOUT_TOP = |
| 14 |
Destination Next Hop Mask Proto Age Metric |
| 15 |
--------------- --------------- -------------- ------- -------- ------ |
| 16 |
. |
| 17 |
|
| 18 |
format STDOUT = |
| 19 |
@<<<<<<<<<<<<<< @<<<<<<<<<<<<<< @<<<<<<<<<<<<< @|||||| @||||||| @||||| |
| 20 |
$dest, $nhop, $mask, $proto, $age, $metric |
| 21 |
. |
| 22 |
|
| 23 |
for (($index,$type,$proto,$mask,$nhop,$age,$metric) = $sess->getnext($vars); |
| 24 |
$$vars[0]->tag eq 'ipRouteIfIndex' and not $sess->{ErrorStr}; |
| 25 |
($index,$type,$proto,$mask,$nhop,$age,$metric) = $sess->getnext($vars)) { |
| 26 |
$dest = $$vars[0]->iid; |
| 27 |
write; |
| 28 |
} |
| 29 |
|
| 30 |
print "$sess->{ErrorStr}\n"; |