sys-uname 0.7.4-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +115 -0
- data/MANIFEST +16 -0
- data/README +42 -0
- data/doc/uname.txt +122 -0
- data/install.rb +30 -0
- data/lib/sys/uname.rb +464 -0
- data/sys-uname-0.7.4-mswin32.gem +0 -0
- data/sys-uname.gemspec +34 -0
- data/test/tc_uname.rb +493 -0
- metadata +62 -0
data/CHANGES
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
== 0.7.4 - 19-Nov-2006
|
2
|
+
* Internal layout changes, doc updates and gemspec improvements.
|
3
|
+
* No code changes.
|
4
|
+
|
5
|
+
== 0.7.3 - 30-Jul-2006
|
6
|
+
* Bug fix for 64 bit platforms.
|
7
|
+
* Minor modification of the extconf.rb file.
|
8
|
+
|
9
|
+
== 0.7.2 - 5-Jul-2006
|
10
|
+
* Removed '?' from the struct member names on MS Windows since these are no
|
11
|
+
longer legal.
|
12
|
+
* Removed duplicate definition of Uname.version on MS Windows (oops).
|
13
|
+
* Added a gemspec.
|
14
|
+
* Added inline rdoc documentation to the source files.
|
15
|
+
|
16
|
+
== 0.7.1 - 5-May-2005
|
17
|
+
* Removed the uname.rd file. The uname.txt file is rdoc friendly, so you
|
18
|
+
can autogenerate html from that file if you wish.
|
19
|
+
* Removed the version.h file - no longer needed now that the Windows version
|
20
|
+
is pure Ruby.
|
21
|
+
* Renamed test.rb to uname_test.rb
|
22
|
+
* Minor setup modifications to the test suite.
|
23
|
+
* This package is now hosted on RubyForge.
|
24
|
+
|
25
|
+
== 0.7.0 - 11-Jan-2004
|
26
|
+
* Scrapped the C version for Windows in favor of a pure Ruby version that uses
|
27
|
+
WMI + OLE. I highly recommend using Ruby 1.8.2 or later on Win32 systems.
|
28
|
+
Earlier versions may cause segfaults.
|
29
|
+
* Added the isa_list, hw_provider, hw_serial_number, srpc_domain and
|
30
|
+
dhcp_cache methods for Solaris.
|
31
|
+
* Added install.rb program for Windows, and modified extconf.rb to only run on
|
32
|
+
non-Windows systems.
|
33
|
+
* The 'examples' directory has been moved to the toplevel directory.
|
34
|
+
* Removed the INSTALL file. That information is now included in the README.
|
35
|
+
* Documentation updates.
|
36
|
+
|
37
|
+
== 0.6.1 - 25-Apr-2004
|
38
|
+
* Simplified extconf.rb script and installation instructions.
|
39
|
+
* Combined three test scripts into a single test script.
|
40
|
+
* Warranty information added.
|
41
|
+
|
42
|
+
== 0.6.0 - 25-Jun-2003
|
43
|
+
* Added HP-UX support, including the id() class method (HP-UX only)
|
44
|
+
* Fixed minor bug in extconf.rb (forgot 'require ftools' at top)
|
45
|
+
* Added HP-UX specific tests and support
|
46
|
+
* Made test.rb friendlier for folks without TestUnit installed
|
47
|
+
|
48
|
+
== 0.5.0 - 16-Jun-2003
|
49
|
+
* Added OS X support, including the "model" method. Thanks to Mike Hall
|
50
|
+
for the patch
|
51
|
+
* Removed VERSION() class method. Use the constant instead
|
52
|
+
* Moved rd documentation to its own file (under /doc directory)
|
53
|
+
* Added a version.h file under 'lib' to store VERSION info for
|
54
|
+
all source files
|
55
|
+
* Modified extconf.rb file to handle OS X support. In addition, moved
|
56
|
+
test.rb into a static file under /test, instead of dynamically
|
57
|
+
generating it
|
58
|
+
* Fixed up test suite. Added OS X specific tests and support. Should now
|
59
|
+
work with TestUnit 0.1.6 or later
|
60
|
+
|
61
|
+
== 0.4.1 - 7-Feb-2003
|
62
|
+
* Fixed C89 issue (again) - thanks go to Daniel Zepeda for the spot
|
63
|
+
* Fixed bugs in extconf.rb file (rescue clause, ftools)
|
64
|
+
|
65
|
+
== 0.4.0 - 6-Feb-2003
|
66
|
+
* MS Windows support!
|
67
|
+
* Added a test suite and automatic test.rb creation
|
68
|
+
* Documentation additions/fixes
|
69
|
+
* Internal directory layout and filename changes (Changelog -> CHANGES)
|
70
|
+
|
71
|
+
== 0.3.3 - 6-Jan-2003
|
72
|
+
* Made the code C89 compliant for older compilers. Thanks to Paul Brannan
|
73
|
+
for teaching me how to fix this in general.
|
74
|
+
* Moved README to doc/uname.txt
|
75
|
+
* Created an INSTALL file
|
76
|
+
* Added a copyright notice
|
77
|
+
* Added a VERSION class method
|
78
|
+
* Changed tarball name to reflect RAA package name
|
79
|
+
* Minor doc changes
|
80
|
+
|
81
|
+
== 0.3.2 - 8-Aug-2002
|
82
|
+
* Changed the struct name returned by the 'uname()' method from
|
83
|
+
"Uname::UnameStruct" to just "UnameStruct". This was to make it
|
84
|
+
compliant with future versions of Ruby. The extra namespace was
|
85
|
+
redundant anyway.
|
86
|
+
* I include the documentation now, instead of making you install rd2 :)
|
87
|
+
|
88
|
+
== 0.3.1 - 22-Jul-2002
|
89
|
+
* Added the 'uname' class method, which returns a struct that contains all
|
90
|
+
of the uname information
|
91
|
+
* Added a test script. Do 'ruby test.rb' to run it.
|
92
|
+
* If rd2 is installed on your system, the documentation is automatically
|
93
|
+
generated for you.
|
94
|
+
* Moved html documentation to 'doc' directory.
|
95
|
+
* Changed version number style to be consistent with other 'Sys' modules
|
96
|
+
* Now installs into 'Sys-Uname-x.x.x' directory (instead of just 'Uname')
|
97
|
+
|
98
|
+
== 0.03 - 6-June-2002
|
99
|
+
* rd style documentation now inline
|
100
|
+
* README.html is now uname.html - created via rdtool
|
101
|
+
* The 'platform()' and 'architecture()' methods have been added for Solaris
|
102
|
+
* You can now do an 'include Sys' to shorten your syntax
|
103
|
+
* The whole 'Sys' class has been removed. Delete your sys.so file if you
|
104
|
+
installed a previous version of Sys-Uname
|
105
|
+
|
106
|
+
== 0.02 - 3-June-2002
|
107
|
+
* Potentially fatal memory problems corrected.
|
108
|
+
* Should now build with C++ as well
|
109
|
+
* Thanks to Mike Hall for both the spot and the fix
|
110
|
+
* Added a Changelog file
|
111
|
+
* Added a README.html file
|
112
|
+
* Added a Manifest file
|
113
|
+
|
114
|
+
== 0.01 - 31-May-2002
|
115
|
+
* Initial release (unannounced)
|
data/MANIFEST
ADDED
data/README
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= Prerequisites
|
2
|
+
=== Unix
|
3
|
+
Ruby 1.8.0 or later.
|
4
|
+
=== MS Windows
|
5
|
+
Ruby 1.8.2 or later. Earlier versions segfault due to OLE bugs.
|
6
|
+
Active WMI service (normally on by default).
|
7
|
+
|
8
|
+
= Installation
|
9
|
+
=== Unix
|
10
|
+
ruby extconf.rb
|
11
|
+
make
|
12
|
+
ruby test/tc_uname.rb (optional)
|
13
|
+
make site-install
|
14
|
+
=== MS Windows
|
15
|
+
ruby test\tc_uname.rb (optional)
|
16
|
+
ruby install.rb
|
17
|
+
|
18
|
+
= Synopsis
|
19
|
+
require 'sys/uname'
|
20
|
+
include Sys
|
21
|
+
|
22
|
+
p Uname.uname
|
23
|
+
|
24
|
+
= Solaris Notes
|
25
|
+
Folks building this package on SunOS get two extra methods: architecture()
|
26
|
+
and platform()
|
27
|
+
|
28
|
+
= OS X Notes
|
29
|
+
OS X users get the extra method "model()".
|
30
|
+
|
31
|
+
= HP-UX Notes
|
32
|
+
HP-UX users get the extra method "id()". This is actually a String, not
|
33
|
+
a Fixnum, because that's how it's defined in the utsname struct.
|
34
|
+
|
35
|
+
= MS Windows Notes
|
36
|
+
The C version for Windows has been completely scrapped in favor of an OLE
|
37
|
+
plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
|
38
|
+
the Win32_OperatingSystem class for a complete list of what each of the
|
39
|
+
UnameStruct members mean.
|
40
|
+
|
41
|
+
= Documentation
|
42
|
+
For more details, see the 'uname.txt' file under the 'doc' directory.
|
data/doc/uname.txt
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
== Description
|
2
|
+
A Ruby interface to the 'uname' command.
|
3
|
+
|
4
|
+
== Synopsis
|
5
|
+
require 'sys/uname'
|
6
|
+
include Sys
|
7
|
+
|
8
|
+
puts Uname.nodename
|
9
|
+
puts Uname.version
|
10
|
+
puts Uname.sysname
|
11
|
+
puts Uname.machine
|
12
|
+
puts Uname.release
|
13
|
+
|
14
|
+
p Uname.uname
|
15
|
+
|
16
|
+
== Constants
|
17
|
+
VERSION
|
18
|
+
The current version number of sys-uname.
|
19
|
+
|
20
|
+
== Class Methods
|
21
|
+
Uname.sysname
|
22
|
+
Returns the operating system name. e.g. "SunOS"
|
23
|
+
|
24
|
+
Uname.nodename
|
25
|
+
Returns the nodename. This is usually, but not necessarily, the
|
26
|
+
same as the system's hostname.
|
27
|
+
|
28
|
+
You cannot currently set the nodename (root or otherwise). This may
|
29
|
+
be added in a future release.
|
30
|
+
|
31
|
+
Uname.machine
|
32
|
+
Returns the machine hardware type. e.g. "i686"
|
33
|
+
|
34
|
+
Uname.version
|
35
|
+
Returns the operating system version. e.g. "5.8". In the case of MS
|
36
|
+
Windows, it returns the version plus patch information, separated by
|
37
|
+
a hyphen, e.g. "2915-Service Pack 2".
|
38
|
+
|
39
|
+
Uname.release
|
40
|
+
Returns the operating system release. e.g. "2.2.16-3"
|
41
|
+
|
42
|
+
Uname.uname
|
43
|
+
Returns a struct of type UnameStruct that contains sysname, nodename,
|
44
|
+
machine, version, and release. On Solaris, it will also include
|
45
|
+
architecture and platform. On HP-UX, it will also include id.
|
46
|
+
|
47
|
+
MS Windows - there are many more, and different, fields in the struct.
|
48
|
+
Please see the MSDN documenation for a complete explanation of what
|
49
|
+
each of these members mean.
|
50
|
+
|
51
|
+
== Solaris Only
|
52
|
+
Uname.architecture
|
53
|
+
Returns the instruction set architecture. e.g. "sparc"
|
54
|
+
|
55
|
+
Uname.platform
|
56
|
+
Returns the platform identifier. e.g. "SUNW,Sun-Blade-100"
|
57
|
+
|
58
|
+
Uname.isa_list
|
59
|
+
Returns a space separated string containing a list of all variant
|
60
|
+
instruction set architectures executable on the current system.
|
61
|
+
|
62
|
+
They are listed in order of performance, from best to worst.
|
63
|
+
|
64
|
+
Uname.hw_provider
|
65
|
+
Returns the name of the hardware manufacturer.
|
66
|
+
|
67
|
+
Uname.hw_serial_number
|
68
|
+
Returns the ASCII representation of the hardware-specific serial number
|
69
|
+
of the machine that executes the function.
|
70
|
+
|
71
|
+
Uname.srpc_domain
|
72
|
+
Returns the name of the Secure Remote Procedure Call domain, if any.
|
73
|
+
|
74
|
+
Uname.dhcp_cache
|
75
|
+
Returns a hexidecimal encoding, in String form, of the name of the
|
76
|
+
interface configured by boot(1M) followed by the DHCPACK reply from
|
77
|
+
the server.
|
78
|
+
|
79
|
+
== OS X Only
|
80
|
+
Uname.model
|
81
|
+
Returns the model type, e.g. "PowerBook5,1"
|
82
|
+
|
83
|
+
== HP-UX Only
|
84
|
+
Uname.id
|
85
|
+
Returns the id number, e.g. 234233587. This is a String, not a Fixnum.
|
86
|
+
|
87
|
+
== Notes
|
88
|
+
Not all of the information that you might be used to seeing with
|
89
|
+
a 'uname -a' is available. This may be added in future releases,
|
90
|
+
but since different implementations provide different information
|
91
|
+
(via different header files) it will be a bit of a pain.
|
92
|
+
|
93
|
+
Windows users - please see the MSDN documentation for the
|
94
|
+
Win32_OperatingSystem class for a complete list of what each of the
|
95
|
+
UnameStruct members mean.
|
96
|
+
|
97
|
+
== Known Bugs
|
98
|
+
None that I'm aware of. Please log any bugs on the project page at
|
99
|
+
http://www.rubyforge.org/projects/sysutils.
|
100
|
+
|
101
|
+
== Future Plans
|
102
|
+
Add additional info for Linux, Solaris, BSD.
|
103
|
+
|
104
|
+
== License
|
105
|
+
Ruby's
|
106
|
+
|
107
|
+
== Copyright
|
108
|
+
(C) 2002-2006 Daniel J. Berger
|
109
|
+
All Rights Reserved
|
110
|
+
|
111
|
+
== Warranty
|
112
|
+
This package is provided "as is" and without any express or
|
113
|
+
implied warranties, including, without limitation, the implied
|
114
|
+
warranties of merchantability and fitness for a particular purpose.
|
115
|
+
|
116
|
+
== Author
|
117
|
+
Daniel Berger
|
118
|
+
djberg96 at gmail dot com
|
119
|
+
imperator on IRC (Freenode)
|
120
|
+
|
121
|
+
== See Also
|
122
|
+
uname(1) for unix, or WMI for MS Windows.
|
data/install.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
###############################################
|
2
|
+
# install.rb
|
3
|
+
#
|
4
|
+
# This is used for MS Windows only.
|
5
|
+
###############################################
|
6
|
+
require "ftools"
|
7
|
+
require "rbconfig"
|
8
|
+
include Config
|
9
|
+
|
10
|
+
unless RUBY_PLATFORM.match('mswin')
|
11
|
+
STDERR.puts "Run 'ruby extconf.rb; make; make site-install' instead"
|
12
|
+
STDERR.puts "Exiting..."
|
13
|
+
end
|
14
|
+
|
15
|
+
sitelibdir = CONFIG["sitelibdir"]
|
16
|
+
file = nil
|
17
|
+
|
18
|
+
file = "lib/sys/uname.rb"
|
19
|
+
install_dir = sitelibdir + "/sys"
|
20
|
+
|
21
|
+
unless File.exist?(install_dir)
|
22
|
+
begin
|
23
|
+
Dir.mkdir(install_dir)
|
24
|
+
rescue Exception => e
|
25
|
+
STDERR.puts "Unable to create #{install_dir}: #{e}"
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
File.copy(file, install_dir, true)
|
data/lib/sys/uname.rb
ADDED
@@ -0,0 +1,464 @@
|
|
1
|
+
require 'win32ole'
|
2
|
+
require 'socket'
|
3
|
+
require 'parsedate'
|
4
|
+
|
5
|
+
module Sys
|
6
|
+
# This is the error raised if any of the Sys::Uname methods should fail.
|
7
|
+
class UnameError < StandardError; end
|
8
|
+
|
9
|
+
# An interface for returning uname (platform) information.
|
10
|
+
class Uname
|
11
|
+
VERSION = '0.7.4'
|
12
|
+
|
13
|
+
fields = %w/
|
14
|
+
boot_device
|
15
|
+
build_number
|
16
|
+
build_type
|
17
|
+
caption
|
18
|
+
code_set
|
19
|
+
country_code
|
20
|
+
creation_class_name
|
21
|
+
cscreation_class_name
|
22
|
+
csd_version
|
23
|
+
cs_name
|
24
|
+
current_time_zone
|
25
|
+
debug
|
26
|
+
description
|
27
|
+
distributed
|
28
|
+
foreground_application_boost
|
29
|
+
free_physical_memory
|
30
|
+
free_space_in_paging_files
|
31
|
+
free_virtual_memory
|
32
|
+
install_date
|
33
|
+
last_bootup_time
|
34
|
+
local_date_time
|
35
|
+
locale
|
36
|
+
manufacturer
|
37
|
+
max_number_of_processes
|
38
|
+
max_process_memory_size
|
39
|
+
name
|
40
|
+
number_of_licensed_users
|
41
|
+
number_of_processes
|
42
|
+
number_of_users
|
43
|
+
organization
|
44
|
+
os_language
|
45
|
+
os_product_suite
|
46
|
+
os_type
|
47
|
+
other_type_description
|
48
|
+
plus_product_id
|
49
|
+
plus_version_number
|
50
|
+
primary
|
51
|
+
quantum_length
|
52
|
+
quantum_type
|
53
|
+
registered_user
|
54
|
+
serial_number
|
55
|
+
service_pack_major_version
|
56
|
+
service_pack_minor_version
|
57
|
+
size_stored_in_paging_files
|
58
|
+
status
|
59
|
+
system_device
|
60
|
+
system_directory
|
61
|
+
total_swap_space_size
|
62
|
+
total_virtual_memory_size
|
63
|
+
total_visible_memory_size
|
64
|
+
version
|
65
|
+
windows_directory
|
66
|
+
/
|
67
|
+
|
68
|
+
UnameStruct = Struct.new("UnameStruct", *fields)
|
69
|
+
|
70
|
+
#########################################################################
|
71
|
+
# The instance name is unpredictable, so we have to resort to using
|
72
|
+
# the 'InstancesOf' method to get the data we need, rather than
|
73
|
+
# including it as part of the connection.
|
74
|
+
#########################################################################
|
75
|
+
|
76
|
+
# Returns the version plus patch information of the operating system,
|
77
|
+
# separated by a hyphen, e.g. "2915-Service Pack 2".
|
78
|
+
#
|
79
|
+
def self.version(host=Socket.gethostname)
|
80
|
+
cs = "winmgmts://#{host}/root/cimv2"
|
81
|
+
begin
|
82
|
+
wmi = WIN32OLE.connect(cs)
|
83
|
+
rescue WIN32OLERuntimeError => e
|
84
|
+
raise UnameError, e
|
85
|
+
else
|
86
|
+
query = "select * from Win32_OperatingSystem"
|
87
|
+
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
88
|
+
str = "#{ole.Version} #{ole.BuildNumber}-"
|
89
|
+
str << "#{ole.ServicePackMajorVersion}"
|
90
|
+
return str
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns the operating system name, e.g. "Microsoft Windows XP Home"
|
96
|
+
#
|
97
|
+
def self.sysname(host=Socket.gethostname)
|
98
|
+
cs = "winmgmts:{impersonationLevel=impersonate,(security)}"
|
99
|
+
cs << "//#{host}/root/cimv2"
|
100
|
+
begin
|
101
|
+
wmi = WIN32OLE.connect(cs)
|
102
|
+
rescue WIN32OLERuntimeError => e
|
103
|
+
raise UnameError, e
|
104
|
+
else
|
105
|
+
query = "select * from Win32_OperatingSystem"
|
106
|
+
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
107
|
+
return ole.Caption
|
108
|
+
}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns the nodename. This is usually, but not necessarily, the
|
113
|
+
# same as the system's hostname.
|
114
|
+
#
|
115
|
+
def self.nodename(host=Socket.gethostname)
|
116
|
+
cs = "winmgmts:{impersonationLevel=impersonate,(security)}"
|
117
|
+
cs << "//#{host}/root/cimv2"
|
118
|
+
begin
|
119
|
+
wmi = WIN32OLE.connect(cs)
|
120
|
+
rescue WIN32OLERuntimeError => e
|
121
|
+
raise UnameError, e
|
122
|
+
else
|
123
|
+
query = "select * from Win32_OperatingSystem"
|
124
|
+
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
125
|
+
return ole.CSName
|
126
|
+
}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# Returns the machine hardware type. e.g. "i686".
|
131
|
+
#--
|
132
|
+
# This may or may not return the expected value because some CPU types
|
133
|
+
# were unknown to the OS when the OS was originally released. It
|
134
|
+
# appears that MS doesn't necessarily patch this, either.
|
135
|
+
#
|
136
|
+
def self.machine(cpu_num=0, host=Socket.gethostname)
|
137
|
+
cs = "winmgmts:{impersonationLevel=impersonate,(security)}"
|
138
|
+
cs << "//#{host}/root/cimv2:Win32_Processor='cpu#{cpu_num}'"
|
139
|
+
begin
|
140
|
+
wmi = WIN32OLE.connect(cs)
|
141
|
+
rescue WIN32OLERuntimeError => e
|
142
|
+
raise UnameError, e
|
143
|
+
else
|
144
|
+
# Convert a family number into the equivalent string
|
145
|
+
case wmi.Family
|
146
|
+
when 1
|
147
|
+
return "Other"
|
148
|
+
when 2
|
149
|
+
return "Unknown"
|
150
|
+
when 3
|
151
|
+
return "8086"
|
152
|
+
when 4
|
153
|
+
return "80286"
|
154
|
+
when 5
|
155
|
+
return "80386"
|
156
|
+
when 6
|
157
|
+
return "80486"
|
158
|
+
when 7
|
159
|
+
return "8087"
|
160
|
+
when 8
|
161
|
+
return "80287"
|
162
|
+
when 9
|
163
|
+
return "80387"
|
164
|
+
when 10
|
165
|
+
return "80487"
|
166
|
+
when 11
|
167
|
+
return "Pentium brand"
|
168
|
+
when 12
|
169
|
+
return "Pentium Pro"
|
170
|
+
when 13
|
171
|
+
return "Pentium II"
|
172
|
+
when 14
|
173
|
+
return "Pentium processor with MMX technology"
|
174
|
+
when 15
|
175
|
+
return "Celeron"
|
176
|
+
when 16
|
177
|
+
return "Pentium II Xeon"
|
178
|
+
when 17
|
179
|
+
return "Pentium III"
|
180
|
+
when 18
|
181
|
+
return "M1 Family"
|
182
|
+
when 19
|
183
|
+
return "M2 Family"
|
184
|
+
when 24
|
185
|
+
return "K5 Family"
|
186
|
+
when 25
|
187
|
+
return "K6 Family"
|
188
|
+
when 26
|
189
|
+
return "K6-2"
|
190
|
+
when 27
|
191
|
+
return "K6-3"
|
192
|
+
when 28
|
193
|
+
return "AMD Athlon Processor Family"
|
194
|
+
when 29
|
195
|
+
return "AMD Duron Processor"
|
196
|
+
when 30
|
197
|
+
return "AMD2900 Family"
|
198
|
+
when 31
|
199
|
+
return "K6-2+"
|
200
|
+
when 32
|
201
|
+
return "Power PC Family"
|
202
|
+
when 33
|
203
|
+
return "Power PC 601"
|
204
|
+
when 34
|
205
|
+
return "Power PC 603"
|
206
|
+
when 35
|
207
|
+
return "Power PC 603+"
|
208
|
+
when 36
|
209
|
+
return "Power PC 604"
|
210
|
+
when 37
|
211
|
+
return "Power PC 620"
|
212
|
+
when 38
|
213
|
+
return "Power PC X704"
|
214
|
+
when 39
|
215
|
+
return "Power PC 750"
|
216
|
+
when 48
|
217
|
+
return "Alpha Family"
|
218
|
+
when 49
|
219
|
+
return "Alpha 21064"
|
220
|
+
when 50
|
221
|
+
return "Alpha 21066"
|
222
|
+
when 51
|
223
|
+
return "Alpha 21164"
|
224
|
+
when 52
|
225
|
+
return "Alpha 21164PC"
|
226
|
+
when 53
|
227
|
+
return "Alpha 21164a"
|
228
|
+
when 54
|
229
|
+
return "Alpha 21264"
|
230
|
+
when 55
|
231
|
+
return "Alpha 21364"
|
232
|
+
when 64
|
233
|
+
return "MIPS Family"
|
234
|
+
when 65
|
235
|
+
return "MIPS R4000"
|
236
|
+
when 66
|
237
|
+
return "MIPS R4200"
|
238
|
+
when 67
|
239
|
+
return "MIPS R4400"
|
240
|
+
when 68
|
241
|
+
return "MIPS R4600"
|
242
|
+
when 69
|
243
|
+
return "MIPS R10000"
|
244
|
+
when 80
|
245
|
+
return "SPARC Family"
|
246
|
+
when 81
|
247
|
+
return "SuperSPARC"
|
248
|
+
when 82
|
249
|
+
return "microSPARC II"
|
250
|
+
when 83
|
251
|
+
return "microSPARC IIep"
|
252
|
+
when 84
|
253
|
+
return "UltraSPARC"
|
254
|
+
when 85
|
255
|
+
return "UltraSPARC II"
|
256
|
+
when 86
|
257
|
+
return "UltraSPARC IIi"
|
258
|
+
when 87
|
259
|
+
return "UltraSPARC III"
|
260
|
+
when 88
|
261
|
+
return "UltraSPARC IIIi"
|
262
|
+
when 96
|
263
|
+
return "68040"
|
264
|
+
when 97
|
265
|
+
return "68xxx Family"
|
266
|
+
when 98
|
267
|
+
return "68000"
|
268
|
+
when 99
|
269
|
+
return "68010"
|
270
|
+
when 100
|
271
|
+
return "68020"
|
272
|
+
when 101
|
273
|
+
return "68030"
|
274
|
+
when 112
|
275
|
+
return "Hobbit Family"
|
276
|
+
when 120
|
277
|
+
return "Crusoe TM5000 Family"
|
278
|
+
when 121
|
279
|
+
return "Crusoe TM3000 Family"
|
280
|
+
when 128
|
281
|
+
return "Weitek"
|
282
|
+
when 130
|
283
|
+
return "Itanium Processor"
|
284
|
+
when 144
|
285
|
+
return "PA-RISC Family"
|
286
|
+
when 145
|
287
|
+
return "PA-RISC 8500"
|
288
|
+
when 146
|
289
|
+
return "PA-RISC 8000"
|
290
|
+
when 147
|
291
|
+
return "PA-RISC 7300LC"
|
292
|
+
when 148
|
293
|
+
return "PA-RISC 7200"
|
294
|
+
when 149
|
295
|
+
return "PA-RISC 7100LC"
|
296
|
+
when 150
|
297
|
+
return "PA-RISC 7100"
|
298
|
+
when 160
|
299
|
+
return "V30 Family"
|
300
|
+
when 176
|
301
|
+
return "Pentium III Xeon�"
|
302
|
+
when 177
|
303
|
+
return "Pentium III Processor with Intel SpeedStep Technology"
|
304
|
+
when 178
|
305
|
+
return "Pentium 4"
|
306
|
+
when 179
|
307
|
+
return "Intel Xeon�"
|
308
|
+
when 180
|
309
|
+
return "AS400 Family"
|
310
|
+
when 181
|
311
|
+
return "Intel Xeon processor MP"
|
312
|
+
when 182
|
313
|
+
return "AMD AthlonXP Family"
|
314
|
+
when 183
|
315
|
+
return "AMD AthlonMP Family"
|
316
|
+
when 184
|
317
|
+
return "Intel Itanium 2"
|
318
|
+
when 185
|
319
|
+
return "AMD Opteron� Family"
|
320
|
+
when 190
|
321
|
+
return "K7"
|
322
|
+
when 200
|
323
|
+
return "IBM390 Family"
|
324
|
+
when 201
|
325
|
+
return "G4"
|
326
|
+
when 202
|
327
|
+
return "G5"
|
328
|
+
when 250
|
329
|
+
return "i860"
|
330
|
+
when 251
|
331
|
+
return "i960"
|
332
|
+
when 260
|
333
|
+
return "SH-3"
|
334
|
+
when 261
|
335
|
+
return "SH-4"
|
336
|
+
when 280
|
337
|
+
return "ARM"
|
338
|
+
when 281
|
339
|
+
return "StrongARM"
|
340
|
+
when 300
|
341
|
+
return "6x86"
|
342
|
+
when 301
|
343
|
+
return "MediaGX"
|
344
|
+
when 302
|
345
|
+
return "MII"
|
346
|
+
when 320
|
347
|
+
return "WinChip"
|
348
|
+
when 350
|
349
|
+
return "DSP"
|
350
|
+
when 500
|
351
|
+
return "Video Processor"
|
352
|
+
else
|
353
|
+
return "Unknown"
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
# Returns the release number, e.g. 5.1.2600.
|
359
|
+
#
|
360
|
+
def self.release(host=Socket.gethostname)
|
361
|
+
cs = "winmgmts://#{host}/root/cimv2"
|
362
|
+
begin
|
363
|
+
wmi = WIN32OLE.connect(cs)
|
364
|
+
rescue WIN32OLERuntimeError => e
|
365
|
+
raise UnameError, e
|
366
|
+
else
|
367
|
+
query = "select * from Win32_OperatingSystem"
|
368
|
+
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
369
|
+
return ole.Version
|
370
|
+
}
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
# Returns a struct of type UnameStruct that contains sysname, nodename,
|
375
|
+
# machine, version, and release, as well as a plethora of other fields.
|
376
|
+
# Please see the MSDN documentation for what each of these fields mean.
|
377
|
+
#
|
378
|
+
def self.uname(host=Socket.gethostname)
|
379
|
+
cs = "winmgmts://#{host}/root/cimv2"
|
380
|
+
begin
|
381
|
+
wmi = WIN32OLE.connect(cs)
|
382
|
+
rescue WIN32OLERuntimeError => e
|
383
|
+
raise UnameError, e
|
384
|
+
else
|
385
|
+
query = "select * from Win32_OperatingSystem"
|
386
|
+
wmi.InstancesOf("Win32_OperatingSystem").each{ |os|
|
387
|
+
return UnameStruct.new(
|
388
|
+
os.BootDevice,
|
389
|
+
os.BuildNumber,
|
390
|
+
os.BuildType,
|
391
|
+
os.Caption,
|
392
|
+
os.CodeSet,
|
393
|
+
os.CountryCode,
|
394
|
+
os.CreationClassName,
|
395
|
+
os.CSCreationClassName,
|
396
|
+
os.CSDVersion,
|
397
|
+
os.CSName,
|
398
|
+
os.CurrentTimeZone,
|
399
|
+
os.Debug,
|
400
|
+
os.Description,
|
401
|
+
os.Distributed,
|
402
|
+
os.ForegroundApplicationBoost,
|
403
|
+
self.convert(os.FreePhysicalMemory),
|
404
|
+
self.convert(os.FreeSpaceInPagingFiles),
|
405
|
+
self.convert(os.FreeVirtualMemory),
|
406
|
+
self.parse_ms_date(os.InstallDate),
|
407
|
+
self.parse_ms_date(os.LastBootUpTime),
|
408
|
+
self.parse_ms_date(os.LocalDateTime),
|
409
|
+
os.Locale,
|
410
|
+
os.Manufacturer,
|
411
|
+
os.MaxNumberOfProcesses,
|
412
|
+
self.convert(os.MaxProcessMemorySize),
|
413
|
+
os.Name,
|
414
|
+
os.NumberOfLicensedUsers,
|
415
|
+
os.NumberOfProcesses,
|
416
|
+
os.NumberOfUsers,
|
417
|
+
os.Organization,
|
418
|
+
os.OSLanguage,
|
419
|
+
os.OSProductSuite,
|
420
|
+
os.OSType,
|
421
|
+
os.OtherTypeDescription,
|
422
|
+
os.PlusProductID,
|
423
|
+
os.PlusVersionNumber,
|
424
|
+
os.Primary,
|
425
|
+
os.QuantumLength,
|
426
|
+
os.QuantumType,
|
427
|
+
os.RegisteredUser,
|
428
|
+
os.SerialNumber,
|
429
|
+
os.ServicePackMajorVersion,
|
430
|
+
os.ServicePackMinorVersion,
|
431
|
+
self.convert(os.SizeStoredInPagingFiles),
|
432
|
+
os.Status,
|
433
|
+
os.SystemDevice,
|
434
|
+
os.SystemDirectory,
|
435
|
+
self.convert(os.TotalSwapSpaceSize),
|
436
|
+
self.convert(os.TotalVirtualMemorySize),
|
437
|
+
self.convert(os.TotalVisibleMemorySize),
|
438
|
+
os.Version,
|
439
|
+
os.WindowsDirectory
|
440
|
+
)
|
441
|
+
}
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
private
|
446
|
+
|
447
|
+
# Converts a string in the format '20040703074625.015625-360' into a
|
448
|
+
# Ruby Time object.
|
449
|
+
#
|
450
|
+
def self.parse_ms_date(str)
|
451
|
+
return if str.nil?
|
452
|
+
parsed = ParseDate.parsedate(str)
|
453
|
+
return Time.mktime(*parsed)
|
454
|
+
end
|
455
|
+
|
456
|
+
# There is a bug in win32ole where uint64 types are returned as a
|
457
|
+
# String rather than a Fixnum/Bignum. This deals with that for now.
|
458
|
+
#
|
459
|
+
def self.convert(str)
|
460
|
+
return nil if str.nil? # Don't turn nil into 0
|
461
|
+
return str.to_i
|
462
|
+
end
|
463
|
+
end
|
464
|
+
end
|