line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::HPUX::CPU; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
94707761
|
use strict; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
133
|
|
4
|
2
|
|
|
2
|
|
24
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
170
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
108
|
|
|
2
|
|
|
|
|
42
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
3151
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
398
|
|
9
|
2
|
|
|
2
|
|
1185
|
use FusionInventory::Agent::Tools::HPUX; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
2577
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub isEnabled { |
12
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
13
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{cpu}; |
14
|
0
|
|
|
|
|
0
|
return 1; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub doInventory { |
18
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
21
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# http://forge.fusioninventory.org/issues/755 |
24
|
0
|
0
|
0
|
|
|
0
|
if (canRun('/opt/propplus/bin/cprop') && !isHPVMGuest()) { |
25
|
0
|
|
|
|
|
0
|
foreach my $cpu (_parseCprop( |
26
|
|
|
|
|
|
|
command => '/opt/propplus/bin/cprop -summary -c Processors', |
27
|
|
|
|
|
|
|
logger => $logger |
28
|
|
|
|
|
|
|
)) { |
29
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
30
|
|
|
|
|
|
|
section => 'CPUS', |
31
|
|
|
|
|
|
|
entry => $cpu |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
0
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
my $CPUinfo; |
38
|
0
|
0
|
|
|
|
0
|
if (canRun('/usr/contrib/bin/machinfo')) { |
39
|
0
|
|
|
|
|
0
|
$CPUinfo = _parseMachinInfo( |
40
|
|
|
|
|
|
|
command => '/usr/contrib/bin/machinfo', |
41
|
|
|
|
|
|
|
logger => $logger |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} else { |
44
|
|
|
|
|
|
|
# old HpUX without machinfo |
45
|
0
|
|
|
|
|
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
|
|
|
|
|
0
|
my $device = getFirstLine(command => 'model |cut -f 3- -d/'); |
79
|
0
|
0
|
|
|
|
0
|
if ($cpuInfos{$device}) { |
80
|
0
|
|
|
|
|
0
|
$CPUinfo = $cpuInfos{$device}; |
81
|
|
|
|
|
|
|
} else { |
82
|
0
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
0
|
$CPUinfo->{CPUcount} = getLinesCount( |
95
|
|
|
|
|
|
|
command => 'ioscan -Fk -C processor' |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
my $serie = getFirstLine(command => 'uname -m'); |
100
|
0
|
0
|
0
|
|
|
0
|
if ( $CPUinfo->{TYPE} eq 'unknow' and $serie =~ /ia64/) { |
101
|
0
|
|
|
|
|
0
|
$CPUinfo->{TYPE} = "Itanium" |
102
|
|
|
|
|
|
|
} |
103
|
0
|
0
|
|
|
|
0
|
if ( $serie =~ /9000/) { |
104
|
0
|
|
|
|
|
0
|
$CPUinfo->{TYPE} = "PA" . $CPUinfo->{TYPE}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
foreach ( 1..$CPUinfo->{CPUcount} ) { |
108
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
109
|
|
|
|
|
|
|
section => 'CPUS', |
110
|
|
|
|
|
|
|
entry => $CPUinfo |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _parseMachinInfo { |
116
|
6
|
|
|
6
|
|
1607
|
my $info = getInfoFromMachinfo(@_); |
117
|
6
|
50
|
|
|
|
65
|
return unless $info; |
118
|
|
|
|
|
|
|
|
119
|
6
|
|
|
|
|
7
|
my $result; |
120
|
6
|
|
|
|
|
10
|
my $cpu_info = $info->{'CPU info'}; |
121
|
6
|
100
|
|
|
|
15
|
if (ref $cpu_info eq 'HASH') { |
122
|
|
|
|
|
|
|
# HPUX 11.23 |
123
|
1
|
|
|
|
|
4
|
$result->{CPUcount} = $cpu_info->{'number of cpus'}; |
124
|
|
|
|
|
|
|
|
125
|
1
|
50
|
|
|
|
7
|
if ($cpu_info->{'clock speed'} =~ /(\d+) MHz/) { |
126
|
1
|
|
|
|
|
3
|
$result->{SPEED} = $1; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
1
|
50
|
|
|
|
5
|
if ($cpu_info->{'processor model'} =~ /Intel/) { |
130
|
1
|
|
|
|
|
3
|
$result->{MANUFACTURER} = 'Intel'; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
1
|
50
|
|
|
|
5
|
if ($cpu_info->{'processor model'} =~ /Itanium/) { |
134
|
1
|
|
|
|
|
2
|
$result->{NAME} = 'Itanium'; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} else { |
137
|
|
|
|
|
|
|
# HPUX 11.31 |
138
|
5
|
50
|
|
|
|
22
|
if ($cpu_info =~ /^(\d+) /) { |
139
|
5
|
|
|
|
|
16
|
$result->{CPUcount} = $1; |
140
|
|
|
|
|
|
|
} |
141
|
5
|
50
|
|
|
|
26
|
if ($cpu_info =~ /([\d.]+) GHz/) { |
142
|
5
|
|
|
|
|
21
|
$result->{SPEED} = $1 * 1000; |
143
|
|
|
|
|
|
|
} |
144
|
5
|
50
|
|
|
|
15
|
if ($cpu_info =~ /Intel/) { |
145
|
5
|
|
|
|
|
11
|
$result->{MANUFACTURER} = 'Intel'; |
146
|
|
|
|
|
|
|
} |
147
|
5
|
50
|
|
|
|
11
|
if ($cpu_info =~ /Itanium/) { |
148
|
5
|
|
|
|
|
11
|
$result->{NAME} = 'Itanium'; |
149
|
|
|
|
|
|
|
} |
150
|
5
|
100
|
|
|
|
23
|
if ($cpu_info =~ /(\d+) logical processors/ ) { |
151
|
2
|
|
|
|
|
7
|
$result->{CORE} = $1 / $result->{CPUcount}; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
6
|
|
|
|
|
14
|
return $result; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _parseCprop { |
159
|
1
|
|
|
1
|
|
287
|
my $handle = getFileHandle(@_); |
160
|
1
|
50
|
|
|
|
5
|
return unless $handle; |
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
2
|
my @cpus; |
163
|
|
|
|
|
|
|
my $instance; |
164
|
|
|
|
|
|
|
|
165
|
1
|
|
|
|
|
24
|
while (my $line = <$handle>) { |
166
|
109
|
100
|
|
|
|
225
|
if ($line =~ /^\[Instance\]: \d+/) { |
167
|
|
|
|
|
|
|
# new block |
168
|
8
|
|
|
|
|
14
|
$instance = {}; |
169
|
8
|
|
|
|
|
41
|
next; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
101
|
100
|
|
|
|
338
|
if ($line =~ /^ \s+ \[ ([^\]]+) \]: \s (.+)/x) { |
173
|
80
|
|
|
|
|
262
|
$instance->{$1} = $2; |
174
|
80
|
|
|
|
|
232
|
next; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
21
|
100
|
|
|
|
70
|
if ($line =~ /^\*+/) { |
178
|
16
|
100
|
|
|
|
51
|
next unless keys %$instance; |
179
|
|
|
|
|
|
|
|
180
|
8
|
50
|
|
|
|
25
|
my $name = $instance->{'Processor Type'} =~ /Itanium/ ? |
181
|
|
|
|
|
|
|
'Itanium' : undef; |
182
|
8
|
50
|
|
|
|
27
|
my $manufacturer = $instance->{'Processor Type'} =~ /Intel/ ? |
183
|
|
|
|
|
|
|
'Intel' : undef; |
184
|
|
|
|
|
|
|
my $cpu = { |
185
|
|
|
|
|
|
|
SPEED => $instance->{'Processor Speed'}, |
186
|
8
|
|
|
|
|
33
|
ID => $instance->{'Tag'}, |
187
|
|
|
|
|
|
|
NAME => $name, |
188
|
|
|
|
|
|
|
MANUFACTURER => $manufacturer |
189
|
|
|
|
|
|
|
}; |
190
|
|
|
|
|
|
|
|
191
|
8
|
50
|
|
|
|
38
|
if ($instance->{'Location'} =~ /Cell Slot Number (\d+)\b/i) { |
192
|
|
|
|
|
|
|
# this is a single core from a multi-core cpu |
193
|
8
|
|
|
|
|
17
|
my $slotId = $1; |
194
|
8
|
100
|
|
|
|
24
|
if ($cpus[$slotId]) { |
195
|
6
|
|
|
|
|
31
|
$cpus[$slotId]->{CORE}++; |
196
|
|
|
|
|
|
|
} else { |
197
|
2
|
|
|
|
|
5
|
$cpus[$slotId] = $cpu; |
198
|
2
|
|
|
|
|
9
|
$cpus[$slotId]->{CORE}=1; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} else { |
201
|
0
|
|
|
|
|
0
|
push @cpus, $cpu; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
} |
205
|
1
|
|
|
|
|
8
|
close $handle; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# filter missing cpus |
208
|
1
|
|
|
|
|
3
|
@cpus = grep { $_ } @cpus; |
|
5
|
|
|
|
|
10
|
|
209
|
|
|
|
|
|
|
|
210
|
1
|
|
|
|
|
7
|
return @cpus; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
1; |