sys-cpu 0.6.4-universal-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +159 -0
- data/MANIFEST +29 -0
- data/README +73 -0
- data/Rakefile +89 -0
- data/doc/bsd.txt +49 -0
- data/doc/hpux.txt +54 -0
- data/doc/linux.txt +41 -0
- data/doc/sunos.txt +56 -0
- data/doc/windows.txt +130 -0
- data/examples/example_sys_cpu_bsd.rb +19 -0
- data/examples/example_sys_cpu_hpux.rb +27 -0
- data/examples/example_sys_cpu_linux.rb +24 -0
- data/examples/example_sys_cpu_sunos.rb +21 -0
- data/examples/example_sys_cpu_windows.rb +24 -0
- data/ext/bsd/bsd.c +331 -0
- data/ext/extconf.rb +26 -0
- data/ext/hpux/hpux.c +219 -0
- data/ext/sunos/sunos.c +281 -0
- data/ext/version.h +2 -0
- data/install.rb +85 -0
- data/lib/linux/sys/cpu.rb +122 -0
- data/lib/windows/sys/cpu.rb +790 -0
- data/sys-cpu.gemspec +50 -0
- data/test/test_sys_cpu.rb +23 -0
- data/test/test_sys_cpu_bsd.rb +76 -0
- data/test/test_sys_cpu_hpux.rb +52 -0
- data/test/test_sys_cpu_linux.rb +34 -0
- data/test/test_sys_cpu_sunos.rb +67 -0
- data/test/test_sys_cpu_version.rb +18 -0
- data/test/test_sys_cpu_windows.rb +72 -0
- metadata +113 -0
data/ext/version.h
ADDED
data/install.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# install.rb
|
3
|
+
#
|
4
|
+
# For pure Ruby versions only. Generally speaking this script should
|
5
|
+
# not be run directly. Use the 'rake install' task instead.
|
6
|
+
#######################################################################
|
7
|
+
require 'rbconfig'
|
8
|
+
require 'fileutils'
|
9
|
+
include Config
|
10
|
+
install_dir = File.join(CONFIG['sitelibdir'], 'sys')
|
11
|
+
|
12
|
+
file = ""
|
13
|
+
|
14
|
+
case CONFIG['host_os']
|
15
|
+
when /windows|win32|mingw|cygwin|dos/i
|
16
|
+
file = "lib/windows/sys/cpu.rb"
|
17
|
+
when /linux/i
|
18
|
+
file = "lib/linux/sys/cpu.rb"
|
19
|
+
when /sunos|solaris|hpux|freebsd/i
|
20
|
+
STDERR.puts "Use 'extconf.rb/make/make site-install' for this platform"
|
21
|
+
exit
|
22
|
+
else
|
23
|
+
STDERR.puts "This platform is not currently supported. Exiting..."
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
|
27
|
+
#######################################################################
|
28
|
+
# Dynamically generate some of the documentation for linux. If the
|
29
|
+
# doc size is already greater than 1.4k, assume that the documentation
|
30
|
+
# has already been written at some point previously and skip it.
|
31
|
+
#######################################################################
|
32
|
+
if CONFIG['host_os'] =~ /linux/
|
33
|
+
cpu_file = "/proc/cpuinfo"
|
34
|
+
text_file = "doc/linux.txt"
|
35
|
+
rb_file = "lib/linux/sys/cpu.rb"
|
36
|
+
|
37
|
+
if File.size(text_file) > 1400
|
38
|
+
puts "You appear to have already created the documentation."
|
39
|
+
puts "Skipping..."
|
40
|
+
else
|
41
|
+
puts "Dynamically generating documentation..."
|
42
|
+
fh = File.open(text_file, 'a')
|
43
|
+
|
44
|
+
IO.foreach(cpu_file){ |line|
|
45
|
+
next if line =~ /^$/
|
46
|
+
k,v = line.split(":")
|
47
|
+
|
48
|
+
v = v.strip.chomp
|
49
|
+
k = k.strip.gsub(/\s+/, '_').downcase
|
50
|
+
|
51
|
+
k += "?" if v =~ /yes|no/i
|
52
|
+
|
53
|
+
fh.puts("CPU.#{k}")
|
54
|
+
|
55
|
+
if v =~ /yes|no/i
|
56
|
+
k.chop!
|
57
|
+
msg = " Returns true if a " + k.gsub(/_/," ") + "exists on"
|
58
|
+
msg << " this system"
|
59
|
+
fh.puts(msg)
|
60
|
+
else
|
61
|
+
fh.puts(" Returns the " + k.gsub(/_/," "))
|
62
|
+
end
|
63
|
+
|
64
|
+
fh.puts # Add a blank line
|
65
|
+
}
|
66
|
+
|
67
|
+
fh.close
|
68
|
+
puts "Documentation creation complete"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Create the 'sys' toplevel directory if it doesn't already exist
|
73
|
+
begin
|
74
|
+
unless File.exist?(install_dir)
|
75
|
+
Dir.mkdir(install_dir)
|
76
|
+
end
|
77
|
+
rescue Errno::EACCES => e
|
78
|
+
puts "Unable to create #{install_dir}: #{e}"
|
79
|
+
exit
|
80
|
+
end
|
81
|
+
|
82
|
+
# Finally, copy the file to the appropriate directory
|
83
|
+
FileUtils.cp(file, "#{install_dir}/cpu.rb", :verbose => true)
|
84
|
+
|
85
|
+
puts "Installation successful"
|
@@ -0,0 +1,122 @@
|
|
1
|
+
##########################################################
|
2
|
+
# linux.rb (sys-cpu) - pure Ruby version for Linux
|
3
|
+
##########################################################
|
4
|
+
module Sys
|
5
|
+
|
6
|
+
# :stopdoc:
|
7
|
+
|
8
|
+
cpu_file = "/proc/cpuinfo"
|
9
|
+
cpu_hash = {}
|
10
|
+
$cpu_array = []
|
11
|
+
|
12
|
+
# Parse the info out of the /proc/cpuinfo file
|
13
|
+
IO.foreach(cpu_file){ |line|
|
14
|
+
line.strip!
|
15
|
+
next if line.empty?
|
16
|
+
|
17
|
+
key, val = line.split(":")
|
18
|
+
key.strip!
|
19
|
+
key.gsub!(/\s+/,"_")
|
20
|
+
key.downcase!
|
21
|
+
val.strip! if val
|
22
|
+
|
23
|
+
if cpu_hash.has_key?(key)
|
24
|
+
$cpu_array.push(cpu_hash.dup)
|
25
|
+
cpu_hash.clear
|
26
|
+
end
|
27
|
+
|
28
|
+
# Turn yes/no attributes into booleans
|
29
|
+
if val == 'yes'
|
30
|
+
val = true
|
31
|
+
elsif val == 'no'
|
32
|
+
val = false
|
33
|
+
end
|
34
|
+
|
35
|
+
cpu_hash[key] = val
|
36
|
+
}
|
37
|
+
|
38
|
+
$cpu_array.push(cpu_hash)
|
39
|
+
|
40
|
+
# :startdoc:
|
41
|
+
|
42
|
+
class CPU
|
43
|
+
|
44
|
+
# The version of the sys-cpu library.
|
45
|
+
VERSION = '0.6.4'
|
46
|
+
|
47
|
+
# :stopdoc:
|
48
|
+
|
49
|
+
CPUStruct = Struct.new("CPUStruct", *$cpu_array.first.keys)
|
50
|
+
|
51
|
+
# :startdoc:
|
52
|
+
|
53
|
+
# In block form, yields a CPUStruct for each CPU on the system. In
|
54
|
+
# non-block form, returns an Array of CPUStruct's.
|
55
|
+
#
|
56
|
+
# The exact members of the struct vary on Linux systems.
|
57
|
+
#
|
58
|
+
def self.processors
|
59
|
+
array = []
|
60
|
+
$cpu_array.each{ |hash|
|
61
|
+
struct = CPUStruct.new
|
62
|
+
struct.members.each{ |m| struct.send("#{m}=", hash[m]) }
|
63
|
+
if block_given?
|
64
|
+
yield struct
|
65
|
+
else
|
66
|
+
array << struct
|
67
|
+
end
|
68
|
+
}
|
69
|
+
array unless block_given?
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
# Create singleton methods for each of the attributes.
|
75
|
+
#
|
76
|
+
def self.method_missing(id, arg=0)
|
77
|
+
rv = $cpu_array[arg][id.to_s]
|
78
|
+
if rv.nil?
|
79
|
+
id = id.to_s + "?"
|
80
|
+
rv = $cpu_array[arg][id]
|
81
|
+
end
|
82
|
+
rv
|
83
|
+
end
|
84
|
+
|
85
|
+
public
|
86
|
+
|
87
|
+
# Returns a 3 element Array corresponding to the 1, 5 and 15 minute
|
88
|
+
# load average for the system.
|
89
|
+
#
|
90
|
+
def self.load_avg
|
91
|
+
load_avg_file = "/proc/loadavg"
|
92
|
+
IO.readlines(load_avg_file).first.split[0..2].map{ |e| e.to_f }
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns a hash of arrays that contain the number of seconds that the
|
96
|
+
# system spent in user mode, user mode with low priority (nice), system
|
97
|
+
# mode, and the idle task, respectively.
|
98
|
+
#
|
99
|
+
def self.cpu_stats
|
100
|
+
cpu_stat_file = "/proc/stat"
|
101
|
+
hash = {} # Hash needed for multi-cpu systems
|
102
|
+
|
103
|
+
lines = IO.readlines(cpu_stat_file)
|
104
|
+
|
105
|
+
lines.each_with_index{ |line, i|
|
106
|
+
array = line.split
|
107
|
+
break unless array[0] =~ /cpu/ # 'cpu' entries always on top
|
108
|
+
|
109
|
+
# Some machines list a 'cpu' and a 'cpu0'. In this case only
|
110
|
+
# return values for the numbered cpu entry.
|
111
|
+
if lines[i].split[0] == "cpu" && lines[i+1].split[0] =~ /cpu\d/
|
112
|
+
next
|
113
|
+
end
|
114
|
+
|
115
|
+
vals = array[1..-1].map{ |e| e = e.to_i / 100 } # 100 jiffies/sec.
|
116
|
+
hash[array[0]] = vals
|
117
|
+
}
|
118
|
+
|
119
|
+
hash
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,790 @@
|
|
1
|
+
require 'win32ole'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
# The Sys module serves only as a namespace
|
5
|
+
module Sys
|
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
|
+
|
11
|
+
# The version of the sys-cpu library
|
12
|
+
VERSION = '0.6.4'
|
13
|
+
|
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
|
+
/
|
66
|
+
|
67
|
+
# The struct returned by the CPU.processors method
|
68
|
+
CPUStruct = Struct.new("CPUStruct", *fields) # :nodoc:
|
69
|
+
|
70
|
+
public
|
71
|
+
|
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)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
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
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
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
|
120
|
+
|
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
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
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
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
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
|
255
|
+
|
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
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
private
|
270
|
+
|
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
|
392
|
+
end
|
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
|
412
|
+
end
|
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
|
483
|
+
end
|
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
|
697
|
+
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
|
721
|
+
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
|
741
|
+
end
|
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
|
773
|
+
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
|
787
|
+
end
|
788
|
+
end
|
789
|
+
end
|
790
|
+
end
|