line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::HPUX::Storages; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
82962068
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
375
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1161
|
|
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
|
|
634
|
my $handle = getFileHandle(@_); |
80
|
3
|
50
|
|
|
|
5
|
return unless $handle; |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
|
|
3
|
my @devices; |
83
|
3
|
|
|
|
|
4
|
my ($description, $model, $manufacturer); |
84
|
3
|
|
|
|
|
61
|
while (my $line = <$handle>) { |
85
|
69
|
100
|
|
|
|
106
|
if ($line =~ /^\s+(\S+)/ ) { |
86
|
39
|
|
|
|
|
42
|
my $device = $1; |
87
|
|
|
|
|
|
|
|
88
|
39
|
|
|
|
|
153
|
push @devices, { |
89
|
|
|
|
|
|
|
MANUFACTURER => $manufacturer, |
90
|
|
|
|
|
|
|
MODEL => $model, |
91
|
|
|
|
|
|
|
NAME => $device, |
92
|
|
|
|
|
|
|
DESCRIPTION => $description, |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
} else { |
95
|
30
|
|
|
|
|
97
|
my @infos = split(/:/, $line); |
96
|
30
|
|
|
|
|
21
|
$description = $infos[0]; |
97
|
30
|
|
|
|
|
154
|
($manufacturer, $model) = $infos[17] =~ /^(\S+) \s+ (\S.*\S)$/x; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
3
|
|
|
|
|
17
|
close $handle; |
101
|
|
|
|
|
|
|
|
102
|
3
|
|
|
|
|
15
|
return @devices; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |