line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::HPUX::CPU; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
81868991
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
75
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
38
|
|
|
2
|
|
|
|
|
20
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1188
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
244
|
|
9
|
2
|
|
|
2
|
|
679
|
use FusionInventory::Agent::Tools::HPUX; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1689
|
|
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
|
|
|
|
47
|
return unless $info; |
118
|
|
|
|
|
|
|
|
119
|
6
|
|
|
|
|
3
|
my $result; |
120
|
6
|
|
|
|
|
14
|
my $cpu_info = $info->{'CPU info'}; |
121
|
6
|
100
|
|
|
|
12
|
if (ref $cpu_info eq 'HASH') { |
122
|
|
|
|
|
|
|
# HPUX 11.23 |
123
|
1
|
|
|
|
|
1
|
$result->{CPUcount} = $cpu_info->{'number of cpus'}; |
124
|
|
|
|
|
|
|
|
125
|
1
|
50
|
|
|
|
6
|
if ($cpu_info->{'clock speed'} =~ /(\d+) MHz/) { |
126
|
1
|
|
|
|
|
2
|
$result->{SPEED} = $1; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
1
|
50
|
|
|
|
3
|
if ($cpu_info->{'processor model'} =~ /Intel/) { |
130
|
1
|
|
|
|
|
2
|
$result->{MANUFACTURER} = 'Intel'; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
1
|
50
|
|
|
|
3
|
if ($cpu_info->{'processor model'} =~ /Itanium/) { |
134
|
1
|
|
|
|
|
1
|
$result->{NAME} = 'Itanium'; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} else { |
137
|
|
|
|
|
|
|
# HPUX 11.31 |
138
|
5
|
50
|
|
|
|
17
|
if ($cpu_info =~ /^(\d+) /) { |
139
|
5
|
|
|
|
|
12
|
$result->{CPUcount} = $1; |
140
|
|
|
|
|
|
|
} |
141
|
5
|
50
|
|
|
|
19
|
if ($cpu_info =~ /([\d.]+) GHz/) { |
142
|
5
|
|
|
|
|
17
|
$result->{SPEED} = $1 * 1000; |
143
|
|
|
|
|
|
|
} |
144
|
5
|
50
|
|
|
|
10
|
if ($cpu_info =~ /Intel/) { |
145
|
5
|
|
|
|
|
6
|
$result->{MANUFACTURER} = 'Intel'; |
146
|
|
|
|
|
|
|
} |
147
|
5
|
50
|
|
|
|
9
|
if ($cpu_info =~ /Itanium/) { |
148
|
5
|
|
|
|
|
4
|
$result->{NAME} = 'Itanium'; |
149
|
|
|
|
|
|
|
} |
150
|
5
|
100
|
|
|
|
15
|
if ($cpu_info =~ /(\d+) logical processors/ ) { |
151
|
2
|
|
|
|
|
5
|
$result->{CORE} = $1 / $result->{CPUcount}; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
6
|
|
|
|
|
10
|
return $result; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _parseCprop { |
159
|
1
|
|
|
1
|
|
303
|
my $handle = getFileHandle(@_); |
160
|
1
|
50
|
|
|
|
4
|
return unless $handle; |
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
2
|
my @cpus; |
163
|
|
|
|
|
|
|
my $instance; |
164
|
|
|
|
|
|
|
|
165
|
1
|
|
|
|
|
19
|
while (my $line = <$handle>) { |
166
|
109
|
100
|
|
|
|
130
|
if ($line =~ /^\[Instance\]: \d+/) { |
167
|
|
|
|
|
|
|
# new block |
168
|
8
|
|
|
|
|
7
|
$instance = {}; |
169
|
8
|
|
|
|
|
24
|
next; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
101
|
100
|
|
|
|
234
|
if ($line =~ /^ \s+ \[ ([^\]]+) \]: \s (.+)/x) { |
173
|
80
|
|
|
|
|
126
|
$instance->{$1} = $2; |
174
|
80
|
|
|
|
|
166
|
next; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
21
|
100
|
|
|
|
47
|
if ($line =~ /^\*+/) { |
178
|
16
|
100
|
|
|
|
29
|
next unless keys %$instance; |
179
|
|
|
|
|
|
|
|
180
|
8
|
50
|
|
|
|
17
|
my $name = $instance->{'Processor Type'} =~ /Itanium/ ? |
181
|
|
|
|
|
|
|
'Itanium' : undef; |
182
|
8
|
50
|
|
|
|
16
|
my $manufacturer = $instance->{'Processor Type'} =~ /Intel/ ? |
183
|
|
|
|
|
|
|
'Intel' : undef; |
184
|
|
|
|
|
|
|
my $cpu = { |
185
|
|
|
|
|
|
|
SPEED => $instance->{'Processor Speed'}, |
186
|
8
|
|
|
|
|
19
|
ID => $instance->{'Tag'}, |
187
|
|
|
|
|
|
|
NAME => $name, |
188
|
|
|
|
|
|
|
MANUFACTURER => $manufacturer |
189
|
|
|
|
|
|
|
}; |
190
|
|
|
|
|
|
|
|
191
|
8
|
50
|
|
|
|
25
|
if ($instance->{'Location'} =~ /Cell Slot Number (\d+)\b/i) { |
192
|
|
|
|
|
|
|
# this is a single core from a multi-core cpu |
193
|
8
|
|
|
|
|
11
|
my $slotId = $1; |
194
|
8
|
100
|
|
|
|
18
|
if ($cpus[$slotId]) { |
195
|
6
|
|
|
|
|
30
|
$cpus[$slotId]->{CORE}++; |
196
|
|
|
|
|
|
|
} else { |
197
|
2
|
|
|
|
|
3
|
$cpus[$slotId] = $cpu; |
198
|
2
|
|
|
|
|
8
|
$cpus[$slotId]->{CORE}=1; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} else { |
201
|
0
|
|
|
|
|
0
|
push @cpus, $cpu; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
} |
205
|
1
|
|
|
|
|
6
|
close $handle; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# filter missing cpus |
208
|
1
|
|
|
|
|
2
|
@cpus = grep { $_ } @cpus; |
|
5
|
|
|
|
|
7
|
|
209
|
|
|
|
|
|
|
|
210
|
1
|
|
|
|
|
6
|
return @cpus; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
1; |