line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::SNMP::Entity; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
################################################## |
4
|
|
|
|
|
|
|
# AUTHOR = Michael Vincent |
5
|
|
|
|
|
|
|
# www.VinsWorld.com |
6
|
|
|
|
|
|
|
################################################## |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
47096
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
23
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
500
|
use Net::SNMP qw(:asn1); |
|
1
|
|
|
|
|
53998
|
|
|
1
|
|
|
|
|
214
|
|
12
|
1
|
|
|
1
|
|
301
|
use Cisco::SNMP; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
243
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = $Cisco::SNMP::VERSION; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Cisco::SNMP); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
################################################## |
19
|
|
|
|
|
|
|
# Start Public Module |
20
|
|
|
|
|
|
|
################################################## |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _entityOID { |
23
|
0
|
|
|
0
|
|
0
|
return '1.3.6.1.2.1.47.1.1.1.1'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub entityOIDs { |
27
|
2
|
|
|
2
|
1
|
7
|
return qw(Descr VendorType ContainedIn Class ParentRelPos Name |
28
|
|
|
|
|
|
|
HardwareRev FirmwareRev SoftwareRev SerialNum MfgName ModelName |
29
|
|
|
|
|
|
|
Alias AssetID IsFRU); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub entity_info { |
33
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
34
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $session = $self->{_SESSION_}; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @ENTITYKEYS = entityOIDs(); |
39
|
0
|
|
|
|
|
|
my %ret; |
40
|
0
|
|
|
|
|
|
for my $oid ( 0 .. $#ENTITYKEYS ) { |
41
|
0
|
|
|
|
|
|
$ret{$ENTITYKEYS[$oid]} = Cisco::SNMP::_snmpwalk( $session, |
42
|
|
|
|
|
|
|
_entityOID() . '.' . ( $oid + 2 ) ); |
43
|
0
|
0
|
|
|
|
|
if ( not defined $ret{$ENTITYKEYS[$oid]} ) { |
44
|
0
|
|
|
|
|
|
$Cisco::SNMP::LASTERROR |
45
|
|
|
|
|
|
|
= "Cannot get entity `$ENTITYKEYS[$oid]' info"; |
46
|
0
|
|
|
|
|
|
return undef; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my @Entity; |
51
|
0
|
|
|
|
|
|
for my $unit ( 0 .. $#{$ret{$ENTITYKEYS[5]}} ) { |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my %EntityHash; |
53
|
0
|
|
|
|
|
|
for ( 0 .. $#ENTITYKEYS ) { |
54
|
0
|
|
|
|
|
|
$EntityHash{$ENTITYKEYS[$_]} = $ret{$ENTITYKEYS[$_]}->[$unit]; |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
push @Entity, \%EntityHash; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
return bless \@Entity, $class; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
for ( entityOIDs() ) { |
62
|
|
|
|
|
|
|
Cisco::SNMP::_mk_accessors_array_1( 'entity', $_ ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
129
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# get_ direct |
68
|
|
|
|
|
|
|
my @OIDS = entityOIDs(); |
69
|
|
|
|
|
|
|
for my $o ( 0 .. $#OIDS ) { |
70
|
|
|
|
|
|
|
*{"get_entity" . $OIDS[$o]} = sub { |
71
|
0
|
|
|
0
|
|
|
my $self = shift; |
72
|
0
|
|
|
|
|
|
my ($val) = @_; |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ( not defined $val ) { $val = 0 } |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $s = $self->session; |
76
|
0
|
|
|
|
|
|
my $r = $s->get_request( |
77
|
|
|
|
|
|
|
varbindlist => [_entityOID() . '.' . ( $o + 2 ) . '.' . $val] ); |
78
|
0
|
|
|
|
|
|
return $r->{_entityOID() . '.' . ( $o + 2 ) . '.' . $val}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
################################################## |
83
|
|
|
|
|
|
|
# End Public Module |
84
|
|
|
|
|
|
|
################################################## |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |