line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::SNMP::Image; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
################################################## |
4
|
|
|
|
|
|
|
# AUTHOR = Michael Vincent |
5
|
|
|
|
|
|
|
# www.VinsWorld.com |
6
|
|
|
|
|
|
|
################################################## |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
85959
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
9
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
773
|
use Net::SNMP qw(:asn1); |
|
1
|
|
|
|
|
69399
|
|
|
1
|
|
|
|
|
859
|
|
12
|
1
|
|
|
1
|
|
1034
|
use Cisco::SNMP; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
253
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = $Cisco::SNMP::VERSION; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Cisco::SNMP); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
################################################## |
19
|
|
|
|
|
|
|
# Start Public Module |
20
|
|
|
|
|
|
|
################################################## |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _imageOID { |
23
|
0
|
|
|
0
|
|
|
return '.1.3.6.1.4.1.9.9.25.1.1.1.2' |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub image_info { |
27
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
28
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $session = $self->{_SESSION_}; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $response = Cisco::SNMP::_snmpwalk($session, _imageOID()); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my %ImageHash; |
35
|
0
|
|
|
|
|
|
for (@{$response}) { |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my ($key, $value) = split /\$/, $_, 2; |
37
|
0
|
|
|
|
|
|
$key =~ s/^CW_//; |
38
|
0
|
|
|
|
|
|
$key = ucfirst(lc($key)); |
39
|
0
|
|
|
|
|
|
$value =~ s/\$$//; |
40
|
0
|
|
|
|
|
|
$ImageHash{$key} = $value |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
10
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
110
|
|
44
|
0
|
|
|
|
|
|
for my $key (keys(%ImageHash)) { |
45
|
0
|
|
|
|
|
|
*{"image" . $key} = sub { |
46
|
0
|
|
|
0
|
|
|
return $ImageHash{$key} |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
} |
49
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
330
|
|
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if (defined $response) { |
52
|
0
|
|
|
|
|
|
return bless $response, $class |
53
|
|
|
|
|
|
|
} else { |
54
|
0
|
|
|
|
|
|
$Cisco::SNMP::LASTERROR = "Cannot read image MIB"; |
55
|
|
|
|
|
|
|
return undef |
56
|
0
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub imageString { |
60
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my ($idx) = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if (!defined $idx) { |
|
|
0
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$idx = 0 |
65
|
|
|
|
|
|
|
} elsif ($idx !~ /^\d+$/) { |
66
|
0
|
|
|
|
|
|
$Cisco::SNMP::LASTERROR = "Invalid image index `$idx'"; |
67
|
|
|
|
|
|
|
return undef |
68
|
0
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
return $self->[$idx] |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_imageString { |
73
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
74
|
0
|
|
|
|
|
|
my ($idx) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $s = $self->session; |
77
|
0
|
|
|
|
|
|
my $r = $s->get_request( |
78
|
|
|
|
|
|
|
varbindlist => [_imageOID() . '.' . ($idx)] |
79
|
|
|
|
|
|
|
); |
80
|
0
|
|
|
|
|
|
return $r->{_imageOID() . '.' . ($idx)} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
################################################## |
84
|
|
|
|
|
|
|
# End Public Module |
85
|
|
|
|
|
|
|
################################################## |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |