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
|
|
51750
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
796
|
use Net::SNMP qw(:asn1); |
|
1
|
|
|
|
|
65836
|
|
|
1
|
|
|
|
|
211
|
|
12
|
1
|
|
|
1
|
|
486
|
use Cisco::SNMP; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
270
|
|
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
|
6
|
return qw(Descr VendorType ContainedIn Class ParentRelPos Name HardwareRev FirmwareRev SoftwareRev SerialNum MfgName ModelName Alias AssetID IsFRU) |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub entity_info { |
31
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
32
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $session = $self->{_SESSION_}; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my @ENTITYKEYS = entityOIDs(); |
37
|
0
|
|
|
|
|
|
my %ret; |
38
|
0
|
|
|
|
|
|
for my $oid (0..$#ENTITYKEYS) { |
39
|
0
|
|
|
|
|
|
$ret{$ENTITYKEYS[$oid]} = Cisco::SNMP::_snmpwalk($session, _entityOID() . '.' . ($oid+2)); |
40
|
0
|
0
|
|
|
|
|
if (!defined $ret{$ENTITYKEYS[$oid]}) { |
41
|
0
|
|
|
|
|
|
$Cisco::SNMP::LASTERROR = "Cannot get entity `$ENTITYKEYS[$oid]' info"; |
42
|
|
|
|
|
|
|
return undef |
43
|
0
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my @Entity; |
47
|
0
|
|
|
|
|
|
for my $unit (0..$#{$ret{$ENTITYKEYS[5]}}) { |
|
0
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my %EntityHash; |
49
|
0
|
|
|
|
|
|
for (0..$#ENTITYKEYS) { |
50
|
0
|
|
|
|
|
|
$EntityHash{$ENTITYKEYS[$_]} = $ret{$ENTITYKEYS[$_]}->[$unit] |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
push @Entity, \%EntityHash |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
|
return bless \@Entity, $class |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
for (entityOIDs()) { |
58
|
|
|
|
|
|
|
Cisco::SNMP::_mk_accessors_array_1('entity', $_) |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
165
|
|
62
|
|
|
|
|
|
|
# get_ direct |
63
|
|
|
|
|
|
|
my @OIDS = entityOIDs(); |
64
|
|
|
|
|
|
|
for my $o (0..$#OIDS) { |
65
|
|
|
|
|
|
|
*{"get_entity" . $OIDS[$o]} = sub { |
66
|
0
|
|
|
0
|
|
|
my $self = shift; |
67
|
0
|
|
|
|
|
|
my ($val) = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if (!defined $val) { $val = 0 } |
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $s = $self->session; |
71
|
0
|
|
|
|
|
|
my $r = $s->get_request( |
72
|
|
|
|
|
|
|
varbindlist => [_entityOID() . '.' . ($o+2) . '.' . $val] |
73
|
|
|
|
|
|
|
); |
74
|
0
|
|
|
|
|
|
return $r->{_entityOID() . '.' . ($o+2) . '.' . $val} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
################################################## |
79
|
|
|
|
|
|
|
# End Public Module |
80
|
|
|
|
|
|
|
################################################## |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |