sys-cpu 0.6.2-x86-mingw32 → 0.6.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +9 -1
- data/MANIFEST +2 -2
- data/README +58 -61
- data/Rakefile +48 -45
- data/examples/example_sys_cpu_linux.rb +5 -6
- data/ext/bsd/bsd.c +1 -1
- data/ext/extconf.rb +5 -4
- data/ext/hpux/hpux.c +1 -1
- data/ext/sunos/sunos.c +1 -1
- data/ext/version.h +1 -1
- data/install.rb +34 -33
- data/lib/linux/sys/cpu.rb +1 -1
- data/lib/windows/sys/cpu.rb +759 -753
- data/sys-cpu.gemspec +2 -2
- data/test/test_sys_cpu_version.rb +3 -3
- data/test/test_sys_cpu_windows.rb +47 -47
- metadata +27 -9
data/lib/linux/sys/cpu.rb
CHANGED
data/lib/windows/sys/cpu.rb
CHANGED
@@ -3,782 +3,788 @@ require 'socket'
|
|
3
3
|
|
4
4
|
# The Sys module serves only as a namespace
|
5
5
|
module Sys
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# Encapsulates system CPU information
|
7
|
+
class CPU
|
8
|
+
# Error raised if any of the Sys::CPU methods fail.
|
9
|
+
class Error < StandardError; end
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
# The version of the sys-cpu library
|
12
|
+
VERSION = '0.6.3'
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
14
|
+
private
|
15
|
+
|
16
|
+
# Base connect string
|
17
|
+
BASE_CS = "winmgmts:{impersonationLevel=impersonate}" # :nodoc:
|
18
|
+
|
19
|
+
# Fields used in the CPUStruct
|
20
|
+
fields = %w/
|
21
|
+
address_width
|
22
|
+
architecture
|
23
|
+
availability
|
24
|
+
caption
|
25
|
+
config_manager_error_code
|
26
|
+
config_manager_user_config
|
27
|
+
cpu_status
|
28
|
+
creation_class_name
|
29
|
+
freq
|
30
|
+
voltage
|
31
|
+
data_width
|
32
|
+
description
|
33
|
+
device_id
|
34
|
+
error_cleared?
|
35
|
+
error_description
|
36
|
+
ext_clock
|
37
|
+
family
|
38
|
+
install_date
|
39
|
+
l2_cache_size
|
40
|
+
l2_cache_speed
|
41
|
+
last_error_code
|
42
|
+
level
|
43
|
+
load_avg
|
44
|
+
manufacturer
|
45
|
+
max_clock_speed
|
46
|
+
name
|
47
|
+
other_family_description
|
48
|
+
pnp_device_id
|
49
|
+
power_management_supported?
|
50
|
+
power_management_capabilities
|
51
|
+
processor_id
|
52
|
+
processor_type
|
53
|
+
revision
|
54
|
+
role
|
55
|
+
socket_designation
|
56
|
+
status
|
57
|
+
status_info
|
58
|
+
stepping
|
59
|
+
system_creation_class_name
|
60
|
+
system_name
|
61
|
+
unique_id
|
62
|
+
upgrade_method
|
63
|
+
version
|
64
|
+
voltage_caps
|
65
|
+
/
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
# The struct returned by the CPU.processors method
|
68
|
+
CPUStruct = Struct.new("CPUStruct", *fields) # :nodoc:
|
69
|
+
|
70
|
+
public
|
67
71
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
72
|
+
# Returns the +host+ CPU's architecture, or nil if it cannot be
|
73
|
+
# determined.
|
74
|
+
#
|
75
|
+
def self.architecture(host=Socket.gethostname)
|
76
|
+
cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu0'"
|
77
|
+
begin
|
78
|
+
wmi = WIN32OLE.connect(cs)
|
79
|
+
rescue WIN32OLERuntimeError => e
|
80
|
+
raise Error, e
|
81
|
+
else
|
82
|
+
self.get_cpu_arch(wmi.Architecture)
|
80
83
|
end
|
84
|
+
end
|
81
85
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
86
|
+
# Returns an integer indicating the speed (i.e. frequency in Mhz) of
|
87
|
+
# +cpu_num+ on +host+, or the localhost if no +host+ is specified.
|
88
|
+
# If +cpu_num+ +1 is greater than the number of cpu's on your system
|
89
|
+
# or this call fails for any other reason, a Error is raised.
|
90
|
+
#
|
91
|
+
def self.freq(cpu_num = 0, host = Socket.gethostname)
|
92
|
+
cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu#{cpu_num}'"
|
93
|
+
begin
|
94
|
+
wmi = WIN32OLE.connect(cs)
|
95
|
+
rescue WIN32OLERuntimeError => e
|
96
|
+
raise Error, e
|
97
|
+
else
|
98
|
+
return wmi.CurrentClockSpeed
|
96
99
|
end
|
100
|
+
end
|
97
101
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
102
|
+
# Returns the load capacity for +cpu_num+ on +host+, or the localhost
|
103
|
+
# if no host is specified, averaged to the last second. Processor
|
104
|
+
# loading refers to the total computing burden for each processor at
|
105
|
+
# one time.
|
106
|
+
#
|
107
|
+
# Note that this attribute is actually the LoadPercentage. I may use
|
108
|
+
# one of the Win32_Perf* classes in the future.
|
109
|
+
#
|
110
|
+
def self.load_avg(cpu_num = 0, host = Socket.gethostname)
|
111
|
+
cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu#{cpu_num}'"
|
112
|
+
begin
|
113
|
+
wmi = WIN32OLE.connect(cs)
|
114
|
+
rescue WIN32OLERuntimeError => e
|
115
|
+
raise Error, e
|
116
|
+
else
|
117
|
+
return wmi.LoadPercentage
|
118
|
+
end
|
119
|
+
end
|
116
120
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
121
|
+
# Returns a string indicating the cpu model, e.g. Intel Pentium 4.
|
122
|
+
#
|
123
|
+
def self.model(host = Socket.gethostname)
|
124
|
+
cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu0'"
|
125
|
+
begin
|
126
|
+
wmi = WIN32OLE.connect(cs)
|
127
|
+
rescue WIN32OLERuntimeError => e
|
128
|
+
raise Error, e
|
129
|
+
else
|
130
|
+
return wmi.Name
|
128
131
|
end
|
132
|
+
end
|
129
133
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
end
|
134
|
+
# Returns an integer indicating the number of cpu's on the system.
|
135
|
+
#--
|
136
|
+
# This (oddly) requires a different class.
|
137
|
+
#
|
138
|
+
def self.num_cpu(host = Socket.gethostname)
|
139
|
+
cs = BASE_CS + "//#{host}/root/cimv2:Win32_ComputerSystem='#{host}'"
|
140
|
+
begin
|
141
|
+
wmi = WIN32OLE.connect(cs)
|
142
|
+
rescue WIN32OLERuntimeError => e
|
143
|
+
raise Error, e
|
144
|
+
else
|
145
|
+
return wmi.NumberOfProcessors
|
143
146
|
end
|
147
|
+
end
|
144
148
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
149
|
+
# Returns a CPUStruct for each CPU on +host+, or the localhost if no
|
150
|
+
# +host+ is specified. A CPUStruct contains the following members:
|
151
|
+
#
|
152
|
+
# * address_width
|
153
|
+
# * architecture
|
154
|
+
# * availability
|
155
|
+
# * caption
|
156
|
+
# * config_manager_error_code
|
157
|
+
# * config_manager_user_config
|
158
|
+
# * cpu_status
|
159
|
+
# * creation_class_name
|
160
|
+
# * freq
|
161
|
+
# * voltage
|
162
|
+
# * data_width
|
163
|
+
# * description
|
164
|
+
# * device_id
|
165
|
+
# * error_cleared?
|
166
|
+
# * error_description
|
167
|
+
# * ext_clock
|
168
|
+
# * family
|
169
|
+
# * install_date
|
170
|
+
# * l2_cache_size
|
171
|
+
# * l2_cache_speed
|
172
|
+
# * last_error_code
|
173
|
+
# * level
|
174
|
+
# * load_avg
|
175
|
+
# * manufacturer
|
176
|
+
# * max_clock_speed
|
177
|
+
# * name
|
178
|
+
# * other_family_description
|
179
|
+
# * pnp_device_id
|
180
|
+
# * power_management_supported?
|
181
|
+
# * power_management_capabilities
|
182
|
+
# * processor_id
|
183
|
+
# * processor_type
|
184
|
+
# * revision
|
185
|
+
# * role
|
186
|
+
# * socket_designation
|
187
|
+
# * status
|
188
|
+
# * status_info
|
189
|
+
# * stepping
|
190
|
+
# * system_creation_class_name
|
191
|
+
# * system_name
|
192
|
+
# * unique_id
|
193
|
+
# * upgrade_method
|
194
|
+
# * version
|
195
|
+
# * voltage_caps
|
196
|
+
#
|
197
|
+
# Note that not all of these members will necessarily be defined.
|
198
|
+
#
|
199
|
+
def self.processors(host = Socket.gethostname) # :yields: CPUStruct
|
200
|
+
begin
|
201
|
+
wmi = WIN32OLE.connect(BASE_CS + "//#{host}/root/cimv2")
|
202
|
+
rescue WIN32OLERuntimeError => e
|
203
|
+
raise Error, e
|
204
|
+
else
|
205
|
+
wmi.InstancesOf("Win32_Processor").each{ |cpu|
|
206
|
+
yield CPUStruct.new(
|
207
|
+
cpu.AddressWidth,
|
208
|
+
self.get_cpu_arch(cpu.Architecture),
|
209
|
+
self.get_availability(cpu.Availability),
|
210
|
+
cpu.Caption,
|
211
|
+
self.get_cmec(cpu.ConfigManagerErrorCode),
|
212
|
+
cpu.ConfigManagerUserConfig,
|
213
|
+
get_status(cpu.CpuStatus),
|
214
|
+
cpu.CreationClassName,
|
215
|
+
cpu.CurrentClockSpeed,
|
216
|
+
cpu.CurrentVoltage,
|
217
|
+
cpu.DataWidth,
|
218
|
+
cpu.Description,
|
219
|
+
cpu.DeviceId,
|
220
|
+
cpu.ErrorCleared,
|
221
|
+
cpu.ErrorDescription,
|
222
|
+
cpu.ExtClock,
|
223
|
+
self.get_family(cpu.Family),
|
224
|
+
cpu.InstallDate,
|
225
|
+
cpu.L2CacheSize,
|
226
|
+
cpu.L2CacheSpeed,
|
227
|
+
cpu.LastErrorCode,
|
228
|
+
cpu.Level,
|
229
|
+
cpu.LoadPercentage,
|
230
|
+
cpu.Manufacturer,
|
231
|
+
cpu.MaxClockSpeed,
|
232
|
+
cpu.Name,
|
233
|
+
cpu.OtherFamilyDescription,
|
234
|
+
cpu.PNPDeviceID,
|
235
|
+
cpu.PowerManagementSupported,
|
236
|
+
cpu.PowerManagementCapabilities,
|
237
|
+
cpu.ProcessorId,
|
238
|
+
self.get_processor_type(cpu.ProcessorType),
|
239
|
+
cpu.Revision,
|
240
|
+
cpu.Role,
|
241
|
+
cpu.SocketDesignation,
|
242
|
+
cpu.Status,
|
243
|
+
cpu.StatusInfo,
|
244
|
+
cpu.Stepping,
|
245
|
+
cpu.SystemCreationClassName,
|
246
|
+
cpu.SystemName,
|
247
|
+
cpu.UniqueId,
|
248
|
+
self.get_upgrade_method(cpu.UpgradeMethod),
|
249
|
+
cpu.Version,
|
250
|
+
self.get_voltage_caps(cpu.VoltageCaps)
|
251
|
+
)
|
252
|
+
}
|
253
|
+
end
|
254
|
+
end
|
251
255
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
end
|
256
|
+
# Returns a string indicating the type of processor, e.g. GenuineIntel.
|
257
|
+
#
|
258
|
+
def self.type(host = Socket.gethostname)
|
259
|
+
cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu0'"
|
260
|
+
begin
|
261
|
+
wmi = WIN32OLE.connect(cs)
|
262
|
+
rescue WIN32OLERuntimeError => e
|
263
|
+
raise Error, e
|
264
|
+
else
|
265
|
+
return wmi.Manufacturer
|
263
266
|
end
|
267
|
+
end
|
264
268
|
|
265
|
-
|
269
|
+
private
|
266
270
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
end
|
271
|
+
# Convert the ConfigManagerErrorCode number to its corresponding string
|
272
|
+
# Note that this value returns nil on my system.
|
273
|
+
#
|
274
|
+
def self.get_cmec(num)
|
275
|
+
case
|
276
|
+
when 0
|
277
|
+
str = "The device is working properly."
|
278
|
+
return str
|
279
|
+
when 1
|
280
|
+
str = "The device is not configured correctly."
|
281
|
+
return str
|
282
|
+
when 2
|
283
|
+
str = "Windows cannot load the driver for the device."
|
284
|
+
return str
|
285
|
+
when 3
|
286
|
+
str = "The driver for the device might be corrupted, or the"
|
287
|
+
str << " system may be running low on memory or other"
|
288
|
+
str << " resources."
|
289
|
+
return str
|
290
|
+
when 4
|
291
|
+
str = "The device is not working properly. One of the drivers"
|
292
|
+
str << " or the registry might be corrupted."
|
293
|
+
return str
|
294
|
+
when 5
|
295
|
+
str = "The driver for this device needs a resource that"
|
296
|
+
str << " Windows cannot manage."
|
297
|
+
return str
|
298
|
+
when 6
|
299
|
+
str = "The boot configuration for this device conflicts with"
|
300
|
+
str << " other devices."
|
301
|
+
return str
|
302
|
+
when 7
|
303
|
+
str = "Cannot filter."
|
304
|
+
return str
|
305
|
+
when 8
|
306
|
+
str = "The driver loader for the device is missing."
|
307
|
+
return str
|
308
|
+
when 9
|
309
|
+
str = "This device is not working properly because the"
|
310
|
+
str << " controlling firmware is reporting the resources"
|
311
|
+
str << " for the device incorrectly."
|
312
|
+
return str
|
313
|
+
when 10
|
314
|
+
str = "This device cannot start."
|
315
|
+
return str
|
316
|
+
when 11
|
317
|
+
str = "This device failed."
|
318
|
+
return str
|
319
|
+
when 12
|
320
|
+
str = "This device cannot find enough free resources that"
|
321
|
+
str << " it can use."
|
322
|
+
return str
|
323
|
+
when 13
|
324
|
+
str = "Windows cannot verify this device's resources."
|
325
|
+
return str
|
326
|
+
when 14
|
327
|
+
str = "This device cannot work properly until you restart"
|
328
|
+
str << " your computer."
|
329
|
+
return str
|
330
|
+
when 15
|
331
|
+
str = "This device is not working properly because there is"
|
332
|
+
str << " probably a re-enumeration problem."
|
333
|
+
return str
|
334
|
+
when 16
|
335
|
+
str = "Windows cannot identify all the resources this device "
|
336
|
+
str << " uses."
|
337
|
+
return str
|
338
|
+
when 17
|
339
|
+
str = "This device is asking for an unknown resource type."
|
340
|
+
return str
|
341
|
+
when 18
|
342
|
+
str = "Reinstall the drivers for this device."
|
343
|
+
return str
|
344
|
+
when 19
|
345
|
+
str = "Failure using the VXD loader."
|
346
|
+
return str
|
347
|
+
when 20
|
348
|
+
str = "Your registry might be corrupted."
|
349
|
+
return str
|
350
|
+
when 21
|
351
|
+
str = "System failure: try changing the driver for this device."
|
352
|
+
str << " If that does not work, see your hardware documentation."
|
353
|
+
str << " Windows is removing this device."
|
354
|
+
return str
|
355
|
+
when 22
|
356
|
+
str = "This device is disabled."
|
357
|
+
return str
|
358
|
+
when 23
|
359
|
+
str = "System failure: try changing the driver for this device."
|
360
|
+
str << "If that doesn't work, see your hardware documentation."
|
361
|
+
return str
|
362
|
+
when 24
|
363
|
+
str = "This device is not present, not working properly, or"
|
364
|
+
str << " does not have all its drivers installed."
|
365
|
+
return str
|
366
|
+
when 25
|
367
|
+
str = "Windows is still setting up this device."
|
368
|
+
return str
|
369
|
+
when 26
|
370
|
+
str = "Windows is still setting up this device."
|
371
|
+
return str
|
372
|
+
when 27
|
373
|
+
str = "This device does not have valid log configuration."
|
374
|
+
return str
|
375
|
+
when 28
|
376
|
+
str = "The drivers for this device are not installed."
|
377
|
+
return str
|
378
|
+
when 29
|
379
|
+
str = "This device is disabled because the firmware of the"
|
380
|
+
str << " device did not give it the required resources."
|
381
|
+
return str
|
382
|
+
when 30
|
383
|
+
str = "This device is using an Interrupt Request (IRQ)"
|
384
|
+
str << " resource that another device is using."
|
385
|
+
return str
|
386
|
+
when 31
|
387
|
+
str = "This device is not working properly because Windows"
|
388
|
+
str << " cannot load the drivers required for this device"
|
389
|
+
return str
|
390
|
+
else
|
391
|
+
return nil
|
389
392
|
end
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
393
|
+
end
|
394
|
+
|
395
|
+
# Convert an cpu architecture number to a string
|
396
|
+
def self.get_cpu_arch(num)
|
397
|
+
case num
|
398
|
+
when 0
|
399
|
+
return "x86"
|
400
|
+
when 1
|
401
|
+
return "MIPS"
|
402
|
+
when 2
|
403
|
+
return "Alpha"
|
404
|
+
when 3
|
405
|
+
return "PowerPC"
|
406
|
+
when 6
|
407
|
+
return "IA64"
|
408
|
+
when 9
|
409
|
+
return "x64"
|
410
|
+
else
|
411
|
+
return nil
|
407
412
|
end
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
413
|
+
end
|
414
|
+
|
415
|
+
# convert an Availability number into a string
|
416
|
+
def self.get_availability(num)
|
417
|
+
case num
|
418
|
+
when 1
|
419
|
+
return "Other"
|
420
|
+
when 2
|
421
|
+
return "Unknown"
|
422
|
+
when 3
|
423
|
+
return "Running"
|
424
|
+
when 4
|
425
|
+
return "Warning"
|
426
|
+
when 5
|
427
|
+
return "In Test"
|
428
|
+
when 6
|
429
|
+
return "Not Applicable"
|
430
|
+
when 7
|
431
|
+
return "Power Off"
|
432
|
+
when 8
|
433
|
+
return "Off Line"
|
434
|
+
when 9
|
435
|
+
return "Off Duty"
|
436
|
+
when 10
|
437
|
+
return "Degraded"
|
438
|
+
when 11
|
439
|
+
return "Not Installed"
|
440
|
+
when 12
|
441
|
+
return "Install Error"
|
442
|
+
when 13
|
443
|
+
return "Power Save - Unknown"
|
444
|
+
when 14
|
445
|
+
return "Power Save - Low Power Mode"
|
446
|
+
when 15
|
447
|
+
return "Power Save - Standby"
|
448
|
+
when 16
|
449
|
+
return "Power Cycle"
|
450
|
+
when 17
|
451
|
+
return "Power Save - Warning"
|
452
|
+
when 18
|
453
|
+
return "Paused"
|
454
|
+
when 19
|
455
|
+
return "Not Ready"
|
456
|
+
when 20
|
457
|
+
return "Not Configured"
|
458
|
+
when 21
|
459
|
+
return "Quiesced"
|
460
|
+
else
|
461
|
+
return nil
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
# convert CpuStatus to a string form. Note that values 5 and 6 are
|
466
|
+
# skipped because they're reserved.
|
467
|
+
def self.get_status(num)
|
468
|
+
case num
|
469
|
+
when 0
|
470
|
+
return "Unknown"
|
471
|
+
when 1
|
472
|
+
return "Enabled"
|
473
|
+
when 2
|
474
|
+
return "Disabled by User via BIOS Setup"
|
475
|
+
when 3
|
476
|
+
return "Disabled By BIOS (POST Error)"
|
477
|
+
when 4
|
478
|
+
return "Idle"
|
479
|
+
when 7
|
480
|
+
return "Other"
|
481
|
+
else
|
482
|
+
return nil
|
457
483
|
end
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
484
|
+
end
|
485
|
+
|
486
|
+
# Convert a family number into the equivalent string
|
487
|
+
def self.get_family(num)
|
488
|
+
case num
|
489
|
+
when 1
|
490
|
+
return "Other"
|
491
|
+
when 2
|
492
|
+
return "Unknown"
|
493
|
+
when 3
|
494
|
+
return "8086"
|
495
|
+
when 4
|
496
|
+
return "80286"
|
497
|
+
when 5
|
498
|
+
return "80386"
|
499
|
+
when 6
|
500
|
+
return "80486"
|
501
|
+
when 7
|
502
|
+
return "8087"
|
503
|
+
when 8
|
504
|
+
return "80287"
|
505
|
+
when 9
|
506
|
+
return "80387"
|
507
|
+
when 10
|
508
|
+
return "80487"
|
509
|
+
when 11
|
510
|
+
return "Pentium?"
|
511
|
+
when 12
|
512
|
+
return "Pentium?"
|
513
|
+
when 13
|
514
|
+
return "Pentium?"
|
515
|
+
when 14
|
516
|
+
return "Pentium?"
|
517
|
+
when 15
|
518
|
+
return "Celeron?"
|
519
|
+
when 16
|
520
|
+
return "Pentium?"
|
521
|
+
when 17
|
522
|
+
return "Pentium?"
|
523
|
+
when 18
|
524
|
+
return "M1"
|
525
|
+
when 19
|
526
|
+
return "M2"
|
527
|
+
when 24
|
528
|
+
return "K5"
|
529
|
+
when 25
|
530
|
+
return "K6"
|
531
|
+
when 26
|
532
|
+
return "K6-2"
|
533
|
+
when 27
|
534
|
+
return "K6-3"
|
535
|
+
when 28
|
536
|
+
return "AMD"
|
537
|
+
when 29
|
538
|
+
return "AMD?"
|
539
|
+
when 30
|
540
|
+
return "AMD2900"
|
541
|
+
when 31
|
542
|
+
return "K6-2+"
|
543
|
+
when 32
|
544
|
+
return "Power"
|
545
|
+
when 33
|
546
|
+
return "Power"
|
547
|
+
when 34
|
548
|
+
return "Power"
|
549
|
+
when 35
|
550
|
+
return "Power"
|
551
|
+
when 36
|
552
|
+
return "Power"
|
553
|
+
when 37
|
554
|
+
return "Power"
|
555
|
+
when 38
|
556
|
+
return "Power"
|
557
|
+
when 39
|
558
|
+
return "Power"
|
559
|
+
when 48
|
560
|
+
return "Alpha"
|
561
|
+
when 49
|
562
|
+
return "Alpha"
|
563
|
+
when 50
|
564
|
+
return "Alpha"
|
565
|
+
when 51
|
566
|
+
return "Alpha"
|
567
|
+
when 52
|
568
|
+
return "Alpha"
|
569
|
+
when 53
|
570
|
+
return "Alpha"
|
571
|
+
when 54
|
572
|
+
return "Alpha"
|
573
|
+
when 55
|
574
|
+
return "Alpha"
|
575
|
+
when 64
|
576
|
+
return "MIPS"
|
577
|
+
when 65
|
578
|
+
return "MIPS"
|
579
|
+
when 66
|
580
|
+
return "MIPS"
|
581
|
+
when 67
|
582
|
+
return "MIPS"
|
583
|
+
when 68
|
584
|
+
return "MIPS"
|
585
|
+
when 69
|
586
|
+
return "MIPS"
|
587
|
+
when 80
|
588
|
+
return "SPARC"
|
589
|
+
when 81
|
590
|
+
return "SuperSPARC"
|
591
|
+
when 82
|
592
|
+
return "microSPARC"
|
593
|
+
when 83
|
594
|
+
return "microSPARC"
|
595
|
+
when 84
|
596
|
+
return "UltraSPARC"
|
597
|
+
when 85
|
598
|
+
return "UltraSPARC"
|
599
|
+
when 86
|
600
|
+
return "UltraSPARC"
|
601
|
+
when 87
|
602
|
+
return "UltraSPARC"
|
603
|
+
when 88
|
604
|
+
return "UltraSPARC"
|
605
|
+
when 96
|
606
|
+
return "68040"
|
607
|
+
when 97
|
608
|
+
return "68xxx"
|
609
|
+
when 98
|
610
|
+
return "68000"
|
611
|
+
when 99
|
612
|
+
return "68010"
|
613
|
+
when 100
|
614
|
+
return "68020"
|
615
|
+
when 101
|
616
|
+
return "68030"
|
617
|
+
when 112
|
618
|
+
return "Hobbit"
|
619
|
+
when 120
|
620
|
+
return "Crusoe?"
|
621
|
+
when 121
|
622
|
+
return "Crusoe?"
|
623
|
+
when 128
|
624
|
+
return "Weitek"
|
625
|
+
when 130
|
626
|
+
return "Itanium?"
|
627
|
+
when 144
|
628
|
+
return "PA-RISC"
|
629
|
+
when 145
|
630
|
+
return "PA-RISC"
|
631
|
+
when 146
|
632
|
+
return "PA-RISC"
|
633
|
+
when 147
|
634
|
+
return "PA-RISC"
|
635
|
+
when 148
|
636
|
+
return "PA-RISC"
|
637
|
+
when 149
|
638
|
+
return "PA-RISC"
|
639
|
+
when 150
|
640
|
+
return "PA-RISC"
|
641
|
+
when 160
|
642
|
+
return "V30"
|
643
|
+
when 176
|
644
|
+
return "Pentium?"
|
645
|
+
when 177
|
646
|
+
return "Pentium?"
|
647
|
+
when 178
|
648
|
+
return "Pentium?"
|
649
|
+
when 179
|
650
|
+
return "Intel?"
|
651
|
+
when 180
|
652
|
+
return "AS400"
|
653
|
+
when 181
|
654
|
+
return "Intel?"
|
655
|
+
when 182
|
656
|
+
return "AMD"
|
657
|
+
when 183
|
658
|
+
return "AMD"
|
659
|
+
when 184
|
660
|
+
return "Intel?"
|
661
|
+
when 185
|
662
|
+
return "AMD"
|
663
|
+
when 190
|
664
|
+
return "K7"
|
665
|
+
when 200
|
666
|
+
return "IBM390"
|
667
|
+
when 201
|
668
|
+
return "G4"
|
669
|
+
when 202
|
670
|
+
return "G5"
|
671
|
+
when 250
|
672
|
+
return "i860"
|
673
|
+
when 251
|
674
|
+
return "i960"
|
675
|
+
when 260
|
676
|
+
return "SH-3"
|
677
|
+
when 261
|
678
|
+
return "SH-4"
|
679
|
+
when 280
|
680
|
+
return "ARM"
|
681
|
+
when 281
|
682
|
+
return "StrongARM"
|
683
|
+
when 300
|
684
|
+
return "6x86"
|
685
|
+
when 301
|
686
|
+
return "MediaGX"
|
687
|
+
when 302
|
688
|
+
return "MII"
|
689
|
+
when 320
|
690
|
+
return "WinChip"
|
691
|
+
when 350
|
692
|
+
return "DSP"
|
693
|
+
when 500
|
694
|
+
return "Video"
|
695
|
+
else
|
696
|
+
return nil
|
478
697
|
end
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
return "80487"
|
503
|
-
when 11
|
504
|
-
return "Pentium?"
|
505
|
-
when 12
|
506
|
-
return "Pentium?"
|
507
|
-
when 13
|
508
|
-
return "Pentium?"
|
509
|
-
when 14
|
510
|
-
return "Pentium?"
|
511
|
-
when 15
|
512
|
-
return "Celeron?"
|
513
|
-
when 16
|
514
|
-
return "Pentium?"
|
515
|
-
when 17
|
516
|
-
return "Pentium?"
|
517
|
-
when 18
|
518
|
-
return "M1"
|
519
|
-
when 19
|
520
|
-
return "M2"
|
521
|
-
when 24
|
522
|
-
return "K5"
|
523
|
-
when 25
|
524
|
-
return "K6"
|
525
|
-
when 26
|
526
|
-
return "K6-2"
|
527
|
-
when 27
|
528
|
-
return "K6-3"
|
529
|
-
when 28
|
530
|
-
return "AMD"
|
531
|
-
when 29
|
532
|
-
return "AMD?"
|
533
|
-
when 30
|
534
|
-
return "AMD2900"
|
535
|
-
when 31
|
536
|
-
return "K6-2+"
|
537
|
-
when 32
|
538
|
-
return "Power"
|
539
|
-
when 33
|
540
|
-
return "Power"
|
541
|
-
when 34
|
542
|
-
return "Power"
|
543
|
-
when 35
|
544
|
-
return "Power"
|
545
|
-
when 36
|
546
|
-
return "Power"
|
547
|
-
when 37
|
548
|
-
return "Power"
|
549
|
-
when 38
|
550
|
-
return "Power"
|
551
|
-
when 39
|
552
|
-
return "Power"
|
553
|
-
when 48
|
554
|
-
return "Alpha"
|
555
|
-
when 49
|
556
|
-
return "Alpha"
|
557
|
-
when 50
|
558
|
-
return "Alpha"
|
559
|
-
when 51
|
560
|
-
return "Alpha"
|
561
|
-
when 52
|
562
|
-
return "Alpha"
|
563
|
-
when 53
|
564
|
-
return "Alpha"
|
565
|
-
when 54
|
566
|
-
return "Alpha"
|
567
|
-
when 55
|
568
|
-
return "Alpha"
|
569
|
-
when 64
|
570
|
-
return "MIPS"
|
571
|
-
when 65
|
572
|
-
return "MIPS"
|
573
|
-
when 66
|
574
|
-
return "MIPS"
|
575
|
-
when 67
|
576
|
-
return "MIPS"
|
577
|
-
when 68
|
578
|
-
return "MIPS"
|
579
|
-
when 69
|
580
|
-
return "MIPS"
|
581
|
-
when 80
|
582
|
-
return "SPARC"
|
583
|
-
when 81
|
584
|
-
return "SuperSPARC"
|
585
|
-
when 82
|
586
|
-
return "microSPARC"
|
587
|
-
when 83
|
588
|
-
return "microSPARC"
|
589
|
-
when 84
|
590
|
-
return "UltraSPARC"
|
591
|
-
when 85
|
592
|
-
return "UltraSPARC"
|
593
|
-
when 86
|
594
|
-
return "UltraSPARC"
|
595
|
-
when 87
|
596
|
-
return "UltraSPARC"
|
597
|
-
when 88
|
598
|
-
return "UltraSPARC"
|
599
|
-
when 96
|
600
|
-
return "68040"
|
601
|
-
when 97
|
602
|
-
return "68xxx"
|
603
|
-
when 98
|
604
|
-
return "68000"
|
605
|
-
when 99
|
606
|
-
return "68010"
|
607
|
-
when 100
|
608
|
-
return "68020"
|
609
|
-
when 101
|
610
|
-
return "68030"
|
611
|
-
when 112
|
612
|
-
return "Hobbit"
|
613
|
-
when 120
|
614
|
-
return "Crusoe?"
|
615
|
-
when 121
|
616
|
-
return "Crusoe?"
|
617
|
-
when 128
|
618
|
-
return "Weitek"
|
619
|
-
when 130
|
620
|
-
return "Itanium?"
|
621
|
-
when 144
|
622
|
-
return "PA-RISC"
|
623
|
-
when 145
|
624
|
-
return "PA-RISC"
|
625
|
-
when 146
|
626
|
-
return "PA-RISC"
|
627
|
-
when 147
|
628
|
-
return "PA-RISC"
|
629
|
-
when 148
|
630
|
-
return "PA-RISC"
|
631
|
-
when 149
|
632
|
-
return "PA-RISC"
|
633
|
-
when 150
|
634
|
-
return "PA-RISC"
|
635
|
-
when 160
|
636
|
-
return "V30"
|
637
|
-
when 176
|
638
|
-
return "Pentium?"
|
639
|
-
when 177
|
640
|
-
return "Pentium?"
|
641
|
-
when 178
|
642
|
-
return "Pentium?"
|
643
|
-
when 179
|
644
|
-
return "Intel?"
|
645
|
-
when 180
|
646
|
-
return "AS400"
|
647
|
-
when 181
|
648
|
-
return "Intel?"
|
649
|
-
when 182
|
650
|
-
return "AMD"
|
651
|
-
when 183
|
652
|
-
return "AMD"
|
653
|
-
when 184
|
654
|
-
return "Intel?"
|
655
|
-
when 185
|
656
|
-
return "AMD"
|
657
|
-
when 190
|
658
|
-
return "K7"
|
659
|
-
when 200
|
660
|
-
return "IBM390"
|
661
|
-
when 201
|
662
|
-
return "G4"
|
663
|
-
when 202
|
664
|
-
return "G5"
|
665
|
-
when 250
|
666
|
-
return "i860"
|
667
|
-
when 251
|
668
|
-
return "i960"
|
669
|
-
when 260
|
670
|
-
return "SH-3"
|
671
|
-
when 261
|
672
|
-
return "SH-4"
|
673
|
-
when 280
|
674
|
-
return "ARM"
|
675
|
-
when 281
|
676
|
-
return "StrongARM"
|
677
|
-
when 300
|
678
|
-
return "6x86"
|
679
|
-
when 301
|
680
|
-
return "MediaGX"
|
681
|
-
when 302
|
682
|
-
return "MII"
|
683
|
-
when 320
|
684
|
-
return "WinChip"
|
685
|
-
when 350
|
686
|
-
return "DSP"
|
687
|
-
when 500
|
688
|
-
return "Video"
|
689
|
-
else
|
690
|
-
return nil
|
691
|
-
end
|
698
|
+
end
|
699
|
+
|
700
|
+
# Convert power management capabilities number to its equivalent string
|
701
|
+
def self.get_pmc(num)
|
702
|
+
case num
|
703
|
+
when 0
|
704
|
+
return "Unknown"
|
705
|
+
when 1
|
706
|
+
return "Not Supported"
|
707
|
+
when 2
|
708
|
+
return "Disabled"
|
709
|
+
when 3
|
710
|
+
return "Enabled"
|
711
|
+
when 4
|
712
|
+
return "Power Saving Modes Entered Automatically"
|
713
|
+
when 5
|
714
|
+
return "Power State Settable"
|
715
|
+
when 6
|
716
|
+
return "Power Cycling Supported"
|
717
|
+
when 7
|
718
|
+
return "Timed Power On Supported"
|
719
|
+
else
|
720
|
+
return nil
|
692
721
|
end
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
return "Timed Power On Supported"
|
713
|
-
else
|
714
|
-
return nil
|
715
|
-
end
|
722
|
+
end
|
723
|
+
|
724
|
+
# Convert a processor type into its equivalent string
|
725
|
+
def self.get_processor_type(num)
|
726
|
+
case num
|
727
|
+
when 1
|
728
|
+
return "Other"
|
729
|
+
when 2
|
730
|
+
return "Unknown"
|
731
|
+
when 3
|
732
|
+
return "Central Processor"
|
733
|
+
when 4
|
734
|
+
return "Math Processor"
|
735
|
+
when 5
|
736
|
+
return "DSP Processor"
|
737
|
+
when 6
|
738
|
+
return "Video Processor"
|
739
|
+
else
|
740
|
+
return nil
|
716
741
|
end
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
742
|
+
end
|
743
|
+
|
744
|
+
# Convert an upgrade method into its equivalent string
|
745
|
+
def self.get_upgrade_method(num)
|
746
|
+
case num
|
747
|
+
when 1
|
748
|
+
return "Other"
|
749
|
+
when 2
|
750
|
+
return "Unknown"
|
751
|
+
when 3
|
752
|
+
return "Daughter Board"
|
753
|
+
when 4
|
754
|
+
return "ZIF Socket"
|
755
|
+
when 5
|
756
|
+
return "Replacement/Piggy Back"
|
757
|
+
when 6
|
758
|
+
return "None"
|
759
|
+
when 7
|
760
|
+
return "LIF Socket"
|
761
|
+
when 8
|
762
|
+
return "Slot 1"
|
763
|
+
when 9
|
764
|
+
return "Slot 2"
|
765
|
+
when 10
|
766
|
+
return "370 Pin Socket"
|
767
|
+
when 11
|
768
|
+
return "Slot A"
|
769
|
+
when 12
|
770
|
+
return "Slot M"
|
771
|
+
else
|
772
|
+
return nil
|
736
773
|
end
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
return "Replacement/Piggy Back"
|
751
|
-
when 6
|
752
|
-
return "None"
|
753
|
-
when 7
|
754
|
-
return "LIF Socket"
|
755
|
-
when 8
|
756
|
-
return "Slot 1"
|
757
|
-
when 9
|
758
|
-
return "Slot 2"
|
759
|
-
when 10
|
760
|
-
return "370 Pin Socket"
|
761
|
-
when 11
|
762
|
-
return "Slot A"
|
763
|
-
when 12
|
764
|
-
return "Slot M"
|
765
|
-
else
|
766
|
-
return nil
|
767
|
-
end
|
768
|
-
end
|
769
|
-
|
770
|
-
# Convert return values to voltage cap values (floats)
|
771
|
-
def self.get_voltage_caps(num)
|
772
|
-
case num
|
773
|
-
when 1
|
774
|
-
return 5.0
|
775
|
-
when 2
|
776
|
-
return 3.3
|
777
|
-
when 4
|
778
|
-
return 2.9
|
779
|
-
else
|
780
|
-
return nil
|
781
|
-
end
|
774
|
+
end
|
775
|
+
|
776
|
+
# Convert return values to voltage cap values (floats)
|
777
|
+
def self.get_voltage_caps(num)
|
778
|
+
case num
|
779
|
+
when 1
|
780
|
+
return 5.0
|
781
|
+
when 2
|
782
|
+
return 3.3
|
783
|
+
when 4
|
784
|
+
return 2.9
|
785
|
+
else
|
786
|
+
return nil
|
782
787
|
end
|
783
|
-
|
788
|
+
end
|
789
|
+
end
|
784
790
|
end
|