| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::HPUX::CPU; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
70891321
|
use strict; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
61
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
65
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use English qw(-no_match_vars); |
|
|
1
|
|
|
|
|
36
|
|
|
|
1
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
990
|
use FusionInventory::Agent::Tools; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
193
|
|
|
9
|
1
|
|
|
1
|
|
342
|
use FusionInventory::Agent::Tools::HPUX; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
862
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub isEnabled { |
|
12
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
|
13
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{cpu}; |
|
14
|
0
|
|
|
|
|
|
return 1; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub doInventory { |
|
18
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
|
21
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# http://forge.fusioninventory.org/issues/755 |
|
24
|
0
|
0
|
0
|
|
|
|
if (canRun('/opt/propplus/bin/cprop') && !isHPVMGuest()) { |
|
25
|
0
|
|
|
|
|
|
foreach my $cpu (_parseCprop( |
|
26
|
|
|
|
|
|
|
command => '/opt/propplus/bin/cprop -summary -c Processors', |
|
27
|
|
|
|
|
|
|
logger => $logger |
|
28
|
|
|
|
|
|
|
)) { |
|
29
|
0
|
|
|
|
|
|
$inventory->addEntry( |
|
30
|
|
|
|
|
|
|
section => 'CPUS', |
|
31
|
|
|
|
|
|
|
entry => $cpu |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
0
|
|
|
|
|
|
return; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $CPUinfo; |
|
38
|
0
|
0
|
|
|
|
|
if (canRun('/usr/contrib/bin/machinfo')) { |
|
39
|
0
|
|
|
|
|
|
$CPUinfo = _parseMachinInfo( |
|
40
|
|
|
|
|
|
|
command => '/usr/contrib/bin/machinfo', |
|
41
|
|
|
|
|
|
|
logger => $logger |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
} else { |
|
44
|
|
|
|
|
|
|
# old HpUX without machinfo |
|
45
|
0
|
|
|
|
|
|
my %cpuInfos = ( |
|
46
|
|
|
|
|
|
|
"D200" => { TYPE => "7100LC", SPEED => 75 }, |
|
47
|
|
|
|
|
|
|
"D210" => { TYPE => "7100LC", SPEED => 100 }, |
|
48
|
|
|
|
|
|
|
"D220" => { TYPE => "7300LC", SPEED => 132 }, |
|
49
|
|
|
|
|
|
|
"D230" => { TYPE => "7300LC", SPEED => 160 }, |
|
50
|
|
|
|
|
|
|
"D250" => { TYPE => "7200", SPEED => 100 }, |
|
51
|
|
|
|
|
|
|
"D260" => { TYPE => "7200", SPEED => 120 }, |
|
52
|
|
|
|
|
|
|
"D270" => { TYPE => "8000", SPEED => 160 }, |
|
53
|
|
|
|
|
|
|
"D280" => { TYPE => "8000", SPEED => 180 }, |
|
54
|
|
|
|
|
|
|
"D310" => { TYPE => "7100LC", SPEED => 100 }, |
|
55
|
|
|
|
|
|
|
"D320" => { TYPE => "7300LC", SPEED => 132 }, |
|
56
|
|
|
|
|
|
|
"D330" => { TYPE => "7300LC", SPEED => 160 }, |
|
57
|
|
|
|
|
|
|
"D350" => { TYPE => "7200", SPEED => 100 }, |
|
58
|
|
|
|
|
|
|
"D360" => { TYPE => "7200", SPEED => 120 }, |
|
59
|
|
|
|
|
|
|
"D370" => { TYPE => "8000", SPEED => 160 }, |
|
60
|
|
|
|
|
|
|
"D380" => { TYPE => "8000", SPEED => 180 }, |
|
61
|
|
|
|
|
|
|
"D390" => { TYPE => "8200", SPEED => 240 }, |
|
62
|
|
|
|
|
|
|
"K360" => { TYPE => "8000", SPEED => 180 }, |
|
63
|
|
|
|
|
|
|
"K370" => { TYPE => "8200", SPEED => 200 }, |
|
64
|
|
|
|
|
|
|
"K380" => { TYPE => "8200", SPEED => 240 }, |
|
65
|
|
|
|
|
|
|
"K400" => { TYPE => "7200", SPEED => 140 }, |
|
66
|
|
|
|
|
|
|
"K410" => { TYPE => "7200", SPEED => 120 }, |
|
67
|
|
|
|
|
|
|
"K420" => { TYPE => "7200", SPEED => 120 }, |
|
68
|
|
|
|
|
|
|
"K460" => { TYPE => "8000", SPEED => 180 }, |
|
69
|
|
|
|
|
|
|
"K570" => { TYPE => "8200", SPEED => 200 }, |
|
70
|
|
|
|
|
|
|
"K580" => { TYPE => "8200", SPEED => 240 }, |
|
71
|
|
|
|
|
|
|
"L1000-36" => { TYPE => "8500", SPEED => 360 }, |
|
72
|
|
|
|
|
|
|
"L1500-7x" => { TYPE => "8700", SPEED => 750 }, |
|
73
|
|
|
|
|
|
|
"L3000-7x" => { TYPE => "8700", SPEED => 750 }, |
|
74
|
|
|
|
|
|
|
"N4000-44" => { TYPE => "8500", SPEED => 440 }, |
|
75
|
|
|
|
|
|
|
"ia64 hp server rx1620" => { TYPE => "itanium", SPEED => 1600 } |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $device = getFirstLine(command => 'model |cut -f 3- -d/'); |
|
79
|
0
|
0
|
|
|
|
|
if ($cpuInfos{$device}) { |
|
80
|
0
|
|
|
|
|
|
$CPUinfo = $cpuInfos{$device}; |
|
81
|
|
|
|
|
|
|
} else { |
|
82
|
0
|
|
|
|
|
|
$CPUinfo->{TYPE} = getFirstMatch( |
|
83
|
|
|
|
|
|
|
command => "echo 'sc product cpu;il' | /usr/sbin/cstm", |
|
84
|
|
|
|
|
|
|
logger => $logger, |
|
85
|
|
|
|
|
|
|
pattern => qr/(\S+)\s+CPU\s+Module/, |
|
86
|
|
|
|
|
|
|
); |
|
87
|
0
|
|
|
|
|
|
$CPUinfo->{SPEED} = getFirstMatch( |
|
88
|
|
|
|
|
|
|
command => "echo 'itick_per_usec/D' | adb -k /stand/vmunix /dev/kmem", |
|
89
|
|
|
|
|
|
|
logger => $logger, |
|
90
|
|
|
|
|
|
|
pattern => qr/tick_per_usec:\s+(\d+)/ |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
# NBR CPU |
|
94
|
0
|
|
|
|
|
|
$CPUinfo->{CPUcount} = getLinesCount( |
|
95
|
|
|
|
|
|
|
command => 'ioscan -Fk -C processor' |
|
96
|
|
|
|
|
|
|
); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $serie = getFirstLine(command => 'uname -m'); |
|
100
|
0
|
0
|
0
|
|
|
|
if ( $CPUinfo->{TYPE} eq 'unknow' and $serie =~ /ia64/) { |
|
101
|
0
|
|
|
|
|
|
$CPUinfo->{TYPE} = "Itanium" |
|
102
|
|
|
|
|
|
|
} |
|
103
|
0
|
0
|
|
|
|
|
if ( $serie =~ /9000/) { |
|
104
|
0
|
|
|
|
|
|
$CPUinfo->{TYPE} = "PA" . $CPUinfo->{TYPE}; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
foreach ( 1..$CPUinfo->{CPUcount} ) { |
|
108
|
0
|
|
|
|
|
|
$inventory->addEntry( |
|
109
|
|
|
|
|
|
|
section => 'CPUS', |
|
110
|
|
|
|
|
|
|
entry => $CPUinfo |
|
111
|
|
|
|
|
|
|
); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _parseMachinInfo { |
|
116
|
0
|
|
|
0
|
|
|
my $info = getInfoFromMachinfo(@_); |
|
117
|
0
|
0
|
|
|
|
|
return unless $info; |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $result; |
|
120
|
0
|
|
|
|
|
|
my $cpu_info = $info->{'CPU info'}; |
|
121
|
0
|
0
|
|
|
|
|
if (ref $cpu_info eq 'HASH') { |
|
122
|
|
|
|
|
|
|
# HPUX 11.23 |
|
123
|
0
|
|
|
|
|
|
$result->{CPUcount} = $cpu_info->{'number of cpus'}; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
if ($cpu_info->{'clock speed'} =~ /(\d+) MHz/) { |
|
126
|
0
|
|
|
|
|
|
$result->{SPEED} = $1; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
if ($cpu_info->{'processor model'} =~ /Intel/) { |
|
130
|
0
|
|
|
|
|
|
$result->{MANUFACTURER} = 'Intel'; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if ($cpu_info->{'processor model'} =~ /Itanium/) { |
|
134
|
0
|
|
|
|
|
|
$result->{NAME} = 'Itanium'; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
} else { |
|
137
|
|
|
|
|
|
|
# HPUX 11.31 |
|
138
|
0
|
0
|
|
|
|
|
if ($cpu_info =~ /^(\d+) /) { |
|
139
|
0
|
|
|
|
|
|
$result->{CPUcount} = $1; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
0
|
0
|
|
|
|
|
if ($cpu_info =~ /([\d.]+) GHz/) { |
|
142
|
0
|
|
|
|
|
|
$result->{SPEED} = $1 * 1000; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
0
|
0
|
|
|
|
|
if ($cpu_info =~ /Intel/) { |
|
145
|
0
|
|
|
|
|
|
$result->{MANUFACTURER} = 'Intel'; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
0
|
0
|
|
|
|
|
if ($cpu_info =~ /Itanium/) { |
|
148
|
0
|
|
|
|
|
|
$result->{NAME} = 'Itanium'; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
0
|
0
|
|
|
|
|
if ($cpu_info =~ /(\d+) logical processors/ ) { |
|
151
|
0
|
|
|
|
|
|
$result->{CORE} = $1 / $result->{CPUcount}; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
return $result; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _parseCprop { |
|
159
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
|
160
|
0
|
0
|
|
|
|
|
return unless $handle; |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
my @cpus; |
|
163
|
|
|
|
|
|
|
my $instance; |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
|
166
|
0
|
0
|
|
|
|
|
if ($line =~ /^\[Instance\]: \d+/) { |
|
167
|
|
|
|
|
|
|
# new block |
|
168
|
0
|
|
|
|
|
|
$instance = {}; |
|
169
|
0
|
|
|
|
|
|
next; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
0
|
|
|
|
|
if ($line =~ /^ \s+ \[ ([^\]]+) \]: \s (.+)/x) { |
|
173
|
0
|
|
|
|
|
|
$instance->{$1} = $2; |
|
174
|
0
|
|
|
|
|
|
next; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
0
|
|
|
|
|
if ($line =~ /^\*+/) { |
|
178
|
0
|
0
|
|
|
|
|
next unless keys %$instance; |
|
179
|
|
|
|
|
|
|
|
|
180
|
0
|
0
|
|
|
|
|
my $name = $instance->{'Processor Type'} =~ /Itanium/ ? |
|
181
|
|
|
|
|
|
|
'Itanium' : undef; |
|
182
|
0
|
0
|
|
|
|
|
my $manufacturer = $instance->{'Processor Type'} =~ /Intel/ ? |
|
183
|
|
|
|
|
|
|
'Intel' : undef; |
|
184
|
0
|
|
|
|
|
|
my $cpu = { |
|
185
|
|
|
|
|
|
|
SPEED => $instance->{'Processor Speed'}, |
|
186
|
|
|
|
|
|
|
ID => $instance->{'Tag'}, |
|
187
|
|
|
|
|
|
|
NAME => $name, |
|
188
|
|
|
|
|
|
|
MANUFACTURER => $manufacturer |
|
189
|
|
|
|
|
|
|
}; |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
0
|
|
|
|
|
if ($instance->{'Location'} =~ /Cell Slot Number (\d+)\b/i) { |
|
192
|
|
|
|
|
|
|
# this is a single core from a multi-core cpu |
|
193
|
0
|
|
|
|
|
|
my $slotId = $1; |
|
194
|
0
|
0
|
|
|
|
|
if ($cpus[$slotId]) { |
|
195
|
0
|
|
|
|
|
|
$cpus[$slotId]->{CORE}++; |
|
196
|
|
|
|
|
|
|
} else { |
|
197
|
0
|
|
|
|
|
|
$cpus[$slotId] = $cpu; |
|
198
|
0
|
|
|
|
|
|
$cpus[$slotId]->{CORE}=1; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
} else { |
|
201
|
0
|
|
|
|
|
|
push @cpus, $cpu; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
} |
|
205
|
0
|
|
|
|
|
|
close $handle; |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# filter missing cpus |
|
208
|
0
|
|
|
|
|
|
@cpus = grep { $_ } @cpus; |
|
|
0
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
return @cpus; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
1; |