Leser: 25
1 2 3 4 5 6 7 8
#!/usr/bin/perl -w use SNMP; use Data::Dumper; my $session = new SNMP::Session(DestHost => 'xxx', Community => 'xxx', Version => '2'); print Dumper ($session->gettable('ifTable',noindexes=>1));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$VAR1 = {
'10107' => {
'ifMtu' => '1500',
'ifPhysAddress' => '?"/',
'ifOperStatus' => '2',
'ifDescr' => 'GigabitEthernet0/7',
'ifInUcastPkts' => '0',
'ifInDiscards' => '0',
'ifAdminStatus' => '2',
'ifOutErrors' => '0',
'ifIndex' => '10107',
'ifLastChange' => '6120',
'ifInNUcastPkts' => '0',
'ifInErrors' => '0',
'ifOutNUcastPkts' => '0',
'ifSpeed' => '10000000',
'ifOutOctets' => '0',
'ifOutDiscards' => '0',
'ifOutQLen' => '0',
'ifSpecific' => 'zeroDotZero',
'ifInOctets' => '0',
'ifOutUcastPkts' => '0',
'ifType' => '6',
'ifInUnknownProtos' => '0'
},
'10501' => {
'ifMtu' => '1500',
'ifPhysAddress' => '',
'ifOperStatus' => '1',
'ifDescr' => 'Null0',
'ifInUcastPkts' => '0',
'ifInDiscards' => '0',
'ifAdminStatus' => '1',
'ifOutErrors' => '0',
'ifIndex' => '10501',
'ifLastChange' => '0',
'ifInNUcastPkts' => '0',
'ifInErrors' => '0',
'ifOutNUcastPkts' => '0',
'ifSpeed' => '4294967295',
'ifOutOctets' => '0',
'ifOutDiscards' => '0',
'ifOutQLen' => '0',
'ifSpecific' => 'zeroDotZero',
'ifInOctets' => '0',
'ifOutUcastPkts' => '0',
'ifType' => '1',
'ifInUnknownProtos' => '0'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; use SNMP; my $session = new SNMP::Session(DestHost => 'xxx', Community => 'xxx', Version => '2'); my $ifTable = $session->gettable('ifTable',noindexes=>1); print "Interfaces: ", join(", ", keys %{$ifTable}), "\n"; while (my ($key, $info) = each %{$ifTable}) { print "key: ", $key, "ifDescr: ", $info->{ifDescr}, "\n"; }
1 2 3 4 5 6
my $ifTable = $session->gettable('ifTable',noindexes=>1); foreach my $key (keys %$ifTable) { foreach my $inkey (keys %{$ifTable->{$key}}) { print "Schluessel $key, Unterschluessel $inkey, Wert " . $ifTable->{$key}->{$inkey} . "\n"; } }