sys-cpu 0.6.4-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,160 @@
1
+ == 0.6.4 - 27-Sep-2011
2
+ * The CPU.freq method now works on OSX.
3
+ * The CPU.model method on OSX has been altered. Previously it
4
+ returned the machine model. However, the information is limited.
5
+ * Fixed a couple unused variable warnings for the BSD/OSX code.
6
+ * The Linux and Windows gems now have a 'universal' architecture.
7
+ * Refactored the clean task in the Rakefile.
8
+
9
+ == 0.6.3 - 9-Oct-2010
10
+ * Fixed a bug in the install.rb file and refactored it a bit. Thanks go
11
+ to Di-an Jan for the spot. Note, however, that this file will eventually
12
+ be removed and/or integrated into the Linux source file.
13
+ * Fixed the example Rake task, and refactored some of the other tasks.
14
+ * Fixed and updated the CPU.architecture method on MS Windows to handle IA64
15
+ and x64 architectures.
16
+
17
+ == 0.6.2 - 1-Jan-2010
18
+ * Fixed a bug in the cpu_freq function (which would only be noticed on
19
+ certain platforms in cases where the CPU.freq method failed). Thanks
20
+ go to Edho P Arief for the spot.
21
+ * Explicitly add sys/param.h on OpenBSD, and default to the HW_MODEL mib
22
+ because HW_MACHINE does not exist. Thanks go to Edho P Arief for the patch.
23
+ * Updated my support notes. In short I will support 1.8.6 and 1.9.x. I will
24
+ not support any 1.8.x branch later than 1.8.6.
25
+ * Removed redundant information in the various .txt files that is already
26
+ covered in the README file.
27
+ * Test files renamed.
28
+ * Added test-unit 2.x as a development dependency.
29
+
30
+ == 0.6.1 - 4-Jan-2009
31
+ * Fix for OS X 10.5.x. Thanks go to Victor Costan for the spot and the patch.
32
+ * Updated the gemspec and some other minor changes.
33
+ * On MS Windows the impersonation level is now explicitly set to 'impersonate'
34
+ to avoid issues where systems might be using an older version of WMI.
35
+
36
+ == 0.6.0 - 26-Apr-2007
37
+ * Added support for most BSD flavors, including OS X. The freebsd.c file is
38
+ now just bsd.c.
39
+ * The CPU.type method for Solaris has been changed to CPU.cpu_type to avoid
40
+ conflicting with the Object.type method.
41
+ * Added a Rakefile. There are now tasks for building, testing and installing,
42
+ among other things. Run 'rake -T' to check your options.
43
+ * Many internal directory layout changes - C source files are now under the
44
+ 'ext' directory.
45
+ * Improved RDoc comments in the C source files.
46
+ * Changed CPUError to CPU::Error.
47
+
48
+ == 0.5.5 - 17-Nov-2006
49
+ * Fixed a bug in the Linux version where there could be a key but no
50
+ associated value, causing a String#strip! call to fail. Now the value is
51
+ simply left at nil.
52
+ * Refactored the CPU.processors method on Linux, including the removal of '?'
53
+ from the CPUStruct members for the boolean methods (Ruby doesn't like them).
54
+ * Minor tweaks and updates to the documentation, including the README.
55
+ * Modified the gemspec so that it sets the platform properly for Linux
56
+ and Windows.
57
+
58
+ == 0.5.4 - 12-Jul-2006
59
+ * Added a gemspec (and a gem on RubyForge).
60
+ * The CPU.architecture method on HP-UX now returns nil if it cannot be
61
+ determined instead of "Unknown" for consistency with the other
62
+ platforms.
63
+ * Inlined the RDoc and made some minor cosmetic source code changes.
64
+
65
+ == 0.5.3 - 4-May-2006
66
+ * Fixed in a bug in the Solaris version where CPU.load_avg returned bad values
67
+ when compiled in 64 bit mode. Thanks go to James Hranicky for the spot and
68
+ both James Hranicky and Peter Tribble (via comp.unix.solaris) for patches.
69
+ * Made some modifications to the test suite. You know longer need to know
70
+ which test suite to run. All platforms now use 'ts_all.rb', which will run
71
+ the appropriate test case behind the scenes.
72
+
73
+ == 0.5.2 - 24-Jun-2005
74
+ * Bug fixed on Linux where empty lines could cause problems. This affected
75
+ both the install.rb and linux.rb files, though it only seems to have been
76
+ an issue on the 2.6+ kernel.
77
+ * Altered the behavior of the CPU.cpu_stats method on Linux. Now, only the
78
+ numbered cpu entries return associated data, unless the numberless entry
79
+ is the only entry.
80
+ * Added a sample program for Linux under the 'examples' directory.
81
+
82
+ == 0.5.1 - 5-May-2005
83
+ * Fixed a potential bug in the FreeBSD version of CPU.model.
84
+ * Eliminated some warnings in the FreeBSD version.
85
+ * Moved examples directory to the toplevel package directory.
86
+ * Renamed and updated the sample scripts.
87
+ * Added a sample script for FreeBSD.
88
+ * Removed the INSTALL file. That information is now included in the README.
89
+ * Made the CHANGES, README, and .txt files rdoc friendly.
90
+ * The dynamic documentation generation for Linux has been altered. Anything
91
+ relating to rd2 has been removed. The doc file generated is now
92
+ doc/linux.txt.
93
+ * Some $LOAD_PATH setup changes in the unit tests.
94
+
95
+ == 0.5.0 - 26-Jun-2004
96
+ * Now requires Ruby 1.8.0 or later.
97
+ * FreeBSD support added.
98
+ * Replaced 'CPUException' with 'CPUError'
99
+ * The MS Windows version has been completely revamped to use WMI instead of
100
+ the C API. Some method names have changed and some methods have been
101
+ dropped entirely. Please see the documentation for details.
102
+ * Corresponding documentation updates and test suite changes.
103
+ * Sample programs have been moved to doc/examples.
104
+ * Installation procedure somewhat revamped.
105
+ * No longer autogenerates test file.
106
+ * The .html files have been removed. You can generate the html on your own
107
+ if you like.
108
+
109
+ == 0.4.0 - 18-Sep-2003
110
+ * Added MS Windows support
111
+ * Changed some method names. The "cpu" has been dropped from most method
112
+ names. See documentation for details.
113
+ * The state() and freq() methods (where supported) now assume a default
114
+ value of zero.
115
+ * More unit tests added.
116
+ * Fixed minor issue with test.rb for those without TestUnit installed.
117
+ * Fixed issue with linux.rb file being auto-installed on non-Linux platforms.
118
+ * Minor API change for the load_avg() method on HP-UX. It now accepts a
119
+ CPU number as an argument.
120
+
121
+ == 0.3.1 - 16-Jul-2003
122
+ * Fixed a bug in the Solaris version that was using up and not
123
+ freeing file descriptors.
124
+ * Added html doc for Solaris under doc directory.
125
+ * Minor changes to test_hpux.rb and test_sunos.rb
126
+ * Minor README changes.
127
+
128
+ == 0.3.0 - 30-Jun-2003
129
+ * Added HP-UX support
130
+ * Removed the VERSION class method. Use the constant instead
131
+ * Changed license to "Artistic"
132
+ * Moved version info into its own file for convenience
133
+ * Some minor mods to the test suites
134
+ * Modified extconf.rb, moving some of the dynamic test generation
135
+ into separate files
136
+
137
+ == 0.2.2 - 25-Mar-2003
138
+ * fpu_type and cpu_type now return nil if not found (Solaris)
139
+ * CPUException is now a direct subclass of StandardError
140
+ * Modified extconf.rb script
141
+ * Minor doc updates
142
+ * Added another test to the solaris test suite
143
+ * Important note added to INSTALL file
144
+
145
+ == 0.2.1 - 12-Mar-2003
146
+ * Added the cpu_stats() class method for Linux, which contains the
147
+ data from the 'cpu' lines of /proc/stat
148
+ * Minor fix for extconf.rb (thanks Michael Granger)
149
+ * Some tests added to Linux test suite
150
+ * MANIFEST correction
151
+
152
+ == 0.2.0 - 13-Feb-2003
153
+ * Linux support added (pure Ruby only)
154
+ * Many changes to extconf.rb to support Linux version
155
+ * sys-uname prerequisite dropped
156
+ * rd2 documentation now kept separate from source
157
+
158
+ == 0.1.0 - 3-Feb-2003
159
+ * Initial release
160
+ * 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/linux/sys/cpu.rb
23
+ * lib/windows/sys/cpu.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,73 @@
1
+ = Description
2
+ A Ruby interface for getting cpu information.
3
+
4
+ = Installation
5
+ gem install sys-cpu
6
+
7
+ If that doesn't work try one of these:
8
+
9
+ gem install sys-cpu --platform linux # Linux
10
+ gem install sys-cpu --platform mingw32 # MS Windows
11
+
12
+ = Notes
13
+ == Solaris
14
+ Currently there is no 'processors()' iterative method for multi-cpu systems.
15
+ I plan to add it this in a future release.
16
+
17
+ == OS X
18
+ The CPU.model method returns very limited information. I do not yet know
19
+ how to get more detailed information.
20
+
21
+ == Linux
22
+ This is pure Ruby. This version reads information out of /proc/cpuinfo and
23
+ /proc/loadavg, so if /proc isn't mounted it won't work.
24
+
25
+ The key-value information in /proc/cpuinfo is stored internally (i.e. in
26
+ memory) as an array of hashes when you first 'require' this package. This
27
+ overhead is exceptionally minimal, given that your average cpuinfo file
28
+ contains less than 1k of text (and I don't store whitespace or newlines).
29
+
30
+ The text documentation for Linux is dynamically generated during the
31
+ build process because the fields vary depending on your setup. So, don't
32
+ look at it until *after* you've installed it. You will see a doc/linux.txt
33
+ file after you run 'rake install' (via install.rb).
34
+
35
+ == HP-UX
36
+ Unlike other platforms, you can get load averages for an individual cpu in
37
+ multi-cpu systems. See documentation for more details.
38
+
39
+ == MS Windows
40
+ This is a pure Ruby implementation using the win32ole package + WMI. The C
41
+ version has been scrapped.
42
+
43
+ As of version 0.5.0, the CPU.usage method has been removed in favor of the
44
+ CPU.load_avg method. This does not (currently) use a perf counter, so there
45
+ is no longer any delay. Also, the 'processors' method has been
46
+ added and the 'supported' method has been dropped. See the documentation
47
+ for other changes.
48
+
49
+ = Acknowledgements
50
+ Thanks go to the MPlayer team for some source code that helped me on
51
+ certain versions of FreeBSD.
52
+
53
+ = Known Bugs
54
+ None that I'm aware of. Please report bugs on the project page at
55
+ http://www.rubyforge.org/projects/sysutils.
56
+
57
+ = Future Plans
58
+ Add iterative CPU.processors method.
59
+ Add more information in general, such as what 'prtdiag' shows.
60
+
61
+ = License
62
+ Artistic 2.0
63
+
64
+ = Copyright
65
+ (C) 2003-2011 Daniel J. Berger, 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
+ = Author
73
+ Daniel J. Berger
data/Rakefile ADDED
@@ -0,0 +1,89 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+ include Config
6
+
7
+ CLEAN.include(
8
+ '**/*.gem', # Gem files
9
+ '**/*.rbc', # Rubinius
10
+ 'ext/cpu.c', # Temporary file
11
+ '**/*.o', # C object file
12
+ '**/*.log', # Ruby extension build log
13
+ '**/Makefile', # C Makefile
14
+ '**/conftest.dSYM', # OS X build directory
15
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
16
+ )
17
+
18
+ desc "Build the sys-cpu library on UNIX systems"
19
+ task :build => [:clean] do
20
+ Dir.chdir('ext') do
21
+ unless CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows|linux/i
22
+ ruby 'extconf.rb'
23
+ sh 'make'
24
+ build_file = 'cpu.' + CONFIG['DLEXT']
25
+ Dir.mkdir('sys') unless File.exists?('sys')
26
+ FileUtils.cp(build_file, 'sys')
27
+ end
28
+ end
29
+ end
30
+
31
+ namespace 'gem' do
32
+ desc "Create the sys-cpu gem"
33
+ task :create => [:clean] do
34
+ spec = eval(IO.read('sys-cpu.gemspec'))
35
+ Gem::Builder.new(spec).build
36
+ end
37
+
38
+ desc "Install the sys-cpu gem"
39
+ task :install => [:create] do
40
+ file = Dir["*.gem"].first
41
+ sh "gem install #{file}"
42
+ end
43
+ end
44
+
45
+ desc "Run the example program"
46
+ task :example => [:build] do
47
+ Dir.mkdir('sys') unless File.exists?('sys')
48
+ if CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows|linux/i
49
+ if CONFIG['host_os'].match('linux')
50
+ cp 'lib/linux/sys/cpu.rb', 'sys'
51
+ else
52
+ cp 'lib/windows/sys/cpu.rb', 'sys'
53
+ end
54
+ else
55
+ build_file = 'ext/cpu.' + CONFIG['DLEXT']
56
+ cp build_file, 'sys'
57
+ end
58
+
59
+ case CONFIG['host_os']
60
+ when /bsd|darwin|mach|osx/i
61
+ file = 'examples/example_sys_cpu_bsd.rb'
62
+ when /hpux/i
63
+ file = 'examples/example_sys_cpu_hpux.rb'
64
+ when /linux/i
65
+ file = 'examples/example_sys_cpu_linux.rb'
66
+ when /sunos|solaris/i
67
+ file = 'examples/example_sys_cpu_sunos.rb'
68
+ when /mswin|win32|cygwin|mingw|dos/i
69
+ file = 'examples/example_sys_cpu_windows.rb'
70
+ end
71
+ sh "ruby -I. -Iext -Ilib #{file}"
72
+ end
73
+
74
+ Rake::TestTask.new do |t|
75
+ if CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows/i
76
+ t.libs << 'lib/windows'
77
+ elsif CONFIG['host_os'] =~ /linux/i
78
+ t.libs << 'lib/linux'
79
+ else
80
+ task :test => :build
81
+ t.libs << 'ext'
82
+ t.libs.delete('lib')
83
+ end
84
+
85
+ t.libs << 'test'
86
+ t.test_files = FileList['test/test_sys_cpu.rb']
87
+ end
88
+
89
+ task :default => :test
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.