sys-cpu 0.6.1-x86-linux → 0.6.2-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +13 -0
- data/MANIFEST +11 -10
- data/README +24 -24
- data/Rakefile +95 -0
- data/doc/bsd.txt +7 -25
- data/doc/hpux.txt +7 -28
- data/doc/sunos.txt +7 -29
- data/doc/windows.txt +8 -30
- 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 +25 -0
- data/examples/example_sys_cpu_sunos.rb +21 -0
- data/examples/example_sys_cpu_windows.rb +24 -0
- data/ext/bsd/bsd.c +294 -0
- data/ext/extconf.rb +25 -0
- data/ext/hpux/hpux.c +219 -0
- data/ext/sunos/sunos.c +281 -0
- data/ext/version.h +2 -0
- data/install.rb +84 -0
- data/lib/linux/sys/cpu.rb +122 -0
- data/lib/windows/sys/cpu.rb +784 -0
- data/sys-cpu.gemspec +47 -0
- data/test/test_sys_cpu.rb +23 -0
- data/test/{tc_bsd.rb → test_sys_cpu_bsd.rb} +33 -12
- data/test/{tc_hpux.rb → test_sys_cpu_hpux.rb} +16 -13
- data/test/test_sys_cpu_linux.rb +34 -0
- data/test/{tc_sunos.rb → test_sys_cpu_sunos.rb} +10 -8
- data/test/{tc_version.rb → test_sys_cpu_version.rb} +5 -2
- data/test/{tc_windows.rb → test_sys_cpu_windows.rb} +25 -22
- metadata +47 -21
- data/lib/sys/cpu.rb +0 -105
- data/test/tc_cpu.rb +0 -17
- data/test/tc_linux.rb +0 -34
data/CHANGES
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
== 0.6.2 - ???
|
2
|
+
* Fixed a bug in the cpu_freq function (which would only be noticed on
|
3
|
+
certain platforms in cases where the CPU.freq method failed). Thanks
|
4
|
+
go to Edho P Arief for the spot.
|
5
|
+
* Explicitly add sys/param.h on OpenBSD, and default to the HW_MODEL mib
|
6
|
+
because HW_MACHINE does not exist. Thanks go to Edho P Arief for the patch.
|
7
|
+
* Updated my support notes. In short I will support 1.8.6 and 1.9.x. I will
|
8
|
+
not support any 1.8.x branch later than 1.8.6.
|
9
|
+
* Removed redundant information in the various .txt files that is already
|
10
|
+
covered in the README file.
|
11
|
+
* Test files renamed.
|
12
|
+
* Added test-unit 2.x as a development dependency.
|
13
|
+
|
1
14
|
== 0.6.1 - 4-Jan-2009
|
2
15
|
* Fix for OS X 10.5.x. Thanks go to Victor Costan for the spot and the patch.
|
3
16
|
* Updated the gemspec and some other minor changes.
|
data/MANIFEST
CHANGED
@@ -9,11 +9,11 @@
|
|
9
9
|
* doc/linux.txt
|
10
10
|
* doc/sunos.txt
|
11
11
|
* doc/windows.txt
|
12
|
-
* examples/
|
13
|
-
* examples/
|
14
|
-
* examples/
|
15
|
-
* examples/
|
16
|
-
* examples/
|
12
|
+
* examples/example_sys_cpu_freebsd.rb
|
13
|
+
* examples/example_sys_cpu_hpux.rb
|
14
|
+
* examples/example_sys_cpu_linux.rb
|
15
|
+
* examples/example_sys_cpu_sunos.rb
|
16
|
+
* examples/example_sys_cpu_windows.rb
|
17
17
|
* ext/extconf.rb
|
18
18
|
* ext/version.h
|
19
19
|
* ext/bsd/bsd.c
|
@@ -21,8 +21,9 @@
|
|
21
21
|
* ext/sunos/sunos.c
|
22
22
|
* lib/sys/linux.rb
|
23
23
|
* lib/sys/windows.rb
|
24
|
-
* test/
|
25
|
-
* test/
|
26
|
-
* test/
|
27
|
-
* test/
|
28
|
-
* test/
|
24
|
+
* test/test_sys_cpu.rb
|
25
|
+
* test/test_sys_cpu_bsd.rb
|
26
|
+
* test/test_sys_cpu_hpux.rb
|
27
|
+
* test/test_sys_cpu_sunos.rb
|
28
|
+
* test/test_sys_cpu_linux.rb
|
29
|
+
* test/test_sys_cpu_windows.rb
|
data/README
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
-
|
1
|
+
== Description
|
2
2
|
A Ruby interface for getting cpu information.
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
rake install (non-gem)
|
8
|
-
== Gem installation
|
9
|
-
rake test (optional)
|
10
|
-
ruby sys-cpu.gemspec
|
11
|
-
gem install sys-cpu-X.Y.Z.gem # where 'X.Y.Z' corresponds to the version.
|
4
|
+
== Installation
|
5
|
+
gem install sys-cpu
|
6
|
+
gem install sys-cpu --platform mswin32 # MS Windows
|
12
7
|
|
13
|
-
|
8
|
+
== Notes
|
14
9
|
=== All Platforms
|
15
10
|
As of version 0.5.0 Ruby 1.8.0 or later is required. It may work with
|
16
11
|
earlier versions, but I will not support it.
|
12
|
+
|
13
|
+
I do not support any Ruby 1.8.x branch after 1.8.6. It should work on those
|
14
|
+
versions of Ruby but if it breaks I'm not going to go out of my way to fix
|
15
|
+
it. I will, however, support the 1.9.x/2.x branch.
|
17
16
|
|
18
17
|
=== Solaris
|
19
18
|
Currently there is no 'processors()' iterative method for multi-cpu systems.
|
@@ -39,8 +38,8 @@
|
|
39
38
|
file after you run 'rake install' (via install.rb).
|
40
39
|
|
41
40
|
=== HP-UX
|
42
|
-
Unlike other platforms, you can get load averages for an individual cpu
|
43
|
-
multi-cpu systems
|
41
|
+
Unlike other platforms, you can get load averages for an individual cpu in
|
42
|
+
multi-cpu systems. See documentation for more details.
|
44
43
|
|
45
44
|
=== MS Windows
|
46
45
|
This is a pure Ruby implementation using the win32ole package + WMI. The C
|
@@ -51,29 +50,30 @@
|
|
51
50
|
is no longer any delay. Also, the 'processors' method has been
|
52
51
|
added and the 'supported' method has been dropped. See the documentation
|
53
52
|
for other changes.
|
53
|
+
|
54
|
+
== Acknowledgements
|
55
|
+
Thanks go to the MPlayer team for some source code that helped me on
|
56
|
+
certain versions of FreeBSD.
|
54
57
|
|
55
|
-
|
56
|
-
None that I'm aware of.
|
58
|
+
== Known Bugs
|
59
|
+
None that I'm aware of. Please report bugs on the project page at
|
57
60
|
http://www.rubyforge.org/projects/sysutils.
|
58
61
|
|
59
|
-
|
62
|
+
== Future Plans
|
60
63
|
Add iterative CPU.processors method.
|
61
64
|
Make CPU.freq work on OS X.
|
62
65
|
Add more information in general, such as what 'prtdiag' shows.
|
63
66
|
|
64
|
-
|
65
|
-
|
67
|
+
== License
|
68
|
+
Artistic 2.0
|
66
69
|
|
67
|
-
|
68
|
-
(C) 2003-
|
69
|
-
All Rights Reserved
|
70
|
+
== Copyright
|
71
|
+
(C) 2003-2009 Daniel J. Berger, All Rights Reserved
|
70
72
|
|
71
|
-
|
73
|
+
== Warranty
|
72
74
|
This package is provided "as is" and without any express or
|
73
75
|
implied warranties, including, without limitation, the implied
|
74
76
|
warranties of merchantability and fitness for a particular purpose.
|
75
77
|
|
76
|
-
|
78
|
+
== Author
|
77
79
|
Daniel J. Berger
|
78
|
-
djberg96 at nospam at gmail dot com
|
79
|
-
imperator on IRC (irc.freenode.net)
|
data/Rakefile
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
desc "Clean the build files for the sys-cpu source for UNIX systems"
|
7
|
+
task :clean do
|
8
|
+
FileUtils.rm_rf('sys') if File.exists?('sys')
|
9
|
+
FileUtils.rm_rf('lib/sys/cpu.rb') if File.exists?('lib/sys/cpu.rb')
|
10
|
+
Dir.chdir('ext') do
|
11
|
+
unless Config::CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|linux/i
|
12
|
+
FileUtils.rm_rf('sys') if File.exists?('sys')
|
13
|
+
FileUtils.rm_rf('cpu.c') if File.exists?('cpu.c')
|
14
|
+
build_file = 'cpu.' + Config::CONFIG['DLEXT']
|
15
|
+
sh 'make distclean' if File.exists?(build_file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Build the sys-cpu library on UNIX systems (but don't install it)"
|
21
|
+
task :build => [:clean] do
|
22
|
+
Dir.chdir('ext') do
|
23
|
+
unless Config::CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|linux/i
|
24
|
+
ruby 'extconf.rb'
|
25
|
+
sh 'make'
|
26
|
+
build_file = 'cpu.' + Config::CONFIG['DLEXT']
|
27
|
+
Dir.mkdir('sys') unless File.exists?('sys')
|
28
|
+
FileUtils.cp(build_file, 'sys')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Build the gem."
|
34
|
+
task :gem do
|
35
|
+
spec = eval(IO.read('sys-cpu.gemspec'))
|
36
|
+
Gem::Builder.new(spec).build
|
37
|
+
end
|
38
|
+
|
39
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|linux/i
|
40
|
+
desc "Install the sys-cpu library"
|
41
|
+
task :install do
|
42
|
+
sh 'ruby install.rb'
|
43
|
+
end
|
44
|
+
else
|
45
|
+
desc "Install the sys-cpu library"
|
46
|
+
task :install => [:build] do
|
47
|
+
Dir.chdir('ext') do
|
48
|
+
sh 'make install'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Run the example program"
|
54
|
+
task :example => [:build] do
|
55
|
+
Dir.mkdir('sys') unless File.exists?('sys')
|
56
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|linux/i
|
57
|
+
if Config::CONFIG['host_os'].match('linux')
|
58
|
+
FileUtils.cp('lib/sys/linux.rb', 'sys/cpu.rb')
|
59
|
+
else
|
60
|
+
FileUtils.cp('lib/sys/windows.rb', 'sys/cpu.rb')
|
61
|
+
end
|
62
|
+
else
|
63
|
+
build_file = 'ext/cpu.' + Config::CONFIG['DLEXT']
|
64
|
+
FileUtils.cp(build_file, 'sys')
|
65
|
+
end
|
66
|
+
|
67
|
+
case Config::CONFIG['host_os']
|
68
|
+
when /bsd|darwin|mach|osx/i
|
69
|
+
file = 'examples/test_cpu_bsd.rb'
|
70
|
+
when /hpux/i
|
71
|
+
file = 'examples/test_cpu_hpux.rb'
|
72
|
+
when /linux/i
|
73
|
+
file = 'examples/test_cpu_linux.rb'
|
74
|
+
when /sunos|solaris/i
|
75
|
+
file = 'examples/test_cpu_sunos.rb'
|
76
|
+
when /mswin|win32|cygwin|mingw|dos/i
|
77
|
+
file = 'examples/test_cpu_windows.rb'
|
78
|
+
end
|
79
|
+
sh "ruby -I. -Iext -Ilib #{file}"
|
80
|
+
end
|
81
|
+
|
82
|
+
Rake::TestTask.new do |t|
|
83
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows/i
|
84
|
+
t.libs << 'lib/windows'
|
85
|
+
elsif Config::CONFIG['host_os'] =~ /linux/i
|
86
|
+
t.libs << 'lib/linux'
|
87
|
+
else
|
88
|
+
task :test => :build
|
89
|
+
t.libs << 'ext'
|
90
|
+
t.libs.delete('lib')
|
91
|
+
end
|
92
|
+
|
93
|
+
t.libs << 'test'
|
94
|
+
t.test_files = FileList['test/test_sys_cpu.rb']
|
95
|
+
end
|
data/doc/bsd.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
== Description
|
2
2
|
Sys::CPU - An interface for various cpu statistics
|
3
3
|
|
4
|
-
|
4
|
+
== Synopsis
|
5
5
|
require "sys/cpu"
|
6
6
|
include Sys
|
7
7
|
|
@@ -13,11 +13,11 @@
|
|
13
13
|
puts "CPU model: " + CPU.model
|
14
14
|
puts "Load averages: " + CPU.load_avg.join(", ")
|
15
15
|
|
16
|
-
|
16
|
+
== Constants
|
17
17
|
VERSION
|
18
18
|
Returns the current version number for this package.
|
19
19
|
|
20
|
-
|
20
|
+
== Class Methods
|
21
21
|
CPU.architecture
|
22
22
|
Returns the cpu's architecture.
|
23
23
|
|
@@ -40,28 +40,10 @@ CPU.model
|
|
40
40
|
CPU.num_cpu
|
41
41
|
Returns an integer indicating the number of cpu's on the system.
|
42
42
|
|
43
|
-
|
43
|
+
== Error Classes
|
44
44
|
CPU::Error < StandardError
|
45
45
|
Raised is response to internal function errors, usually relating to an
|
46
46
|
invalid cpu number.
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
http://www.rubyforge.org/projects/sysutils
|
51
|
-
|
52
|
-
= Copyright
|
53
|
-
(C) 2003-2007 Daniel J. Berger
|
54
|
-
All Rights Reserved
|
55
|
-
|
56
|
-
= Warranty
|
57
|
-
This package is provided "as is" and without any express or
|
58
|
-
implied warranties, including, without limitation, the implied
|
59
|
-
warranties of merchantability and fitness for a particular purpose.
|
60
|
-
|
61
|
-
= License
|
62
|
-
Ruby's
|
63
|
-
|
64
|
-
= Author
|
65
|
-
Daniel J. Berger
|
66
|
-
djberg96 at nospam at gmail dot com
|
67
|
-
imperator on IRC (Freenode)
|
48
|
+
== More Information
|
49
|
+
See the README file for more information.
|
data/doc/hpux.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
== Description
|
2
2
|
Sys::CPU - An interface for various cpu statistics
|
3
3
|
|
4
|
-
|
4
|
+
== Synopsis
|
5
5
|
require "sys/cpu"
|
6
6
|
include Sys
|
7
7
|
|
@@ -11,11 +11,11 @@
|
|
11
11
|
puts "Number of active cpu's: " + CPU.num_active_cpu.to_s
|
12
12
|
puts "Load averages: " + CPU.load_avg.join(", ")
|
13
13
|
|
14
|
-
|
14
|
+
== Constants
|
15
15
|
VERSION
|
16
16
|
Returns the current version number for this package.
|
17
17
|
|
18
|
-
|
18
|
+
== Class Methods
|
19
19
|
CPU.architecture
|
20
20
|
Returns the cpu architecture, e.g. PA RISC 1.2, etc.
|
21
21
|
|
@@ -45,31 +45,10 @@ CPU.num_cpu
|
|
45
45
|
CPU.num_active_cpu
|
46
46
|
Returns an integer indicating the number of active cpu's on the system.
|
47
47
|
|
48
|
-
|
48
|
+
== Error Classes
|
49
49
|
CPU::Error < StandardError
|
50
50
|
Raised is response to internal function errors, usually relating to an
|
51
51
|
invalid cpu number.
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
http://www.rubyforge.org/projects/sysutils
|
56
|
-
|
57
|
-
= Future Plans
|
58
|
-
Add cpu model and type
|
59
|
-
|
60
|
-
= Copyright
|
61
|
-
(C) 2003-2007 Daniel J. Berger
|
62
|
-
All Rights Reserved
|
63
|
-
|
64
|
-
= Warranty
|
65
|
-
This package is provided "as is" and without any express or
|
66
|
-
implied warranties, including, without limitation, the implied
|
67
|
-
warranties of merchantability and fitness for a particular purpose.
|
68
|
-
|
69
|
-
= License
|
70
|
-
Ruby's
|
71
|
-
|
72
|
-
= Author
|
73
|
-
Daniel J. Berger
|
74
|
-
djberg96 at nospam at gmail dot com
|
75
|
-
imperator on IRC (Freenode)
|
53
|
+
== More Information
|
54
|
+
See the README file for more information.
|
data/doc/sunos.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
== Description
|
2
2
|
Sys::CPU - An interface for various cpu statistics
|
3
3
|
|
4
|
-
|
4
|
+
== Synopsis
|
5
5
|
require "sys/cpu"
|
6
6
|
include Sys
|
7
7
|
|
@@ -14,11 +14,11 @@
|
|
14
14
|
puts "CPU model: " + CPU.model
|
15
15
|
puts "Load averages: " + CPU.load_avg.join(", ")
|
16
16
|
|
17
|
-
|
17
|
+
== Constants
|
18
18
|
VERSION
|
19
19
|
Returns the current version number for this package.
|
20
20
|
|
21
|
-
|
21
|
+
== Class Methods
|
22
22
|
CPU.freq(cpu_num=0)
|
23
23
|
Returns an integer indicating the speed (i.e. frequency in Mhz) of
|
24
24
|
'cpu_num', or CPU 0 if no number is provided.
|
@@ -47,32 +47,10 @@ CPU.num_cpu
|
|
47
47
|
CPU.state(cpu_num)
|
48
48
|
Returns a string indicating the cpu state of 'cpu_num'.
|
49
49
|
|
50
|
-
|
50
|
+
== Error Classes
|
51
51
|
CPU::Error < StandardError
|
52
52
|
Raised is response to internal function errors, usually relating to an
|
53
53
|
invalid cpu number.
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
http://www.rubyforge.org/projects/sysutils
|
58
|
-
|
59
|
-
= Future Plans
|
60
|
-
Add more information, such as what prtdiag shows.
|
61
|
-
Get the model() method to display more specific information.
|
62
|
-
|
63
|
-
= Copyright
|
64
|
-
(C) 2003-2007 Daniel J. Berger
|
65
|
-
All Rights Reserved
|
66
|
-
|
67
|
-
= Warranty
|
68
|
-
This package is provided "as is" and without any express or
|
69
|
-
implied warranties, including, without limitation, the implied
|
70
|
-
warranties of merchantability and fitness for a particular purpose.
|
71
|
-
|
72
|
-
= License
|
73
|
-
Ruby's
|
74
|
-
|
75
|
-
= Author
|
76
|
-
Daniel J. Berger
|
77
|
-
djberg96 at nospam at gmail dot com
|
78
|
-
imperator on IRC (Freenode)
|
55
|
+
== More Information
|
56
|
+
See the README file for more information.
|
data/doc/windows.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
== Description
|
2
2
|
Sys::CPU - An interface for various cpu statistics
|
3
3
|
|
4
|
-
|
4
|
+
== Synopsis
|
5
5
|
require "sys/cpu"
|
6
6
|
include Sys
|
7
7
|
|
@@ -18,11 +18,11 @@
|
|
18
18
|
puts "Model: " + CPU.model
|
19
19
|
puts "Architecture: " + CPU.architecture
|
20
20
|
|
21
|
-
|
21
|
+
== Constants
|
22
22
|
VERSION
|
23
23
|
Returns the current version number for this package.
|
24
24
|
|
25
|
-
|
25
|
+
== Class Methods
|
26
26
|
CPU.architecture(host=localhost)
|
27
27
|
Returns the architecture of the cpu, e.g. x86 Family 15 Model 2
|
28
28
|
|
@@ -101,13 +101,13 @@ CPU.processors(host=localhost){ |cpu| ... }
|
|
101
101
|
CPU.type(host=localhost)
|
102
102
|
Returns a string indicating the type of processor, e.g. GenuineIntel.
|
103
103
|
|
104
|
-
|
104
|
+
== Exception Classes
|
105
105
|
CPU::Error < StandardError
|
106
106
|
Raised is response to internal function errors, most likely to be raised
|
107
107
|
in the event that in invalid cpu number is provided for the 'freq'
|
108
108
|
method.
|
109
109
|
|
110
|
-
|
110
|
+
== Notes
|
111
111
|
Some of the CPUStruct members may be nil. As far as I can tell, this
|
112
112
|
means that Windows is unable to determine the value for the attribute due
|
113
113
|
to your BIOS and/or BIOS settings. There is nothing clear in the
|
@@ -126,27 +126,5 @@ CPU::Error < StandardError
|
|
126
126
|
frame) for a list of attributes and their meaning. Link courtesy of
|
127
127
|
tinyurl.com.
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
http://www.rubyforge.org/projects/sysutils
|
132
|
-
|
133
|
-
= Future Plans
|
134
|
-
Add more detailed CPU usage information via the
|
135
|
-
Win32_PerfFormattedData_PerfOS_Processor class.
|
136
|
-
|
137
|
-
= Copyright
|
138
|
-
(C) 2003-2007 Daniel J. Berger
|
139
|
-
All Rights Reserved
|
140
|
-
|
141
|
-
= Warranty
|
142
|
-
This package is provided "as is" and without any express or
|
143
|
-
implied warranties, including, without limitation, the implied
|
144
|
-
warranties of merchantability and fitness for a particular purpose.
|
145
|
-
|
146
|
-
= License
|
147
|
-
Ruby's
|
148
|
-
|
149
|
-
= Author
|
150
|
-
Daniel J. Berger
|
151
|
-
djberg96 at nospam at gmail dot com
|
152
|
-
imperator/rubyhacker1 on IRC (Freenode)
|
129
|
+
== More Information
|
130
|
+
See the README file for more information.
|