| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::MacOS::Storages; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
66648810
|
use strict; |
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
73
|
|
|
4
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
60
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
425
|
use FusionInventory::Agent::Tools; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
205
|
|
|
7
|
1
|
|
|
1
|
|
441
|
use FusionInventory::Agent::Tools::MacOS; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
590
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
|
10
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
|
11
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{storage}; |
|
12
|
0
|
|
|
|
|
|
return 1; |
|
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 $storage (_getStorages(logger => $logger)) { |
|
22
|
0
|
|
|
|
|
|
$inventory->addEntry( |
|
23
|
|
|
|
|
|
|
section => 'STORAGES', |
|
24
|
|
|
|
|
|
|
entry => $storage |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _getStorages { |
|
30
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $infos = getSystemProfilerInfos( |
|
33
|
|
|
|
|
|
|
logger => $params{logger}, |
|
34
|
|
|
|
|
|
|
file => $params{file} |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# system profiler data structure: |
|
38
|
|
|
|
|
|
|
# bus |
|
39
|
|
|
|
|
|
|
# └── controller |
|
40
|
|
|
|
|
|
|
# ├── device |
|
41
|
|
|
|
|
|
|
# │ ├── subdevice |
|
42
|
|
|
|
|
|
|
# │ │ └── key:value |
|
43
|
|
|
|
|
|
|
# │ └── key:value |
|
44
|
|
|
|
|
|
|
# └── key:value |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my @storages; |
|
47
|
0
|
|
|
|
|
|
my @busNames = ('ATA', 'SERIAL-ATA', 'USB', 'FireWire', 'Fibre Channel'); |
|
48
|
0
|
|
|
|
|
|
foreach my $busName (@busNames) { |
|
49
|
0
|
|
|
|
|
|
my $bus = $infos->{$busName}; |
|
50
|
0
|
0
|
|
|
|
|
next unless $bus; |
|
51
|
0
|
|
|
|
|
|
foreach my $controllerName (keys %{$bus}) { |
|
|
0
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $controller = $bus->{$controllerName}; |
|
53
|
0
|
|
|
|
|
|
foreach my $deviceName (keys %{$controller}) { |
|
|
0
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $device = $controller->{$deviceName}; |
|
55
|
0
|
0
|
|
|
|
|
next unless ref $device eq 'HASH'; |
|
56
|
0
|
0
|
|
|
|
|
if (_isStorage($device)) { |
|
57
|
0
|
|
|
|
|
|
push @storages, |
|
58
|
|
|
|
|
|
|
_getStorage($device, $deviceName, $busName); |
|
59
|
|
|
|
|
|
|
} else { |
|
60
|
0
|
|
|
|
|
|
foreach my $subdeviceName (keys %{$device}) { |
|
|
0
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $subdevice = $device->{$subdeviceName}; |
|
62
|
0
|
0
|
|
|
|
|
next unless ref $subdevice eq 'HASH'; |
|
63
|
0
|
0
|
|
|
|
|
push @storages, |
|
64
|
|
|
|
|
|
|
_getStorage($subdevice, $subdeviceName, $busName) |
|
65
|
|
|
|
|
|
|
if _isStorage($subdevice); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return @storages; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _isStorage { |
|
77
|
0
|
|
|
0
|
|
|
my ($device) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return |
|
80
|
0
|
|
0
|
|
|
|
($device->{'BSD Name'} && $device->{'BSD Name'} =~ /^disk\d+$/) || |
|
81
|
|
|
|
|
|
|
($device->{'Protocol'} && $device->{'Socket Type'}); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _getStorage { |
|
85
|
0
|
|
|
0
|
|
|
my ($device, $device_name, $bus_name) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
my $storage = { |
|
88
|
|
|
|
|
|
|
NAME => $device_name, |
|
89
|
|
|
|
|
|
|
MANUFACTURER => getCanonicalManufacturer($device_name), |
|
90
|
|
|
|
|
|
|
TYPE => $bus_name eq 'FireWire' ? '1394' : $bus_name, |
|
91
|
|
|
|
|
|
|
SERIAL => $device->{'Serial Number'}, |
|
92
|
|
|
|
|
|
|
FIRMWARE => $device->{'Revision'}, |
|
93
|
|
|
|
|
|
|
MODEL => $device->{'Model'}, |
|
94
|
|
|
|
|
|
|
DISKSIZE => $device->{'Capacity'} |
|
95
|
|
|
|
|
|
|
}; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
0
|
0
|
|
|
|
if (!$device->{'Protocol'}) { |
|
|
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$storage->{DESCRIPTION} = 'Disk drive'; |
|
99
|
|
|
|
|
|
|
} elsif ($device->{'Protocol'} eq 'ATAPI' || $device->{'Drive Type'}) { |
|
100
|
0
|
|
|
|
|
|
$storage->{DESCRIPTION} = 'CD-ROM Drive'; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
if ($storage->{DISKSIZE}) { |
|
104
|
|
|
|
|
|
|
#e.g: Capacity: 320,07 GB (320 072 933 376 bytes) |
|
105
|
0
|
|
|
|
|
|
$storage->{DISKSIZE} =~ s/\s*\(.*//; |
|
106
|
0
|
|
|
|
|
|
$storage->{DISKSIZE} =~ s/,/./; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
if ($storage->{DISKSIZE} =~ s/\s*TB//) { |
|
|
|
0
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$storage->{DISKSIZE} = int($storage->{DISKSIZE} * 1000 * 1000); |
|
110
|
|
|
|
|
|
|
} elsif ($storage->{DISKSIZE} =~ s/\s+GB$//) { |
|
111
|
0
|
|
|
|
|
|
$storage->{DISKSIZE} = int($storage->{DISKSIZE} * 1000 * 1000); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if ($storage->{MODEL}) { |
|
116
|
0
|
|
|
|
|
|
$storage->{MODEL} =~ s/\s*$storage->{MANUFACTURER}\s*//i; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
return $storage; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |