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