line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::Storages; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
76241601
|
use strict; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
137
|
|
4
|
1
|
|
|
1
|
|
20
|
use warnings; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
140
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1171
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
202
|
|
7
|
1
|
|
|
1
|
|
707
|
use FusionInventory::Agent::Tools::Generic; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
98
|
|
8
|
1
|
|
|
1
|
|
608
|
use FusionInventory::Agent::Tools::Win32; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
794
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub isEnabled { |
11
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
12
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{storage}; |
13
|
0
|
|
|
|
|
|
return 1; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub doInventory { |
17
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
20
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $hdparm = canRun('hdparm'); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
foreach my $storage (_getDrives(class => 'Win32_DiskDrive')) { |
25
|
0
|
0
|
0
|
|
|
|
if ($hdparm && $storage->{NAME} =~ /(\d+)$/) { |
26
|
0
|
|
|
|
|
|
my $info = getHdparmInfo( |
27
|
|
|
|
|
|
|
device => "/dev/hd" . chr(ord('a') + $1), |
28
|
|
|
|
|
|
|
logger => $logger |
29
|
|
|
|
|
|
|
); |
30
|
0
|
0
|
|
|
|
|
$storage->{MODEL} = $info->{model} if $info->{model}; |
31
|
0
|
0
|
|
|
|
|
$storage->{FIRMWARE} = $info->{firmware} if $info->{firmware}; |
32
|
0
|
0
|
|
|
|
|
$storage->{SERIAL} = $info->{serial} if $info->{serial}; |
33
|
0
|
0
|
|
|
|
|
$storage->{DISKSIZE} = $info->{size} if $info->{size}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$inventory->addEntry( |
37
|
0
|
|
|
|
|
|
section => 'STORAGES', |
38
|
|
|
|
|
|
|
entry => $storage |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
foreach my $storage (_getDrives(class => 'Win32_CDROMDrive')) { |
43
|
0
|
0
|
0
|
|
|
|
if ($hdparm && $storage->{NAME} =~ /(\d+)$/) { |
44
|
0
|
|
|
|
|
|
my $info = getHdparmInfo( |
45
|
|
|
|
|
|
|
device => "/dev/scd" . chr(ord('a') + $1), |
46
|
|
|
|
|
|
|
logger => $logger |
47
|
|
|
|
|
|
|
); |
48
|
0
|
0
|
|
|
|
|
$storage->{MODEL} = $info->{model} if $info->{model}; |
49
|
0
|
0
|
|
|
|
|
$storage->{FIRMWARE} = $info->{firmware} if $info->{firmware}; |
50
|
0
|
0
|
|
|
|
|
$storage->{SERIAL} = $info->{serial} if $info->{serial}; |
51
|
0
|
0
|
|
|
|
|
$storage->{DISKSIZE} = $info->{size} if $info->{size}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$inventory->addEntry( |
55
|
0
|
|
|
|
|
|
section => 'STORAGES', |
56
|
|
|
|
|
|
|
entry => $storage |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
foreach my $storage (_getDrives(class => 'Win32_TapeDrive')) { |
61
|
0
|
|
|
|
|
|
$inventory->addEntry( |
62
|
|
|
|
|
|
|
section => 'STORAGES', |
63
|
|
|
|
|
|
|
entry => $storage |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _getDrives { |
69
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my @drives; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
foreach my $object (getWMIObjects( |
74
|
|
|
|
|
|
|
class => $params{class}, |
75
|
|
|
|
|
|
|
properties => [ qw/ |
76
|
|
|
|
|
|
|
Manufacturer Model Caption Description Name MediaType InterfaceType |
77
|
|
|
|
|
|
|
FirmwareRevision SerialNumber Size |
78
|
|
|
|
|
|
|
SCSIPort SCSILogicalUnit SCSITargetId |
79
|
|
|
|
|
|
|
/ ] |
80
|
|
|
|
|
|
|
)) { |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $drive = { |
83
|
|
|
|
|
|
|
MANUFACTURER => $object->{Manufacturer}, |
84
|
|
|
|
|
|
|
MODEL => $object->{Model} || $object->{Caption}, |
85
|
|
|
|
|
|
|
DESCRIPTION => $object->{Description}, |
86
|
|
|
|
|
|
|
NAME => $object->{Name}, |
87
|
|
|
|
|
|
|
TYPE => $object->{MediaType}, |
88
|
|
|
|
|
|
|
INTERFACE => $object->{InterfaceType}, |
89
|
|
|
|
|
|
|
FIRMWARE => $object->{FirmwareRevision}, |
90
|
|
|
|
|
|
|
SCSI_COID => $object->{SCSIPort}, |
91
|
|
|
|
|
|
|
SCSI_LUN => $object->{SCSILogicalUnit}, |
92
|
|
|
|
|
|
|
SCSI_UNID => $object->{SCSITargetId}, |
93
|
0
|
|
0
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$drive->{DISKSIZE} = int($object->{Size} / (1024 * 1024)) |
96
|
0
|
0
|
|
|
|
|
if $object->{Size}; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$drive->{SERIAL} = $object->{SerialNumber} |
99
|
0
|
0
|
0
|
|
|
|
if $object->{SerialNumber} && $object->{SerialNumber} !~ /^ +$/; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
push @drives, $drive; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return @drives; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |