sys-cpu 0.6.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,144 @@
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
+
14
+ == 0.6.1 - 4-Jan-2009
15
+ * Fix for OS X 10.5.x. Thanks go to Victor Costan for the spot and the patch.
16
+ * Updated the gemspec and some other minor changes.
17
+ * On MS Windows the impersonation level is now explicitly set to 'impersonate'
18
+ to avoid issues where systems might be using an older version of WMI.
19
+
20
+ == 0.6.0 - 26-Apr-2007
21
+ * Added support for most BSD flavors, including OS X. The freebsd.c file is
22
+ now just bsd.c.
23
+ * The CPU.type method for Solaris has been changed to CPU.cpu_type to avoid
24
+ conflicting with the Object.type method.
25
+ * Added a Rakefile. There are now tasks for building, testing and installing,
26
+ among other things. Run 'rake -T' to check your options.
27
+ * Many internal directory layout changes - C source files are now under the
28
+ 'ext' directory.
29
+ * Improved RDoc comments in the C source files.
30
+ * Changed CPUError to CPU::Error.
31
+
32
+ == 0.5.5 - 17-Nov-2006
33
+ * Fixed a bug in the Linux version where there could be a key but no
34
+ associated value, causing a String#strip! call to fail. Now the value is
35
+ simply left at nil.
36
+ * Refactored the CPU.processors method on Linux, including the removal of '?'
37
+ from the CPUStruct members for the boolean methods (Ruby doesn't like them).
38
+ * Minor tweaks and updates to the documentation, including the README.
39
+ * Modified the gemspec so that it sets the platform properly for Linux
40
+ and Windows.
41
+
42
+ == 0.5.4 - 12-Jul-2006
43
+ * Added a gemspec (and a gem on RubyForge).
44
+ * The CPU.architecture method on HP-UX now returns nil if it cannot be
45
+ determined instead of "Unknown" for consistency with the other
46
+ platforms.
47
+ * Inlined the RDoc and made some minor cosmetic source code changes.
48
+
49
+ == 0.5.3 - 4-May-2006
50
+ * Fixed in a bug in the Solaris version where CPU.load_avg returned bad values
51
+ when compiled in 64 bit mode. Thanks go to James Hranicky for the spot and
52
+ both James Hranicky and Peter Tribble (via comp.unix.solaris) for patches.
53
+ * Made some modifications to the test suite. You know longer need to know
54
+ which test suite to run. All platforms now use 'ts_all.rb', which will run
55
+ the appropriate test case behind the scenes.
56
+
57
+ == 0.5.2 - 24-Jun-2005
58
+ * Bug fixed on Linux where empty lines could cause problems. This affected
59
+ both the install.rb and linux.rb files, though it only seems to have been
60
+ an issue on the 2.6+ kernel.
61
+ * Altered the behavior of the CPU.cpu_stats method on Linux. Now, only the
62
+ numbered cpu entries return associated data, unless the numberless entry
63
+ is the only entry.
64
+ * Added a sample program for Linux under the 'examples' directory.
65
+
66
+ == 0.5.1 - 5-May-2005
67
+ * Fixed a potential bug in the FreeBSD version of CPU.model.
68
+ * Eliminated some warnings in the FreeBSD version.
69
+ * Moved examples directory to the toplevel package directory.
70
+ * Renamed and updated the sample scripts.
71
+ * Added a sample script for FreeBSD.
72
+ * Removed the INSTALL file. That information is now included in the README.
73
+ * Made the CHANGES, README, and .txt files rdoc friendly.
74
+ * The dynamic documentation generation for Linux has been altered. Anything
75
+ relating to rd2 has been removed. The doc file generated is now
76
+ doc/linux.txt.
77
+ * Some $LOAD_PATH setup changes in the unit tests.
78
+
79
+ == 0.5.0 - 26-Jun-2004
80
+ * Now requires Ruby 1.8.0 or later.
81
+ * FreeBSD support added.
82
+ * Replaced 'CPUException' with 'CPUError'
83
+ * The MS Windows version has been completely revamped to use WMI instead of
84
+ the C API. Some method names have changed and some methods have been
85
+ dropped entirely. Please see the documentation for details.
86
+ * Corresponding documentation updates and test suite changes.
87
+ * Sample programs have been moved to doc/examples.
88
+ * Installation procedure somewhat revamped.
89
+ * No longer autogenerates test file.
90
+ * The .html files have been removed. You can generate the html on your own
91
+ if you like.
92
+
93
+ == 0.4.0 - 18-Sep-2003
94
+ * Added MS Windows support
95
+ * Changed some method names. The "cpu" has been dropped from most method
96
+ names. See documentation for details.
97
+ * The state() and freq() methods (where supported) now assume a default
98
+ value of zero.
99
+ * More unit tests added.
100
+ * Fixed minor issue with test.rb for those without TestUnit installed.
101
+ * Fixed issue with linux.rb file being auto-installed on non-Linux platforms.
102
+ * Minor API change for the load_avg() method on HP-UX. It now accepts a
103
+ CPU number as an argument.
104
+
105
+ == 0.3.1 - 16-Jul-2003
106
+ * Fixed a bug in the Solaris version that was using up and not
107
+ freeing file descriptors.
108
+ * Added html doc for Solaris under doc directory.
109
+ * Minor changes to test_hpux.rb and test_sunos.rb
110
+ * Minor README changes.
111
+
112
+ == 0.3.0 - 30-Jun-2003
113
+ * Added HP-UX support
114
+ * Removed the VERSION class method. Use the constant instead
115
+ * Changed license to "Artistic"
116
+ * Moved version info into its own file for convenience
117
+ * Some minor mods to the test suites
118
+ * Modified extconf.rb, moving some of the dynamic test generation
119
+ into separate files
120
+
121
+ == 0.2.2 - 25-Mar-2003
122
+ * fpu_type and cpu_type now return nil if not found (Solaris)
123
+ * CPUException is now a direct subclass of StandardError
124
+ * Modified extconf.rb script
125
+ * Minor doc updates
126
+ * Added another test to the solaris test suite
127
+ * Important note added to INSTALL file
128
+
129
+ == 0.2.1 - 12-Mar-2003
130
+ * Added the cpu_stats() class method for Linux, which contains the
131
+ data from the 'cpu' lines of /proc/stat
132
+ * Minor fix for extconf.rb (thanks Michael Granger)
133
+ * Some tests added to Linux test suite
134
+ * MANIFEST correction
135
+
136
+ == 0.2.0 - 13-Feb-2003
137
+ * Linux support added (pure Ruby only)
138
+ * Many changes to extconf.rb to support Linux version
139
+ * sys-uname prerequisite dropped
140
+ * rd2 documentation now kept separate from source
141
+
142
+ == 0.1.0 - 3-Feb-2003
143
+ * Initial release
144
+ * Currently supports Solaris (only)
data/MANIFEST ADDED
@@ -0,0 +1,29 @@
1
+ * install.rb
2
+ * MANIFEST
3
+ * CHANGES
4
+ * Rakefile
5
+ * README
6
+ * sys-cpu.gemspec
7
+ * doc/bsd.txt
8
+ * doc/hpux.txt
9
+ * doc/linux.txt
10
+ * doc/sunos.txt
11
+ * doc/windows.txt
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
+ * ext/extconf.rb
18
+ * ext/version.h
19
+ * ext/bsd/bsd.c
20
+ * ext/hpux/hpux.c
21
+ * ext/sunos/sunos.c
22
+ * lib/sys/linux.rb
23
+ * lib/sys/windows.rb
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 ADDED
@@ -0,0 +1,79 @@
1
+ == Description
2
+ A Ruby interface for getting cpu information.
3
+
4
+ == Installation
5
+ gem install sys-cpu
6
+ gem install sys-cpu --platform mswin32 # MS Windows
7
+
8
+ == Notes
9
+ === All Platforms
10
+ As of version 0.5.0 Ruby 1.8.0 or later is required. It may work with
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.
16
+
17
+ === Solaris
18
+ Currently there is no 'processors()' iterative method for multi-cpu systems.
19
+ I plan to add it this in a future release.
20
+
21
+ === OS X
22
+ The CPU.freq method is not supported at the moment. The sysctl() approach
23
+ returns a bogus, hard coded value of some sort. I suspect it's possible
24
+ by using kernel modules via kldload(), but I'm not sure how yet.
25
+
26
+ === Linux
27
+ This is pure Ruby. This version reads information out of /proc/cpuinfo and
28
+ /proc/loadavg, so if /proc isn't mounted it won't work.
29
+
30
+ The key-value information in /proc/cpuinfo is stored internally (i.e. in
31
+ memory) as an array of hashes when you first 'require' this package. This
32
+ overhead is exceptionally minimal, given that your average cpuinfo file
33
+ contains less than 1k of text (and I don't store whitespace or newlines).
34
+
35
+ The text documentation for Linux is dynamically generated during the
36
+ build process because the fields vary depending on your setup. So, don't
37
+ look at it until *after* you've installed it. You will see a doc/linux.txt
38
+ file after you run 'rake install' (via install.rb).
39
+
40
+ === HP-UX
41
+ Unlike other platforms, you can get load averages for an individual cpu in
42
+ multi-cpu systems. See documentation for more details.
43
+
44
+ === MS Windows
45
+ This is a pure Ruby implementation using the win32ole package + WMI. The C
46
+ version has been scrapped.
47
+
48
+ As of version 0.5.0, the CPU.usage method has been removed in favor of the
49
+ CPU.load_avg method. This does not (currently) use a perf counter, so there
50
+ is no longer any delay. Also, the 'processors' method has been
51
+ added and the 'supported' method has been dropped. See the documentation
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.
57
+
58
+ == Known Bugs
59
+ None that I'm aware of. Please report bugs on the project page at
60
+ http://www.rubyforge.org/projects/sysutils.
61
+
62
+ == Future Plans
63
+ Add iterative CPU.processors method.
64
+ Make CPU.freq work on OS X.
65
+ Add more information in general, such as what 'prtdiag' shows.
66
+
67
+ == License
68
+ Artistic 2.0
69
+
70
+ == Copyright
71
+ (C) 2003-2009 Daniel J. Berger, All Rights Reserved
72
+
73
+ == Warranty
74
+ This package is provided "as is" and without any express or
75
+ implied warranties, including, without limitation, the implied
76
+ warranties of merchantability and fitness for a particular purpose.
77
+
78
+ == Author
79
+ Daniel J. Berger
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 ADDED
@@ -0,0 +1,49 @@
1
+ == Description
2
+ Sys::CPU - An interface for various cpu statistics
3
+
4
+ == Synopsis
5
+ require "sys/cpu"
6
+ include Sys
7
+
8
+ # BSD and OS X
9
+ puts "Architecture: " + CPU.architecture
10
+ puts "Machine: " + CPU.machine
11
+ puts "Mhz: " + CPU.cpu_freq.to_s
12
+ puts "Number of cpu's on this system: " + CPU.num_cpu.to_s
13
+ puts "CPU model: " + CPU.model
14
+ puts "Load averages: " + CPU.load_avg.join(", ")
15
+
16
+ == Constants
17
+ VERSION
18
+ Returns the current version number for this package.
19
+
20
+ == Class Methods
21
+ CPU.architecture
22
+ Returns the cpu's architecture.
23
+
24
+ CPU.freq
25
+ Returns an integer indicating the speed (i.e. frequency in Mhz) of
26
+ the cpu.
27
+
28
+ Not supported on OS X.
29
+
30
+ CPU.load_avg
31
+ Returns an array of three floats indicating the 1, 5 and 15 minute load
32
+ average.
33
+
34
+ CPU.machine
35
+ Returns the class of cpu (probably identical to the architecture).
36
+
37
+ CPU.model
38
+ Returns a string indicating the cpu model.
39
+
40
+ CPU.num_cpu
41
+ Returns an integer indicating the number of cpu's on the system.
42
+
43
+ == Error Classes
44
+ CPU::Error < StandardError
45
+ Raised is response to internal function errors, usually relating to an
46
+ invalid cpu number.
47
+
48
+ == More Information
49
+ See the README file for more information.
data/doc/hpux.txt ADDED
@@ -0,0 +1,54 @@
1
+ == Description
2
+ Sys::CPU - An interface for various cpu statistics
3
+
4
+ == Synopsis
5
+ require "sys/cpu"
6
+ include Sys
7
+
8
+ puts "Mhz: " + CPU.cpu_freq.to_s
9
+ puts "State: " + CPU.state(0)
10
+ puts "Number of cpu's on this system: " + CPU.num_cpu.to_s
11
+ puts "Number of active cpu's: " + CPU.num_active_cpu.to_s
12
+ puts "Load averages: " + CPU.load_avg.join(", ")
13
+
14
+ == Constants
15
+ VERSION
16
+ Returns the current version number for this package.
17
+
18
+ == Class Methods
19
+ CPU.architecture
20
+ Returns the cpu architecture, e.g. PA RISC 1.2, etc.
21
+
22
+ CPU.freq(cpu_num=0)
23
+ Returns an integer indicating the speed (i.e. frequency in Mhz) of
24
+ the cpu.
25
+
26
+ CPU.load_avg
27
+ CPU.load_avg(cpu_num)
28
+ CPU.load_avg{ |cpu| ... }
29
+
30
+ In non-block form returns an array of three floats indicating the 1, 5
31
+ and 15 minute overall load average.
32
+
33
+ In block form, it returns an array of three floats indicating the 1, 5
34
+ and 15 minute load average for each cpu. Only useful on multi-cpu
35
+ systems.
36
+
37
+ If 'cpu_num' is provided, returns the load average (as a 3-element
38
+ array) for that cpu only.
39
+
40
+ You cannot provide a cpu number and use block form at the same time.
41
+
42
+ CPU.num_cpu
43
+ Returns an integer indicating the number of cpu's on the system.
44
+
45
+ CPU.num_active_cpu
46
+ Returns an integer indicating the number of active cpu's on the system.
47
+
48
+ == Error Classes
49
+ CPU::Error < StandardError
50
+ Raised is response to internal function errors, usually relating to an
51
+ invalid cpu number.
52
+
53
+ == More Information
54
+ See the README file for more information.