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