sys-cpu 0.8.3 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +50 -25
- data/Gemfile +7 -0
- data/{MANIFEST.rdoc → MANIFEST.md} +12 -9
- data/{README.rdoc → README.md} +21 -21
- data/Rakefile +6 -8
- data/lib/sys/cpu.rb +3 -1
- data/lib/sys/darwin/sys/cpu.rb +167 -0
- data/lib/sys/linux/sys/cpu.rb +45 -15
- data/lib/sys/unix/sys/cpu.rb +41 -73
- data/lib/sys/windows/sys/cpu.rb +289 -271
- data/spec/spec_helper.rb +9 -0
- data/spec/sys_cpu_bsd_spec.rb +94 -0
- data/spec/sys_cpu_hpux_spec.rb +50 -0
- data/spec/sys_cpu_linux_spec.rb +53 -0
- data/spec/sys_cpu_spec.rb +18 -0
- data/spec/sys_cpu_sunos_spec.rb +80 -0
- data/spec/sys_cpu_windows_spec.rb +61 -0
- data/sys-cpu.gemspec +5 -5
- metadata +49 -56
- metadata.gz.sig +0 -0
- data/test/test_sys_cpu.rb +0 -23
- data/test/test_sys_cpu_bsd.rb +0 -97
- data/test/test_sys_cpu_hpux.rb +0 -49
- data/test/test_sys_cpu_linux.rb +0 -31
- data/test/test_sys_cpu_sunos.rb +0 -81
- data/test/test_sys_cpu_version.rb +0 -19
- data/test/test_sys_cpu_windows.rb +0 -72
data/lib/sys/linux/sys/cpu.rb
CHANGED
@@ -5,20 +5,20 @@ module Sys
|
|
5
5
|
|
6
6
|
# :stopdoc:
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
cpu_file = "/proc/cpuinfo"
|
8
|
+
cpu_file = '/proc/cpuinfo'
|
11
9
|
cpu_hash = {}
|
12
10
|
CPU_ARRAY = []
|
13
11
|
|
12
|
+
private_constant :CPU_ARRAY
|
13
|
+
|
14
14
|
# Parse the info out of the /proc/cpuinfo file
|
15
15
|
IO.foreach(cpu_file){ |line|
|
16
16
|
line.strip!
|
17
17
|
next if line.empty?
|
18
18
|
|
19
|
-
key, val = line.split(
|
19
|
+
key, val = line.split(':')
|
20
20
|
key.strip!
|
21
|
-
key.gsub!(/\s+/,
|
21
|
+
key.gsub!(/\s+/,'_')
|
22
22
|
key.downcase!
|
23
23
|
val.strip! if val
|
24
24
|
|
@@ -39,15 +39,15 @@ module Sys
|
|
39
39
|
|
40
40
|
CPU_ARRAY.push(cpu_hash)
|
41
41
|
|
42
|
-
public
|
43
|
-
|
44
42
|
# :startdoc:
|
45
43
|
|
46
44
|
class CPU
|
47
45
|
|
48
46
|
# :stopdoc:
|
49
47
|
|
50
|
-
CPUStruct = Struct.new(
|
48
|
+
CPUStruct = Struct.new('CPUStruct', *CPU_ARRAY.first.keys)
|
49
|
+
|
50
|
+
private_constant :CPUStruct
|
51
51
|
|
52
52
|
# :startdoc:
|
53
53
|
|
@@ -70,26 +70,56 @@ module Sys
|
|
70
70
|
array unless block_given?
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
# Return the total number of logical CPU on the system.
|
74
|
+
#
|
75
|
+
def self.num_cpu
|
76
|
+
CPU_ARRAY.size
|
77
|
+
end
|
78
|
+
|
79
|
+
# Return the architecture of the CPU.
|
80
|
+
#
|
81
|
+
def self.architecture
|
82
|
+
case CPU_ARRAY.first['cpu_family']
|
83
|
+
when '3'
|
84
|
+
'x86'
|
85
|
+
when '6'
|
86
|
+
'x86_64'
|
87
|
+
else
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns a string indicating the CPU model.
|
93
|
+
#
|
94
|
+
def self.model
|
95
|
+
CPU_ARRAY.first['model_name']
|
96
|
+
end
|
97
|
+
|
98
|
+
# Returns an integer indicating the speed of the CPU.
|
99
|
+
#
|
100
|
+
def self.freq
|
101
|
+
CPU_ARRAY.first['cpu_mhz'].to_f.round
|
102
|
+
end
|
74
103
|
|
75
104
|
# Create singleton methods for each of the attributes.
|
76
105
|
#
|
77
106
|
def self.method_missing(id, arg=0)
|
107
|
+
raise NoMethodError, "'#{id}'" unless CPU_ARRAY[arg].has_key?(id.to_s)
|
78
108
|
rv = CPU_ARRAY[arg][id.to_s]
|
79
109
|
if rv.nil?
|
80
|
-
id = id.to_s +
|
110
|
+
id = id.to_s + '?'
|
81
111
|
rv = CPU_ARRAY[arg][id]
|
82
112
|
end
|
83
113
|
rv
|
84
114
|
end
|
85
115
|
|
86
|
-
|
116
|
+
private_class_method :method_missing
|
87
117
|
|
88
118
|
# Returns a 3 element Array corresponding to the 1, 5 and 15 minute
|
89
119
|
# load average for the system.
|
90
120
|
#
|
91
121
|
def self.load_avg
|
92
|
-
load_avg_file =
|
122
|
+
load_avg_file = '/proc/loadavg'
|
93
123
|
IO.readlines(load_avg_file).first.split[0..2].map{ |e| e.to_f }
|
94
124
|
end
|
95
125
|
|
@@ -110,7 +140,7 @@ module Sys
|
|
110
140
|
# Note that older kernels may not necessarily include some of these fields.
|
111
141
|
#
|
112
142
|
def self.cpu_stats
|
113
|
-
cpu_stat_file =
|
143
|
+
cpu_stat_file = '/proc/stat'
|
114
144
|
hash = {} # Hash needed for multi-cpu systems
|
115
145
|
|
116
146
|
lines = IO.readlines(cpu_stat_file)
|
@@ -121,11 +151,11 @@ module Sys
|
|
121
151
|
|
122
152
|
# Some machines list a 'cpu' and a 'cpu0'. In this case only
|
123
153
|
# return values for the numbered cpu entry.
|
124
|
-
if lines[i].split[0] ==
|
154
|
+
if lines[i].split[0] == 'cpu' && lines[i+1].split[0] =~ /cpu\d/
|
125
155
|
next
|
126
156
|
end
|
127
157
|
|
128
|
-
vals = array[1..-1].map{ |e| e
|
158
|
+
vals = array[1..-1].map{ |e| e.to_i / 100 } # 100 jiffies/sec.
|
129
159
|
hash[array[0]] = vals
|
130
160
|
}
|
131
161
|
|
data/lib/sys/unix/sys/cpu.rb
CHANGED
@@ -95,7 +95,7 @@ module Sys
|
|
95
95
|
buf = 0.chr * 257
|
96
96
|
|
97
97
|
if sysinfo(SI_ARCHITECTURE, buf, buf.size) < 0
|
98
|
-
raise Error,
|
98
|
+
raise Error, 'sysinfo function failed'
|
99
99
|
end
|
100
100
|
|
101
101
|
buf.strip
|
@@ -105,14 +105,8 @@ module Sys
|
|
105
105
|
|
106
106
|
size.write_int(optr.size)
|
107
107
|
|
108
|
-
if
|
109
|
-
|
110
|
-
else
|
111
|
-
name = 'hw.machine_arch'
|
112
|
-
end
|
113
|
-
|
114
|
-
if sysctlbyname(name, optr, size, nil, 0) < 0
|
115
|
-
raise Error, "sysctlbyname function failed"
|
108
|
+
if sysctlbyname('hw.machine_arch', optr, size, nil, 0) < 0
|
109
|
+
raise Error, 'sysctlbyname function failed'
|
116
110
|
end
|
117
111
|
|
118
112
|
optr.read_string
|
@@ -125,7 +119,7 @@ module Sys
|
|
125
119
|
size.write_int(buf.size)
|
126
120
|
|
127
121
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
128
|
-
raise Error,
|
122
|
+
raise Error, 'sysctl function failed'
|
129
123
|
end
|
130
124
|
|
131
125
|
buf.strip
|
@@ -144,7 +138,7 @@ module Sys
|
|
144
138
|
size.write_long(optr.size)
|
145
139
|
|
146
140
|
if sysctlbyname('hw.ncpu', optr, size, nil, 0) < 0
|
147
|
-
raise Error,
|
141
|
+
raise Error, 'sysctlbyname failed'
|
148
142
|
end
|
149
143
|
|
150
144
|
optr.read_long
|
@@ -152,7 +146,7 @@ module Sys
|
|
152
146
|
num = sysconf(SC_NPROCESSORS_ONLN)
|
153
147
|
|
154
148
|
if num < 0
|
155
|
-
raise Error,
|
149
|
+
raise Error, 'sysconf function failed'
|
156
150
|
end
|
157
151
|
|
158
152
|
num
|
@@ -165,10 +159,10 @@ module Sys
|
|
165
159
|
size.write_int(buf.size)
|
166
160
|
|
167
161
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
168
|
-
raise Error,
|
162
|
+
raise Error, 'sysctl function failed'
|
169
163
|
end
|
170
164
|
|
171
|
-
buf.strip.unpack(
|
165
|
+
buf.strip.unpack('C').first
|
172
166
|
end
|
173
167
|
end
|
174
168
|
|
@@ -186,7 +180,7 @@ module Sys
|
|
186
180
|
size.write_int(buf.size)
|
187
181
|
|
188
182
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
189
|
-
raise Error,
|
183
|
+
raise Error, 'sysctl function failed'
|
190
184
|
end
|
191
185
|
|
192
186
|
buf.strip
|
@@ -194,7 +188,7 @@ module Sys
|
|
194
188
|
buf = 0.chr * 257
|
195
189
|
|
196
190
|
if sysinfo(SI_MACHINE, buf, buf.size) < 0
|
197
|
-
raise Error,
|
191
|
+
raise Error, 'sysinfo function failed'
|
198
192
|
end
|
199
193
|
|
200
194
|
buf.strip
|
@@ -204,52 +198,30 @@ module Sys
|
|
204
198
|
# Returns a string indicating the cpu model.
|
205
199
|
#
|
206
200
|
def self.model
|
207
|
-
if
|
208
|
-
|
209
|
-
|
201
|
+
if respond_to?(:sysctl, true)
|
202
|
+
buf = 0.chr * 64
|
203
|
+
mib = FFI::MemoryPointer.new(:int, 2)
|
204
|
+
size = FFI::MemoryPointer.new(:long, 1)
|
210
205
|
|
211
|
-
|
206
|
+
mib.write_array_of_int([CTL_HW, HW_MODEL])
|
207
|
+
size.write_int(buf.size)
|
212
208
|
|
213
|
-
if
|
214
|
-
raise
|
209
|
+
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
210
|
+
raise Error, 'sysctl function failed'
|
215
211
|
end
|
216
212
|
|
217
|
-
|
218
|
-
when CPU_TYPE_X86, CPU_TYPE_X86_64
|
219
|
-
"Intel"
|
220
|
-
when CPU_TYPE_SPARC
|
221
|
-
"Sparc"
|
222
|
-
when CPU_TYPE_POWERPC, CPU_TYPE_POWERPC64
|
223
|
-
"PowerPC"
|
224
|
-
else
|
225
|
-
"Unknown"
|
226
|
-
end
|
213
|
+
buf.strip
|
227
214
|
else
|
228
|
-
|
229
|
-
buf = 0.chr * 64
|
230
|
-
mib = FFI::MemoryPointer.new(:int, 2)
|
231
|
-
size = FFI::MemoryPointer.new(:long, 1)
|
232
|
-
|
233
|
-
mib.write_array_of_int([CTL_HW, HW_MODEL])
|
234
|
-
size.write_int(buf.size)
|
235
|
-
|
236
|
-
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
237
|
-
raise Error, "sysctl function failed"
|
238
|
-
end
|
239
|
-
|
240
|
-
buf.strip
|
241
|
-
else
|
242
|
-
pinfo = ProcInfo.new
|
215
|
+
pinfo = ProcInfo.new
|
243
216
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
end
|
217
|
+
# Some systems start at 0, some at 1
|
218
|
+
if processor_info(0, pinfo) < 0
|
219
|
+
if processor_info(1, pinfo) < 0
|
220
|
+
raise Error, 'process_info function failed'
|
249
221
|
end
|
250
|
-
|
251
|
-
pinfo[:pi_processor_type].to_s
|
252
222
|
end
|
223
|
+
|
224
|
+
pinfo[:pi_processor_type].to_s
|
253
225
|
end
|
254
226
|
end
|
255
227
|
|
@@ -269,14 +241,10 @@ module Sys
|
|
269
241
|
end
|
270
242
|
|
271
243
|
if sysctlbyname(name, optr, size, nil, 0) < 0
|
272
|
-
raise Error,
|
244
|
+
raise Error, 'sysctlbyname failed'
|
273
245
|
end
|
274
246
|
|
275
|
-
|
276
|
-
optr.read_long / 1000000
|
277
|
-
else
|
278
|
-
optr.read_long
|
279
|
-
end
|
247
|
+
optr.read_long
|
280
248
|
elsif respond_to?(:sysctl, true)
|
281
249
|
buf = 0.chr * 16
|
282
250
|
mib = FFI::MemoryPointer.new(:int, 2)
|
@@ -286,17 +254,17 @@ module Sys
|
|
286
254
|
size.write_int(buf.size)
|
287
255
|
|
288
256
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
289
|
-
raise Error,
|
257
|
+
raise Error, 'sysctl function failed'
|
290
258
|
end
|
291
259
|
|
292
|
-
buf.unpack(
|
260
|
+
buf.unpack('I*').first / 1000000
|
293
261
|
else
|
294
262
|
pinfo = ProcInfo.new
|
295
263
|
|
296
264
|
# Some systems start at 0, some at 1
|
297
265
|
if processor_info(0, pinfo) < 0
|
298
266
|
if processor_info(1, pinfo) < 0
|
299
|
-
raise Error,
|
267
|
+
raise Error, 'process_info function failed'
|
300
268
|
end
|
301
269
|
end
|
302
270
|
|
@@ -312,7 +280,7 @@ module Sys
|
|
312
280
|
loadavg = FFI::MemoryPointer.new(:double, 3)
|
313
281
|
|
314
282
|
if getloadavg(loadavg, loadavg.size) < 0
|
315
|
-
raise Error,
|
283
|
+
raise Error, 'getloadavg function failed'
|
316
284
|
end
|
317
285
|
|
318
286
|
loadavg.get_array_of_double(0, 3)
|
@@ -330,7 +298,7 @@ module Sys
|
|
330
298
|
|
331
299
|
if processor_info(0, pinfo) < 0
|
332
300
|
if processor_info(1, pinfo) < 0
|
333
|
-
raise Error,
|
301
|
+
raise Error, 'process_info function failed'
|
334
302
|
end
|
335
303
|
end
|
336
304
|
|
@@ -348,24 +316,24 @@ module Sys
|
|
348
316
|
pinfo = ProcInfo.new
|
349
317
|
|
350
318
|
if processor_info(num, pinfo) < 0
|
351
|
-
raise Error,
|
319
|
+
raise Error, 'process_info function failed'
|
352
320
|
end
|
353
321
|
|
354
322
|
case pinfo[:pi_state].to_i
|
355
323
|
when P_ONLINE
|
356
|
-
|
324
|
+
'online'
|
357
325
|
when P_OFFLINE
|
358
|
-
|
326
|
+
'offline'
|
359
327
|
when P_POWEROFF
|
360
|
-
|
328
|
+
'poweroff'
|
361
329
|
when P_FAULTED
|
362
|
-
|
330
|
+
'faulted'
|
363
331
|
when P_NOINTR
|
364
|
-
|
332
|
+
'nointr'
|
365
333
|
when P_SPARE
|
366
|
-
|
334
|
+
'spare'
|
367
335
|
else
|
368
|
-
|
336
|
+
'unknown'
|
369
337
|
end
|
370
338
|
end
|
371
339
|
end
|
data/lib/sys/windows/sys/cpu.rb
CHANGED
@@ -17,10 +17,10 @@ module Sys
|
|
17
17
|
# Error raised if any of the Sys::CPU methods fail.
|
18
18
|
class Error < StandardError; end
|
19
19
|
|
20
|
-
private
|
21
|
-
|
22
20
|
# Base connect string
|
23
|
-
BASE_CS =
|
21
|
+
BASE_CS = 'winmgmts:{impersonationLevel=impersonate}' # :nodoc:
|
22
|
+
|
23
|
+
private_constant :BASE_CS
|
24
24
|
|
25
25
|
# Fields used in the CPUStruct
|
26
26
|
fields = %w[
|
@@ -71,9 +71,9 @@ module Sys
|
|
71
71
|
]
|
72
72
|
|
73
73
|
# The struct returned by the CPU.processors method
|
74
|
-
CPUStruct = Struct.new(
|
74
|
+
CPUStruct = Struct.new('CPUStruct', *fields) # :nodoc:
|
75
75
|
|
76
|
-
|
76
|
+
private_constant :CPUStruct
|
77
77
|
|
78
78
|
# Returns the +host+ CPU's architecture, or nil if it cannot be
|
79
79
|
# determined.
|
@@ -85,7 +85,7 @@ module Sys
|
|
85
85
|
rescue WIN32OLERuntimeError => e
|
86
86
|
raise Error, e
|
87
87
|
else
|
88
|
-
|
88
|
+
get_cpu_arch(wmi.Architecture)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -101,7 +101,7 @@ module Sys
|
|
101
101
|
rescue WIN32OLERuntimeError => e
|
102
102
|
raise Error, e
|
103
103
|
else
|
104
|
-
|
104
|
+
wmi.CurrentClockSpeed
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -120,7 +120,7 @@ module Sys
|
|
120
120
|
rescue WIN32OLERuntimeError => e
|
121
121
|
raise Error, e
|
122
122
|
else
|
123
|
-
|
123
|
+
wmi.LoadPercentage
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -133,7 +133,7 @@ module Sys
|
|
133
133
|
rescue WIN32OLERuntimeError => e
|
134
134
|
raise Error, e
|
135
135
|
else
|
136
|
-
|
136
|
+
wmi.Name
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -148,7 +148,7 @@ module Sys
|
|
148
148
|
rescue WIN32OLERuntimeError => e
|
149
149
|
raise Error, e
|
150
150
|
else
|
151
|
-
|
151
|
+
wmi.NumberOfProcessors
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -208,13 +208,13 @@ module Sys
|
|
208
208
|
rescue WIN32OLERuntimeError => e
|
209
209
|
raise Error, e
|
210
210
|
else
|
211
|
-
wmi.InstancesOf(
|
211
|
+
wmi.InstancesOf('Win32_Processor').each{ |cpu|
|
212
212
|
yield CPUStruct.new(
|
213
213
|
cpu.AddressWidth,
|
214
|
-
|
215
|
-
|
214
|
+
get_cpu_arch(cpu.Architecture),
|
215
|
+
get_availability(cpu.Availability),
|
216
216
|
cpu.Caption,
|
217
|
-
|
217
|
+
get_cmec(cpu.ConfigManagerErrorCode),
|
218
218
|
cpu.ConfigManagerUserConfig,
|
219
219
|
get_status(cpu.CpuStatus),
|
220
220
|
cpu.CreationClassName,
|
@@ -226,7 +226,7 @@ module Sys
|
|
226
226
|
cpu.ErrorCleared,
|
227
227
|
cpu.ErrorDescription,
|
228
228
|
cpu.ExtClock,
|
229
|
-
|
229
|
+
get_family(cpu.Family),
|
230
230
|
cpu.InstallDate,
|
231
231
|
cpu.L2CacheSize,
|
232
232
|
cpu.L2CacheSpeed,
|
@@ -268,7 +268,7 @@ module Sys
|
|
268
268
|
rescue WIN32OLERuntimeError => e
|
269
269
|
raise Error, e
|
270
270
|
else
|
271
|
-
|
271
|
+
wmi.Manufacturer
|
272
272
|
end
|
273
273
|
end
|
274
274
|
|
@@ -278,519 +278,537 @@ module Sys
|
|
278
278
|
# Note that this value returns nil on my system.
|
279
279
|
#
|
280
280
|
def self.get_cmec(num)
|
281
|
-
case
|
281
|
+
case num
|
282
282
|
when 0
|
283
|
-
str =
|
284
|
-
|
283
|
+
str = 'The device is working properly.'
|
284
|
+
str
|
285
285
|
when 1
|
286
|
-
str =
|
287
|
-
|
286
|
+
str = 'The device is not configured correctly.'
|
287
|
+
str
|
288
288
|
when 2
|
289
|
-
str =
|
290
|
-
|
289
|
+
str = 'Windows cannot load the driver for the device.'
|
290
|
+
str
|
291
291
|
when 3
|
292
|
-
str =
|
293
|
-
str <<
|
294
|
-
str <<
|
295
|
-
|
292
|
+
str = 'The driver for the device might be corrupted, or the'
|
293
|
+
str << ' system may be running low on memory or other'
|
294
|
+
str << ' resources.'
|
295
|
+
str
|
296
296
|
when 4
|
297
|
-
str =
|
298
|
-
str <<
|
299
|
-
|
297
|
+
str = 'The device is not working properly. One of the drivers'
|
298
|
+
str << ' or the registry might be corrupted.'
|
299
|
+
str
|
300
300
|
when 5
|
301
|
-
str =
|
302
|
-
str <<
|
303
|
-
|
301
|
+
str = 'The driver for this device needs a resource that'
|
302
|
+
str << ' Windows cannot manage.'
|
303
|
+
str
|
304
304
|
when 6
|
305
|
-
str =
|
306
|
-
str <<
|
307
|
-
|
305
|
+
str = 'The boot configuration for this device conflicts with'
|
306
|
+
str << ' other devices.'
|
307
|
+
str
|
308
308
|
when 7
|
309
|
-
str =
|
310
|
-
|
309
|
+
str = 'Cannot filter.'
|
310
|
+
str
|
311
311
|
when 8
|
312
|
-
str =
|
313
|
-
|
312
|
+
str = 'The driver loader for the device is missing.'
|
313
|
+
str
|
314
314
|
when 9
|
315
|
-
str =
|
316
|
-
str <<
|
317
|
-
str <<
|
318
|
-
|
315
|
+
str = 'This device is not working properly because the'
|
316
|
+
str << ' controlling firmware is reporting the resources'
|
317
|
+
str << ' for the device incorrectly.'
|
318
|
+
str
|
319
319
|
when 10
|
320
|
-
str =
|
321
|
-
|
320
|
+
str = 'This device cannot start.'
|
321
|
+
str
|
322
322
|
when 11
|
323
|
-
str =
|
324
|
-
|
323
|
+
str = 'This device failed.'
|
324
|
+
str
|
325
325
|
when 12
|
326
|
-
str =
|
327
|
-
str <<
|
328
|
-
|
326
|
+
str = 'This device cannot find enough free resources that'
|
327
|
+
str << ' it can use.'
|
328
|
+
str
|
329
329
|
when 13
|
330
330
|
str = "Windows cannot verify this device's resources."
|
331
|
-
|
331
|
+
str
|
332
332
|
when 14
|
333
|
-
str =
|
334
|
-
str <<
|
335
|
-
|
333
|
+
str = 'This device cannot work properly until you restart'
|
334
|
+
str << ' your computer.'
|
335
|
+
str
|
336
336
|
when 15
|
337
|
-
str =
|
338
|
-
str <<
|
339
|
-
|
337
|
+
str = 'This device is not working properly because there is'
|
338
|
+
str << ' probably a re-enumeration problem.'
|
339
|
+
str
|
340
340
|
when 16
|
341
|
-
str =
|
342
|
-
str <<
|
343
|
-
|
341
|
+
str = 'Windows cannot identify all the resources this device '
|
342
|
+
str << ' uses.'
|
343
|
+
str
|
344
344
|
when 17
|
345
|
-
str =
|
346
|
-
|
345
|
+
str = 'This device is asking for an unknown resource type.'
|
346
|
+
str
|
347
347
|
when 18
|
348
|
-
str =
|
349
|
-
|
348
|
+
str = 'Reinstall the drivers for this device.'
|
349
|
+
str
|
350
350
|
when 19
|
351
|
-
str =
|
352
|
-
|
351
|
+
str = 'Failure using the VXD loader.'
|
352
|
+
str
|
353
353
|
when 20
|
354
|
-
str =
|
355
|
-
|
354
|
+
str = 'Your registry might be corrupted.'
|
355
|
+
str
|
356
356
|
when 21
|
357
|
-
str =
|
358
|
-
str <<
|
359
|
-
str <<
|
360
|
-
|
357
|
+
str = 'System failure: try changing the driver for this device.'
|
358
|
+
str << ' If that does not work, see your hardware documentation.'
|
359
|
+
str << ' Windows is removing this device.'
|
360
|
+
str
|
361
361
|
when 22
|
362
|
-
str =
|
363
|
-
|
362
|
+
str = 'This device is disabled.'
|
363
|
+
str
|
364
364
|
when 23
|
365
|
-
str =
|
365
|
+
str = 'System failure: try changing the driver for this device.'
|
366
366
|
str << "If that doesn't work, see your hardware documentation."
|
367
|
-
|
367
|
+
str
|
368
368
|
when 24
|
369
|
-
str =
|
370
|
-
str <<
|
371
|
-
|
369
|
+
str = 'This device is not present, not working properly, or'
|
370
|
+
str << ' does not have all its drivers installed.'
|
371
|
+
str
|
372
372
|
when 25
|
373
|
-
str =
|
374
|
-
|
373
|
+
str = 'Windows is still setting up this device.'
|
374
|
+
str
|
375
375
|
when 26
|
376
|
-
str =
|
377
|
-
|
376
|
+
str = 'Windows is still setting up this device.'
|
377
|
+
str
|
378
378
|
when 27
|
379
|
-
str =
|
380
|
-
|
379
|
+
str = 'This device does not have valid log configuration.'
|
380
|
+
str
|
381
381
|
when 28
|
382
|
-
str =
|
383
|
-
|
382
|
+
str = 'The drivers for this device are not installed.'
|
383
|
+
str
|
384
384
|
when 29
|
385
|
-
str =
|
386
|
-
str <<
|
387
|
-
|
385
|
+
str = 'This device is disabled because the firmware of the'
|
386
|
+
str << ' device did not give it the required resources.'
|
387
|
+
str
|
388
388
|
when 30
|
389
|
-
str =
|
390
|
-
str <<
|
391
|
-
|
389
|
+
str = 'This device is using an Interrupt Request (IRQ)'
|
390
|
+
str << ' resource that another device is using.'
|
391
|
+
str
|
392
392
|
when 31
|
393
|
-
str =
|
394
|
-
str <<
|
395
|
-
|
393
|
+
str = 'This device is not working properly because Windows'
|
394
|
+
str << ' cannot load the drivers required for this device'
|
395
|
+
str
|
396
396
|
else
|
397
|
-
|
397
|
+
nil
|
398
398
|
end
|
399
399
|
end
|
400
400
|
|
401
|
+
private_class_method :get_cmec
|
402
|
+
|
401
403
|
# Convert an cpu architecture number to a string
|
402
404
|
def self.get_cpu_arch(num)
|
403
405
|
case num
|
404
406
|
when 0
|
405
|
-
|
407
|
+
'x86'
|
406
408
|
when 1
|
407
|
-
|
409
|
+
'MIPS'
|
408
410
|
when 2
|
409
|
-
|
411
|
+
'Alpha'
|
410
412
|
when 3
|
411
|
-
|
413
|
+
'PowerPC'
|
412
414
|
when 6
|
413
|
-
|
415
|
+
'IA64'
|
414
416
|
when 9
|
415
|
-
|
417
|
+
'x64'
|
416
418
|
else
|
417
|
-
|
419
|
+
nil
|
418
420
|
end
|
419
421
|
end
|
420
422
|
|
423
|
+
private_class_method :get_cpu_arch
|
424
|
+
|
421
425
|
# convert an Availability number into a string
|
422
426
|
def self.get_availability(num)
|
423
427
|
case num
|
424
428
|
when 1
|
425
|
-
|
429
|
+
'Other'
|
426
430
|
when 2
|
427
|
-
|
431
|
+
'Unknown'
|
428
432
|
when 3
|
429
|
-
|
433
|
+
'Running'
|
430
434
|
when 4
|
431
|
-
|
435
|
+
'Warning'
|
432
436
|
when 5
|
433
|
-
|
437
|
+
'In Test'
|
434
438
|
when 6
|
435
|
-
|
439
|
+
'Not Applicable'
|
436
440
|
when 7
|
437
|
-
|
441
|
+
'Power Off'
|
438
442
|
when 8
|
439
|
-
|
443
|
+
'Off Line'
|
440
444
|
when 9
|
441
|
-
|
445
|
+
'Off Duty'
|
442
446
|
when 10
|
443
|
-
|
447
|
+
'Degraded'
|
444
448
|
when 11
|
445
|
-
|
449
|
+
'Not Installed'
|
446
450
|
when 12
|
447
|
-
|
451
|
+
'Install Error'
|
448
452
|
when 13
|
449
|
-
|
453
|
+
'Power Save - Unknown'
|
450
454
|
when 14
|
451
|
-
|
455
|
+
'Power Save - Low Power Mode'
|
452
456
|
when 15
|
453
|
-
|
457
|
+
'Power Save - Standby'
|
454
458
|
when 16
|
455
|
-
|
459
|
+
'Power Cycle'
|
456
460
|
when 17
|
457
|
-
|
461
|
+
'Power Save - Warning'
|
458
462
|
when 18
|
459
|
-
|
463
|
+
'Paused'
|
460
464
|
when 19
|
461
|
-
|
465
|
+
'Not Ready'
|
462
466
|
when 20
|
463
|
-
|
467
|
+
'Not Configured'
|
464
468
|
when 21
|
465
|
-
|
469
|
+
'Quiesced'
|
466
470
|
else
|
467
|
-
|
471
|
+
nil
|
468
472
|
end
|
469
473
|
end
|
470
474
|
|
475
|
+
private_class_method :get_availability
|
476
|
+
|
471
477
|
# convert CpuStatus to a string form. Note that values 5 and 6 are
|
472
478
|
# skipped because they're reserved.
|
473
479
|
def self.get_status(num)
|
474
480
|
case num
|
475
481
|
when 0
|
476
|
-
|
482
|
+
'Unknown'
|
477
483
|
when 1
|
478
|
-
|
484
|
+
'Enabled'
|
479
485
|
when 2
|
480
|
-
|
486
|
+
'Disabled by User via BIOS Setup'
|
481
487
|
when 3
|
482
|
-
|
488
|
+
'Disabled By BIOS (POST Error)'
|
483
489
|
when 4
|
484
|
-
|
490
|
+
'Idle'
|
485
491
|
when 7
|
486
|
-
|
492
|
+
'Other'
|
487
493
|
else
|
488
|
-
|
494
|
+
nil
|
489
495
|
end
|
490
496
|
end
|
491
497
|
|
498
|
+
private_class_method :get_status
|
499
|
+
|
492
500
|
# Convert a family number into the equivalent string
|
493
501
|
def self.get_family(num)
|
494
502
|
case num
|
495
503
|
when 1
|
496
|
-
|
504
|
+
'Other'
|
497
505
|
when 2
|
498
|
-
|
506
|
+
'Unknown'
|
499
507
|
when 3
|
500
|
-
|
508
|
+
'8086'
|
501
509
|
when 4
|
502
|
-
|
510
|
+
'80286'
|
503
511
|
when 5
|
504
|
-
|
512
|
+
'80386'
|
505
513
|
when 6
|
506
|
-
|
514
|
+
'80486'
|
507
515
|
when 7
|
508
|
-
|
516
|
+
'8087'
|
509
517
|
when 8
|
510
|
-
|
518
|
+
'80287'
|
511
519
|
when 9
|
512
|
-
|
520
|
+
'80387'
|
513
521
|
when 10
|
514
|
-
|
522
|
+
'80487'
|
515
523
|
when 11
|
516
|
-
|
524
|
+
'Pentium?'
|
517
525
|
when 12
|
518
|
-
|
526
|
+
'Pentium?'
|
519
527
|
when 13
|
520
|
-
|
528
|
+
'Pentium?'
|
521
529
|
when 14
|
522
|
-
|
530
|
+
'Pentium?'
|
523
531
|
when 15
|
524
|
-
|
532
|
+
'Celeron?'
|
525
533
|
when 16
|
526
|
-
|
534
|
+
'Pentium?'
|
527
535
|
when 17
|
528
|
-
|
536
|
+
'Pentium?'
|
529
537
|
when 18
|
530
|
-
|
538
|
+
'M1'
|
531
539
|
when 19
|
532
|
-
|
540
|
+
'M2'
|
533
541
|
when 24
|
534
|
-
|
542
|
+
'K5'
|
535
543
|
when 25
|
536
|
-
|
544
|
+
'K6'
|
537
545
|
when 26
|
538
|
-
|
546
|
+
'K6-2'
|
539
547
|
when 27
|
540
|
-
|
548
|
+
'K6-3'
|
541
549
|
when 28
|
542
|
-
|
550
|
+
'AMD'
|
543
551
|
when 29
|
544
|
-
|
552
|
+
'AMD?'
|
545
553
|
when 30
|
546
|
-
|
554
|
+
'AMD2900'
|
547
555
|
when 31
|
548
|
-
|
556
|
+
'K6-2+'
|
549
557
|
when 32
|
550
|
-
|
558
|
+
'Power'
|
551
559
|
when 33
|
552
|
-
|
560
|
+
'Power'
|
553
561
|
when 34
|
554
|
-
|
562
|
+
'Power'
|
555
563
|
when 35
|
556
|
-
|
564
|
+
'Power'
|
557
565
|
when 36
|
558
|
-
|
566
|
+
'Power'
|
559
567
|
when 37
|
560
|
-
|
568
|
+
'Power'
|
561
569
|
when 38
|
562
|
-
|
570
|
+
'Power'
|
563
571
|
when 39
|
564
|
-
|
572
|
+
'Power'
|
565
573
|
when 48
|
566
|
-
|
574
|
+
'Alpha'
|
567
575
|
when 49
|
568
|
-
|
576
|
+
'Alpha'
|
569
577
|
when 50
|
570
|
-
|
578
|
+
'Alpha'
|
571
579
|
when 51
|
572
|
-
|
580
|
+
'Alpha'
|
573
581
|
when 52
|
574
|
-
|
582
|
+
'Alpha'
|
575
583
|
when 53
|
576
|
-
|
584
|
+
'Alpha'
|
577
585
|
when 54
|
578
|
-
|
586
|
+
'Alpha'
|
579
587
|
when 55
|
580
|
-
|
588
|
+
'Alpha'
|
581
589
|
when 64
|
582
|
-
|
590
|
+
'MIPS'
|
583
591
|
when 65
|
584
|
-
|
592
|
+
'MIPS'
|
585
593
|
when 66
|
586
|
-
|
594
|
+
'MIPS'
|
587
595
|
when 67
|
588
|
-
|
596
|
+
'MIPS'
|
589
597
|
when 68
|
590
|
-
|
598
|
+
'MIPS'
|
591
599
|
when 69
|
592
|
-
|
600
|
+
'MIPS'
|
593
601
|
when 80
|
594
|
-
|
602
|
+
'SPARC'
|
595
603
|
when 81
|
596
|
-
|
604
|
+
'SuperSPARC'
|
597
605
|
when 82
|
598
|
-
|
606
|
+
'microSPARC'
|
599
607
|
when 83
|
600
|
-
|
608
|
+
'microSPARC'
|
601
609
|
when 84
|
602
|
-
|
610
|
+
'UltraSPARC'
|
603
611
|
when 85
|
604
|
-
|
612
|
+
'UltraSPARC'
|
605
613
|
when 86
|
606
|
-
|
614
|
+
'UltraSPARC'
|
607
615
|
when 87
|
608
|
-
|
616
|
+
'UltraSPARC'
|
609
617
|
when 88
|
610
|
-
|
618
|
+
'UltraSPARC'
|
611
619
|
when 96
|
612
|
-
|
620
|
+
'68040'
|
613
621
|
when 97
|
614
|
-
|
622
|
+
'68xxx'
|
615
623
|
when 98
|
616
|
-
|
624
|
+
'68000'
|
617
625
|
when 99
|
618
|
-
|
626
|
+
'68010'
|
619
627
|
when 100
|
620
|
-
|
628
|
+
'68020'
|
621
629
|
when 101
|
622
|
-
|
630
|
+
'68030'
|
623
631
|
when 112
|
624
|
-
|
632
|
+
'Hobbit'
|
625
633
|
when 120
|
626
|
-
|
634
|
+
'Crusoe?'
|
627
635
|
when 121
|
628
|
-
|
636
|
+
'Crusoe?'
|
629
637
|
when 128
|
630
|
-
|
638
|
+
'Weitek'
|
631
639
|
when 130
|
632
|
-
|
640
|
+
'Itanium?'
|
633
641
|
when 144
|
634
|
-
|
642
|
+
'PA-RISC'
|
635
643
|
when 145
|
636
|
-
|
644
|
+
'PA-RISC'
|
637
645
|
when 146
|
638
|
-
|
646
|
+
'PA-RISC'
|
639
647
|
when 147
|
640
|
-
|
648
|
+
'PA-RISC'
|
641
649
|
when 148
|
642
|
-
|
650
|
+
'PA-RISC'
|
643
651
|
when 149
|
644
|
-
|
652
|
+
'PA-RISC'
|
645
653
|
when 150
|
646
|
-
|
654
|
+
'PA-RISC'
|
647
655
|
when 160
|
648
|
-
|
656
|
+
'V30'
|
649
657
|
when 176
|
650
|
-
|
658
|
+
'Pentium?'
|
651
659
|
when 177
|
652
|
-
|
660
|
+
'Pentium?'
|
653
661
|
when 178
|
654
|
-
|
662
|
+
'Pentium?'
|
655
663
|
when 179
|
656
|
-
|
664
|
+
'Intel?'
|
657
665
|
when 180
|
658
|
-
|
666
|
+
'AS400'
|
659
667
|
when 181
|
660
|
-
|
668
|
+
'Intel?'
|
661
669
|
when 182
|
662
|
-
|
670
|
+
'AMD'
|
663
671
|
when 183
|
664
|
-
|
672
|
+
'AMD'
|
665
673
|
when 184
|
666
|
-
|
674
|
+
'Intel?'
|
667
675
|
when 185
|
668
|
-
|
676
|
+
'AMD'
|
669
677
|
when 190
|
670
|
-
|
678
|
+
'K7'
|
671
679
|
when 200
|
672
|
-
|
680
|
+
'IBM390'
|
673
681
|
when 201
|
674
|
-
|
682
|
+
'G4'
|
675
683
|
when 202
|
676
|
-
|
684
|
+
'G5'
|
677
685
|
when 250
|
678
|
-
|
686
|
+
'i860'
|
679
687
|
when 251
|
680
|
-
|
688
|
+
'i960'
|
681
689
|
when 260
|
682
|
-
|
690
|
+
'SH-3'
|
683
691
|
when 261
|
684
|
-
|
692
|
+
'SH-4'
|
685
693
|
when 280
|
686
|
-
|
694
|
+
'ARM'
|
687
695
|
when 281
|
688
|
-
|
696
|
+
'StrongARM'
|
689
697
|
when 300
|
690
|
-
|
698
|
+
'6x86'
|
691
699
|
when 301
|
692
|
-
|
700
|
+
'MediaGX'
|
693
701
|
when 302
|
694
|
-
|
702
|
+
'MII'
|
695
703
|
when 320
|
696
|
-
|
704
|
+
'WinChip'
|
697
705
|
when 350
|
698
|
-
|
706
|
+
'DSP'
|
699
707
|
when 500
|
700
|
-
|
708
|
+
'Video'
|
701
709
|
else
|
702
|
-
|
710
|
+
nil
|
703
711
|
end
|
704
712
|
end
|
705
713
|
|
714
|
+
private_class_method :get_family
|
715
|
+
|
706
716
|
# Convert power management capabilities number to its equivalent string
|
707
717
|
def self.get_pmc(num)
|
708
718
|
case num
|
709
719
|
when 0
|
710
|
-
|
720
|
+
'Unknown'
|
711
721
|
when 1
|
712
|
-
|
722
|
+
'Not Supported'
|
713
723
|
when 2
|
714
|
-
|
724
|
+
'Disabled'
|
715
725
|
when 3
|
716
|
-
|
726
|
+
'Enabled'
|
717
727
|
when 4
|
718
|
-
|
728
|
+
'Power Saving Modes Entered Automatically'
|
719
729
|
when 5
|
720
|
-
|
730
|
+
'Power State Settable'
|
721
731
|
when 6
|
722
|
-
|
732
|
+
'Power Cycling Supported'
|
723
733
|
when 7
|
724
|
-
|
734
|
+
'Timed Power On Supported'
|
725
735
|
else
|
726
|
-
|
736
|
+
nil
|
727
737
|
end
|
728
738
|
end
|
729
739
|
|
740
|
+
private_class_method :get_pmc
|
741
|
+
|
730
742
|
# Convert a processor type into its equivalent string
|
731
743
|
def self.get_processor_type(num)
|
732
744
|
case num
|
733
745
|
when 1
|
734
|
-
|
746
|
+
'Other'
|
735
747
|
when 2
|
736
|
-
|
748
|
+
'Unknown'
|
737
749
|
when 3
|
738
|
-
|
750
|
+
'Central Processor'
|
739
751
|
when 4
|
740
|
-
|
752
|
+
'Math Processor'
|
741
753
|
when 5
|
742
|
-
|
754
|
+
'DSP Processor'
|
743
755
|
when 6
|
744
|
-
|
756
|
+
'Video Processor'
|
745
757
|
else
|
746
|
-
|
758
|
+
nil
|
747
759
|
end
|
748
760
|
end
|
749
761
|
|
762
|
+
private_class_method :get_processor_type
|
763
|
+
|
750
764
|
# Convert an upgrade method into its equivalent string
|
751
765
|
def self.get_upgrade_method(num)
|
752
766
|
case num
|
753
767
|
when 1
|
754
|
-
|
768
|
+
'Other'
|
755
769
|
when 2
|
756
|
-
|
770
|
+
'Unknown'
|
757
771
|
when 3
|
758
|
-
|
772
|
+
'Daughter Board'
|
759
773
|
when 4
|
760
|
-
|
774
|
+
'ZIF Socket'
|
761
775
|
when 5
|
762
|
-
|
776
|
+
'Replacement/Piggy Back'
|
763
777
|
when 6
|
764
|
-
|
778
|
+
'None'
|
765
779
|
when 7
|
766
|
-
|
780
|
+
'LIF Socket'
|
767
781
|
when 8
|
768
|
-
|
782
|
+
'Slot 1'
|
769
783
|
when 9
|
770
|
-
|
784
|
+
'Slot 2'
|
771
785
|
when 10
|
772
|
-
|
786
|
+
'370 Pin Socket'
|
773
787
|
when 11
|
774
|
-
|
788
|
+
'Slot A'
|
775
789
|
when 12
|
776
|
-
|
790
|
+
'Slot M'
|
777
791
|
else
|
778
|
-
|
792
|
+
nil
|
779
793
|
end
|
780
794
|
end
|
781
795
|
|
796
|
+
private_class_method :get_upgrade_method
|
797
|
+
|
782
798
|
# Convert return values to voltage cap values (floats)
|
783
799
|
def self.get_voltage_caps(num)
|
784
800
|
case num
|
785
801
|
when 1
|
786
|
-
|
802
|
+
5.0
|
787
803
|
when 2
|
788
|
-
|
804
|
+
3.3
|
789
805
|
when 4
|
790
|
-
|
806
|
+
2.9
|
791
807
|
else
|
792
|
-
|
808
|
+
nil
|
793
809
|
end
|
794
810
|
end
|
811
|
+
|
812
|
+
private_class_method :get_voltage_caps
|
795
813
|
end
|
796
814
|
end
|