sys-cpu 1.0.1 → 1.0.2
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.md +3 -0
- data/README.md +1 -1
- data/lib/sys/cpu.rb +1 -1
- data/lib/sys/linux/sys/cpu.rb +16 -18
- data/lib/sys/unix/sys/cpu.rb +31 -31
- data/lib/sys/windows/sys/cpu.rb +288 -270
- data/spec/sys_cpu_spec.rb +1 -1
- data/sys-cpu.gemspec +1 -1
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9b8cf15d0019738569df3847184952320df08960cc039e52ed819ae7a649d3f
|
4
|
+
data.tar.gz: b38dc203121fa564f8c6d156e99821eb33ea1b7db7070e261262458531b7393a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bbce2f399977b559cbbd799b0b2fb9c5343627e316d8d8c1a58fd61878452491ffd3bf4dc18851c1a8c76d383b7b9aea2e9f7b8bae03e465fd94cd602f1e802
|
7
|
+
data.tar.gz: 1ac9b193bf154c24b884ac0638a6bc2ff7ee959adaf0dac0d05eb8e47a4f4eadbc5e0f019cd50100cc5e30c0ac02ec8db6f10c89b1acf3404f30f64ea5341818
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
data/lib/sys/cpu.rb
CHANGED
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
|
|
@@ -81,9 +81,9 @@ module Sys
|
|
81
81
|
def self.architecture
|
82
82
|
case CPU_ARRAY.first['cpu_family']
|
83
83
|
when '3'
|
84
|
-
|
84
|
+
'x86'
|
85
85
|
when '6'
|
86
|
-
|
86
|
+
'x86_64'
|
87
87
|
else
|
88
88
|
nil
|
89
89
|
end
|
@@ -101,27 +101,25 @@ module Sys
|
|
101
101
|
CPU_ARRAY.first['cpu_mhz'].to_f.round
|
102
102
|
end
|
103
103
|
|
104
|
-
private
|
105
|
-
|
106
104
|
# Create singleton methods for each of the attributes.
|
107
105
|
#
|
108
106
|
def self.method_missing(id, arg=0)
|
109
107
|
raise NoMethodError, "'#{id}'" unless CPU_ARRAY[arg].has_key?(id.to_s)
|
110
108
|
rv = CPU_ARRAY[arg][id.to_s]
|
111
109
|
if rv.nil?
|
112
|
-
id = id.to_s +
|
110
|
+
id = id.to_s + '?'
|
113
111
|
rv = CPU_ARRAY[arg][id]
|
114
112
|
end
|
115
113
|
rv
|
116
114
|
end
|
117
115
|
|
118
|
-
|
116
|
+
private_class_method :method_missing
|
119
117
|
|
120
118
|
# Returns a 3 element Array corresponding to the 1, 5 and 15 minute
|
121
119
|
# load average for the system.
|
122
120
|
#
|
123
121
|
def self.load_avg
|
124
|
-
load_avg_file =
|
122
|
+
load_avg_file = '/proc/loadavg'
|
125
123
|
IO.readlines(load_avg_file).first.split[0..2].map{ |e| e.to_f }
|
126
124
|
end
|
127
125
|
|
@@ -142,7 +140,7 @@ module Sys
|
|
142
140
|
# Note that older kernels may not necessarily include some of these fields.
|
143
141
|
#
|
144
142
|
def self.cpu_stats
|
145
|
-
cpu_stat_file =
|
143
|
+
cpu_stat_file = '/proc/stat'
|
146
144
|
hash = {} # Hash needed for multi-cpu systems
|
147
145
|
|
148
146
|
lines = IO.readlines(cpu_stat_file)
|
@@ -153,11 +151,11 @@ module Sys
|
|
153
151
|
|
154
152
|
# Some machines list a 'cpu' and a 'cpu0'. In this case only
|
155
153
|
# return values for the numbered cpu entry.
|
156
|
-
if lines[i].split[0] ==
|
154
|
+
if lines[i].split[0] == 'cpu' && lines[i+1].split[0] =~ /cpu\d/
|
157
155
|
next
|
158
156
|
end
|
159
157
|
|
160
|
-
vals = array[1..-1].map{ |e| e
|
158
|
+
vals = array[1..-1].map{ |e| e.to_i / 100 } # 100 jiffies/sec.
|
161
159
|
hash[array[0]] = vals
|
162
160
|
}
|
163
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
|
@@ -112,7 +112,7 @@ module Sys
|
|
112
112
|
end
|
113
113
|
|
114
114
|
if sysctlbyname(name, optr, size, nil, 0) < 0
|
115
|
-
raise Error,
|
115
|
+
raise Error, 'sysctlbyname function failed'
|
116
116
|
end
|
117
117
|
|
118
118
|
optr.read_string
|
@@ -125,7 +125,7 @@ module Sys
|
|
125
125
|
size.write_int(buf.size)
|
126
126
|
|
127
127
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
128
|
-
raise Error,
|
128
|
+
raise Error, 'sysctl function failed'
|
129
129
|
end
|
130
130
|
|
131
131
|
buf.strip
|
@@ -144,7 +144,7 @@ module Sys
|
|
144
144
|
size.write_long(optr.size)
|
145
145
|
|
146
146
|
if sysctlbyname('hw.ncpu', optr, size, nil, 0) < 0
|
147
|
-
raise Error,
|
147
|
+
raise Error, 'sysctlbyname failed'
|
148
148
|
end
|
149
149
|
|
150
150
|
optr.read_long
|
@@ -152,7 +152,7 @@ module Sys
|
|
152
152
|
num = sysconf(SC_NPROCESSORS_ONLN)
|
153
153
|
|
154
154
|
if num < 0
|
155
|
-
raise Error,
|
155
|
+
raise Error, 'sysconf function failed'
|
156
156
|
end
|
157
157
|
|
158
158
|
num
|
@@ -165,10 +165,10 @@ module Sys
|
|
165
165
|
size.write_int(buf.size)
|
166
166
|
|
167
167
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
168
|
-
raise Error,
|
168
|
+
raise Error, 'sysctl function failed'
|
169
169
|
end
|
170
170
|
|
171
|
-
buf.strip.unpack(
|
171
|
+
buf.strip.unpack('C').first
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -186,7 +186,7 @@ module Sys
|
|
186
186
|
size.write_int(buf.size)
|
187
187
|
|
188
188
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
189
|
-
raise Error,
|
189
|
+
raise Error, 'sysctl function failed'
|
190
190
|
end
|
191
191
|
|
192
192
|
buf.strip
|
@@ -194,7 +194,7 @@ module Sys
|
|
194
194
|
buf = 0.chr * 257
|
195
195
|
|
196
196
|
if sysinfo(SI_MACHINE, buf, buf.size) < 0
|
197
|
-
raise Error,
|
197
|
+
raise Error, 'sysinfo function failed'
|
198
198
|
end
|
199
199
|
|
200
200
|
buf.strip
|
@@ -210,19 +210,19 @@ module Sys
|
|
210
210
|
|
211
211
|
size.write_long(ptr.size)
|
212
212
|
|
213
|
-
if sysctlbyname(
|
214
|
-
raise
|
213
|
+
if sysctlbyname('hw.cputype', ptr, size, nil, 0) < 0
|
214
|
+
raise 'sysctlbyname function failed'
|
215
215
|
end
|
216
216
|
|
217
217
|
case ptr.read_long
|
218
218
|
when CPU_TYPE_X86, CPU_TYPE_X86_64
|
219
|
-
|
219
|
+
'Intel'
|
220
220
|
when CPU_TYPE_SPARC
|
221
|
-
|
221
|
+
'Sparc'
|
222
222
|
when CPU_TYPE_POWERPC, CPU_TYPE_POWERPC64
|
223
|
-
|
223
|
+
'PowerPC'
|
224
224
|
else
|
225
|
-
|
225
|
+
'Unknown'
|
226
226
|
end
|
227
227
|
else
|
228
228
|
if respond_to?(:sysctl, true)
|
@@ -234,7 +234,7 @@ module Sys
|
|
234
234
|
size.write_int(buf.size)
|
235
235
|
|
236
236
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
237
|
-
raise Error,
|
237
|
+
raise Error, 'sysctl function failed'
|
238
238
|
end
|
239
239
|
|
240
240
|
buf.strip
|
@@ -244,7 +244,7 @@ module Sys
|
|
244
244
|
# Some systems start at 0, some at 1
|
245
245
|
if processor_info(0, pinfo) < 0
|
246
246
|
if processor_info(1, pinfo) < 0
|
247
|
-
raise Error,
|
247
|
+
raise Error, 'process_info function failed'
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
@@ -269,7 +269,7 @@ module Sys
|
|
269
269
|
end
|
270
270
|
|
271
271
|
if sysctlbyname(name, optr, size, nil, 0) < 0
|
272
|
-
raise Error,
|
272
|
+
raise Error, 'sysctlbyname failed'
|
273
273
|
end
|
274
274
|
|
275
275
|
if RbConfig::CONFIG['host_os'] =~ /darwin/i
|
@@ -286,17 +286,17 @@ module Sys
|
|
286
286
|
size.write_int(buf.size)
|
287
287
|
|
288
288
|
if sysctl(mib, 2, buf, size, nil, 0) < 0
|
289
|
-
raise Error,
|
289
|
+
raise Error, 'sysctl function failed'
|
290
290
|
end
|
291
291
|
|
292
|
-
buf.unpack(
|
292
|
+
buf.unpack('I*').first / 1000000
|
293
293
|
else
|
294
294
|
pinfo = ProcInfo.new
|
295
295
|
|
296
296
|
# Some systems start at 0, some at 1
|
297
297
|
if processor_info(0, pinfo) < 0
|
298
298
|
if processor_info(1, pinfo) < 0
|
299
|
-
raise Error,
|
299
|
+
raise Error, 'process_info function failed'
|
300
300
|
end
|
301
301
|
end
|
302
302
|
|
@@ -312,7 +312,7 @@ module Sys
|
|
312
312
|
loadavg = FFI::MemoryPointer.new(:double, 3)
|
313
313
|
|
314
314
|
if getloadavg(loadavg, loadavg.size) < 0
|
315
|
-
raise Error,
|
315
|
+
raise Error, 'getloadavg function failed'
|
316
316
|
end
|
317
317
|
|
318
318
|
loadavg.get_array_of_double(0, 3)
|
@@ -330,7 +330,7 @@ module Sys
|
|
330
330
|
|
331
331
|
if processor_info(0, pinfo) < 0
|
332
332
|
if processor_info(1, pinfo) < 0
|
333
|
-
raise Error,
|
333
|
+
raise Error, 'process_info function failed'
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
@@ -348,24 +348,24 @@ module Sys
|
|
348
348
|
pinfo = ProcInfo.new
|
349
349
|
|
350
350
|
if processor_info(num, pinfo) < 0
|
351
|
-
raise Error,
|
351
|
+
raise Error, 'process_info function failed'
|
352
352
|
end
|
353
353
|
|
354
354
|
case pinfo[:pi_state].to_i
|
355
355
|
when P_ONLINE
|
356
|
-
|
356
|
+
'online'
|
357
357
|
when P_OFFLINE
|
358
|
-
|
358
|
+
'offline'
|
359
359
|
when P_POWEROFF
|
360
|
-
|
360
|
+
'poweroff'
|
361
361
|
when P_FAULTED
|
362
|
-
|
362
|
+
'faulted'
|
363
363
|
when P_NOINTR
|
364
|
-
|
364
|
+
'nointr'
|
365
365
|
when P_SPARE
|
366
|
-
|
366
|
+
'spare'
|
367
367
|
else
|
368
|
-
|
368
|
+
'unknown'
|
369
369
|
end
|
370
370
|
end
|
371
371
|
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
|
|
@@ -280,517 +280,535 @@ module Sys
|
|
280
280
|
def self.get_cmec(num)
|
281
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
|