line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::MacOS::Memory; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
67089416
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
75
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
77
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
441
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
146
|
|
7
|
1
|
|
|
1
|
|
403
|
use FusionInventory::Agent::Tools::MacOS; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
418
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
11
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{memory}; |
12
|
0
|
|
|
|
|
|
return canRun('/usr/sbin/system_profiler'); |
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 $memory (_getMemories(logger => $logger)) { |
22
|
0
|
|
|
|
|
|
$inventory->addEntry( |
23
|
|
|
|
|
|
|
section => 'MEMORIES', |
24
|
|
|
|
|
|
|
entry => $memory |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $memory = _getMemory(logger => $logger); |
29
|
0
|
|
|
|
|
|
$inventory->setHardware({ |
30
|
|
|
|
|
|
|
MEMORY => $memory, |
31
|
|
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _getMemories { |
36
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $infos = getSystemProfilerInfos( |
39
|
|
|
|
|
|
|
logger => $params{logger}, |
40
|
|
|
|
|
|
|
file => $params{file} |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
return unless $infos->{Memory}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# the memory slot informations may appears directly under |
46
|
|
|
|
|
|
|
# 'Memory' top-level node, or under Memory/Memory Slots |
47
|
0
|
0
|
|
|
|
|
my $parent_node = $infos->{Memory}->{'Memory Slots'} ? |
48
|
|
|
|
|
|
|
$infos->{Memory}->{'Memory Slots'} : |
49
|
|
|
|
|
|
|
$infos->{Memory}; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my @memories; |
52
|
0
|
|
|
|
|
|
foreach my $key (sort keys %$parent_node) { |
53
|
0
|
0
|
|
|
|
|
next unless $key =~ /DIMM(\d)/; |
54
|
0
|
|
|
|
|
|
my $slot = $1; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $info = $parent_node->{$key}; |
57
|
0
|
|
|
|
|
|
my $description = $info->{'Part Number'}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# convert hexa to ascii |
60
|
0
|
0
|
0
|
|
|
|
if ($description && $description =~ /^0x/) { |
61
|
0
|
|
|
|
|
|
$description = pack 'H*', substr($description, 2); |
62
|
0
|
|
|
|
|
|
$description =~ s/\s*$//; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $memory = { |
66
|
|
|
|
|
|
|
NUMSLOTS => $slot, |
67
|
|
|
|
|
|
|
DESCRIPTION => $description, |
68
|
|
|
|
|
|
|
CAPTION => "Status: $info->{'Status'}", |
69
|
|
|
|
|
|
|
TYPE => $info->{'Type'}, |
70
|
|
|
|
|
|
|
SERIALNUMBER => $info->{'Serial Number'}, |
71
|
|
|
|
|
|
|
SPEED => getCanonicalSpeed($info->{'Speed'}), |
72
|
|
|
|
|
|
|
CAPACITY => getCanonicalSize($info->{'Size'}) |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
push @memories, $memory; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return @memories; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _getMemory { |
82
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $infos = getSystemProfilerInfos( |
85
|
|
|
|
|
|
|
logger => $params{logger}, |
86
|
|
|
|
|
|
|
file => $params{file} |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return getCanonicalSize( |
90
|
|
|
|
|
|
|
$infos->{'Hardware'}{'Hardware Overview'}{'Memory'}, |
91
|
|
|
|
|
|
|
1024 |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |