line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::HPUX::Memory; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
83622209
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
79
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
377
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
238
|
|
7
|
2
|
|
|
2
|
|
653
|
use FusionInventory::Agent::Tools::HPUX; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
8
|
2
|
|
|
2
|
|
8
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub isEnabled { |
11
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
12
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{memory}; |
13
|
0
|
|
|
|
|
0
|
return 1; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub doInventory { |
17
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
20
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
my @memories; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# http://forge.fusioninventory.org/issues/754 |
25
|
0
|
0
|
0
|
|
|
0
|
if (canRun('/opt/propplus/bin/cprop') && !isHPVMGuest()) { |
26
|
0
|
|
|
|
|
0
|
@memories = _parseCprop( |
27
|
|
|
|
|
|
|
command => '/opt/propplus/bin/cprop -summary -c Memory', |
28
|
|
|
|
|
|
|
logger => $logger |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} else { |
31
|
0
|
|
|
|
|
0
|
my $arch = getFirstLine(command => 'uname -m'); |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
0
|
if ($arch =~ /ia64/ ) { |
34
|
|
|
|
|
|
|
# enable infolog |
35
|
0
|
|
|
|
|
0
|
system("echo 'sc product IPF_MEMORY;info' | /usr/sbin/cstm"); |
36
|
0
|
|
|
|
|
0
|
@memories = _parseCstm64( |
37
|
|
|
|
|
|
|
command => "echo 'sc product IPF_MEMORY;il' | /usr/sbin/cstm", |
38
|
|
|
|
|
|
|
logger => $logger |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
0
|
@memories = _parseCstm( |
42
|
|
|
|
|
|
|
command => "echo 'sc product mem;il'| /usr/sbin/cstm", |
43
|
|
|
|
|
|
|
logger => $logger |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my $memorySize; |
49
|
0
|
|
|
|
|
0
|
my $swapSize = getFirstMatch( |
50
|
|
|
|
|
|
|
command => 'swapinfo -dt', |
51
|
|
|
|
|
|
|
logger => $logger, |
52
|
|
|
|
|
|
|
pattern => qr/^total\s+(\d+)/ |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
foreach my $memory (@memories) { |
56
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
57
|
|
|
|
|
|
|
section => 'MEMORIES', |
58
|
|
|
|
|
|
|
entry => $memory |
59
|
|
|
|
|
|
|
); |
60
|
0
|
|
|
|
|
0
|
$memorySize += $memory->{CAPACITY}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$inventory->setHardware({ |
64
|
0
|
|
|
|
|
0
|
SWAP => int($swapSize / 1024), |
65
|
|
|
|
|
|
|
MEMORY => $memorySize |
66
|
|
|
|
|
|
|
}); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _parseCprop { |
70
|
1
|
|
|
1
|
|
301
|
my $handle = getFileHandle(@_); |
71
|
1
|
50
|
|
|
|
3
|
return unless $handle; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
2
|
my @memories; |
74
|
|
|
|
|
|
|
my $instance; |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
29
|
while (my $line = <$handle>) { |
77
|
439
|
100
|
|
|
|
544
|
if ($line =~ /\[Instance\]: \d+/) { |
78
|
|
|
|
|
|
|
# new block |
79
|
48
|
|
|
|
|
44
|
$instance = {}; |
80
|
48
|
|
|
|
|
115
|
next; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
391
|
100
|
|
|
|
726
|
if ($line =~ /^ \s+ \[ ([^\]]+) \]: \s (\S+.*)/x) { |
84
|
288
|
|
|
|
|
406
|
$instance->{$1} = $2; |
85
|
288
|
|
|
|
|
531
|
next; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
103
|
100
|
|
|
|
167
|
if ($line =~ /^\*+/) { |
89
|
96
|
100
|
|
|
|
171
|
next unless keys %$instance; |
90
|
48
|
100
|
|
|
|
81
|
next unless $instance->{Size}; |
91
|
|
|
|
|
|
|
push @memories, { |
92
|
|
|
|
|
|
|
CAPACITY => getCanonicalSize($instance->{Size}), |
93
|
|
|
|
|
|
|
DESCRIPTION => $instance->{'Part Number'}, |
94
|
|
|
|
|
|
|
SERIALNUMBER => $instance->{'Serial Number'}, |
95
|
24
|
|
|
|
|
66
|
TYPE => $instance->{'Module Type'}, |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
1
|
|
|
|
|
7
|
close $handle; |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
8
|
return @memories; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _parseCstm { |
105
|
1
|
|
|
1
|
|
11
|
my $handle = getFileHandle(@_); |
106
|
1
|
50
|
|
|
|
2
|
return unless $handle; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
1
|
my @memories; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my %capacities; |
111
|
1
|
|
|
|
|
3
|
my $capacity = 0; |
112
|
1
|
|
|
|
|
1
|
my $description; |
113
|
1
|
|
|
|
|
1
|
my $numslot = 1; |
114
|
1
|
|
|
|
|
1
|
my $subnumslot; |
115
|
1
|
|
|
|
|
20
|
my $serialnumber = 'No Serial Number available!'; |
116
|
1
|
|
|
|
|
1
|
my $type; |
117
|
1
|
|
|
|
|
2
|
my $ok = 0; |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
9
|
while (my $line = <$handle>) { |
120
|
|
|
|
|
|
|
|
121
|
76
|
50
|
|
|
|
84
|
if ($line =~ /FRU\sSource\s+=\s+\S+\s+\(memory/ ) { |
122
|
0
|
|
|
|
|
0
|
$ok = 0; |
123
|
|
|
|
|
|
|
} |
124
|
76
|
50
|
|
|
|
85
|
if ($line =~ /Source\s+Detail\s+=\s4/ ) { |
125
|
0
|
|
|
|
|
0
|
$ok = 1; |
126
|
|
|
|
|
|
|
} |
127
|
76
|
100
|
|
|
|
150
|
if ($line =~ /\s+(\d+)\s+(\d+)/ ) { |
128
|
11
|
|
|
|
|
22
|
$capacities{$1} = $2; |
129
|
|
|
|
|
|
|
} |
130
|
76
|
50
|
|
|
|
83
|
if ($line =~ /Extender\s+Location\s+=\s+(\S+)/ ) { |
131
|
0
|
|
|
|
|
0
|
$subnumslot = $1; |
132
|
|
|
|
|
|
|
}; |
133
|
76
|
50
|
|
|
|
88
|
if ($line =~ /DIMMS\s+Rank\s+=\s+(\S+)/ ) { |
134
|
0
|
|
|
|
|
0
|
$numslot = sprintf("%02x",$1); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
76
|
50
|
|
|
|
85
|
if ($line =~ /FRU\s+Name\.*:\s+(\S+)/ ) { |
138
|
0
|
0
|
|
|
|
0
|
if ($line =~ /(\S+)_(\S+)/ ) { |
|
|
0
|
|
|
|
|
|
139
|
0
|
|
|
|
|
0
|
$type = $1; |
140
|
0
|
|
|
|
|
0
|
$capacity = $2; |
141
|
|
|
|
|
|
|
} elsif ($line =~ /(\wIMM)(\S+)/ ) { |
142
|
0
|
|
|
|
|
0
|
$ok = 1; |
143
|
0
|
|
|
|
|
0
|
$type = $1; |
144
|
0
|
|
|
|
|
0
|
$numslot = $2; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
76
|
50
|
|
|
|
86
|
if ($line =~ /Part\s+Number\.*:\s*(\S+)\s+/ ) { |
148
|
0
|
|
|
|
|
0
|
$description = $1; |
149
|
|
|
|
|
|
|
} |
150
|
76
|
50
|
|
|
|
151
|
if ($line =~ /Serial\s+Number\.*:\s*(\S+)\s+/ ) { |
151
|
0
|
|
|
|
|
0
|
$serialnumber = $1; |
152
|
0
|
0
|
|
|
|
0
|
if ( $ok eq 1 ) { |
153
|
0
|
0
|
|
|
|
0
|
if ( $capacity eq 0 ) { |
154
|
0
|
|
|
|
|
0
|
$capacity = $capacities{$numslot}; |
155
|
|
|
|
|
|
|
} |
156
|
0
|
|
|
|
|
0
|
push @memories, { |
157
|
|
|
|
|
|
|
CAPACITY => $capacity, |
158
|
|
|
|
|
|
|
DESCRIPTION => "Part Number $description", |
159
|
|
|
|
|
|
|
CAPTION => "Ext $subnumslot Slot $numslot", |
160
|
|
|
|
|
|
|
TYPE => $type, |
161
|
|
|
|
|
|
|
NUMSLOTS => '1', |
162
|
|
|
|
|
|
|
SERIALNUMBER => $serialnumber, |
163
|
|
|
|
|
|
|
}; |
164
|
0
|
|
|
|
|
0
|
$ok = 0; |
165
|
0
|
|
|
|
|
0
|
$capacity = 0; |
166
|
|
|
|
|
|
|
} # $ok eq 1 |
167
|
|
|
|
|
|
|
} # /Serial\s+Number\.*:\s*(\S+)\s+/ |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
} |
170
|
1
|
|
|
|
|
6
|
close $handle; |
171
|
|
|
|
|
|
|
|
172
|
1
|
|
|
|
|
7
|
return @memories; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub _parseCstm64 { |
176
|
2
|
|
|
2
|
|
7165
|
my $handle = getFileHandle(@_); |
177
|
2
|
50
|
|
|
|
6
|
return unless $handle; |
178
|
|
|
|
|
|
|
|
179
|
2
|
|
|
|
|
2
|
my @memories; |
180
|
|
|
|
|
|
|
|
181
|
2
|
|
|
|
|
41
|
while (my $line = <$handle>) { |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# this pattern assumes memory slots are correctly |
184
|
|
|
|
|
|
|
# balanced (slot A and slot B are occuped) |
185
|
151
|
100
|
|
|
|
349
|
next unless $line =~ / |
186
|
|
|
|
|
|
|
(\w+IMM)\s+(\w+)\s+(\d+) # first column |
187
|
|
|
|
|
|
|
\s+ |
188
|
|
|
|
|
|
|
(\w+IMM)\s+(\w+)\s+(\d+) # second column |
189
|
|
|
|
|
|
|
/x; |
190
|
|
|
|
|
|
|
|
191
|
6
|
|
|
|
|
52
|
push @memories, { |
192
|
|
|
|
|
|
|
CAPACITY => $3, |
193
|
|
|
|
|
|
|
DESCRIPTION => $1, |
194
|
|
|
|
|
|
|
CAPTION => $1 . ' ' . $2, |
195
|
|
|
|
|
|
|
TYPE => $1, |
196
|
|
|
|
|
|
|
NUMSLOTS => $2, |
197
|
|
|
|
|
|
|
}, { |
198
|
|
|
|
|
|
|
CAPACITY => $6, |
199
|
|
|
|
|
|
|
DESCRIPTION => $4, |
200
|
|
|
|
|
|
|
CAPTION => $4 . ' ' . $5, |
201
|
|
|
|
|
|
|
TYPE => $4, |
202
|
|
|
|
|
|
|
NUMSLOTS => $5, |
203
|
|
|
|
|
|
|
}; |
204
|
|
|
|
|
|
|
} |
205
|
2
|
|
|
|
|
20
|
close $handle; |
206
|
|
|
|
|
|
|
|
207
|
2
|
|
|
|
|
12
|
return @memories; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
1; |