sys-cpu 0.6.1-x86-mswin32-60

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