line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::HPUX::Storages; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
97890762
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
104
|
|
4
|
2
|
|
|
2
|
|
24
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
113
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
840
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1703
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
10
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{storage}; |
11
|
|
|
|
|
|
|
return |
12
|
0
|
|
|
|
|
0
|
canRun('ioscan'); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub doInventory { |
16
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
19
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
foreach my $disk (_getDisks($logger)) { |
22
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $disk); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
foreach my $tape (_getTapes($logger)) { |
26
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $tape); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _getDisks { |
31
|
0
|
|
|
0
|
|
0
|
my ($logger) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
my @disks; |
34
|
0
|
|
|
|
|
0
|
foreach my $device ( |
35
|
|
|
|
|
|
|
_parseIoscan(command => 'ioscan -kFnC disk', logger => $logger) |
36
|
|
|
|
|
|
|
) { |
37
|
|
|
|
|
|
|
# skip alternate links |
38
|
0
|
0
|
|
|
|
0
|
next if getFirstMatch( |
39
|
|
|
|
|
|
|
command => "pvdisplay $device->{NAME}", |
40
|
|
|
|
|
|
|
pattern => qr/$device->{NAME}\.+lternate/ |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
my $handle = getFileHandle( |
44
|
|
|
|
|
|
|
command => "diskinfo -v $device->{NAME}", |
45
|
|
|
|
|
|
|
logger => $logger |
46
|
|
|
|
|
|
|
); |
47
|
0
|
|
|
|
|
0
|
while (my $line = <$handle>) { |
48
|
0
|
0
|
|
|
|
0
|
if ($line =~ /^\s+size:\s+(\S+)/) { |
49
|
0
|
|
|
|
|
0
|
$device->{DISKSIZE} = int($1/1024); |
50
|
|
|
|
|
|
|
} |
51
|
0
|
0
|
|
|
|
0
|
if ($line =~ /^\s+rev level:\s+(\S+)/) { |
52
|
0
|
|
|
|
|
0
|
$device->{FIRMWARE} = $1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
0
|
close $handle; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
$device->{TYPE} = 'disk'; |
58
|
0
|
|
|
|
|
0
|
push @disks, $device; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
return @disks; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _getTapes { |
65
|
0
|
|
|
0
|
|
0
|
my ($logger) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
my @tapes; |
68
|
0
|
|
|
|
|
0
|
foreach my $device ( |
69
|
|
|
|
|
|
|
_parseIoscan(command => 'ioscan -kFnC tape', logger => $logger) |
70
|
|
|
|
|
|
|
) { |
71
|
0
|
|
|
|
|
0
|
$device->{TYPE} = 'tape'; |
72
|
0
|
|
|
|
|
0
|
push @tapes, $device; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
return @tapes; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _parseIoscan { |
79
|
3
|
|
|
3
|
|
638
|
my $handle = getFileHandle(@_); |
80
|
3
|
50
|
|
|
|
8
|
return unless $handle; |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
|
|
5
|
my @devices; |
83
|
3
|
|
|
|
|
3
|
my ($description, $model, $manufacturer); |
84
|
3
|
|
|
|
|
64
|
while (my $line = <$handle>) { |
85
|
69
|
100
|
|
|
|
202
|
if ($line =~ /^\s+(\S+)/ ) { |
86
|
39
|
|
|
|
|
102
|
my $device = $1; |
87
|
|
|
|
|
|
|
|
88
|
39
|
|
|
|
|
319
|
push @devices, { |
89
|
|
|
|
|
|
|
MANUFACTURER => $manufacturer, |
90
|
|
|
|
|
|
|
MODEL => $model, |
91
|
|
|
|
|
|
|
NAME => $device, |
92
|
|
|
|
|
|
|
DESCRIPTION => $description, |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
} else { |
95
|
30
|
|
|
|
|
189
|
my @infos = split(/:/, $line); |
96
|
30
|
|
|
|
|
40
|
$description = $infos[0]; |
97
|
30
|
|
|
|
|
236
|
($manufacturer, $model) = $infos[17] =~ /^(\S+) \s+ (\S.*\S)$/x; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
3
|
|
|
|
|
98
|
close $handle; |
101
|
|
|
|
|
|
|
|
102
|
3
|
|
|
|
|
24
|
return @devices; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |