sys-cpu 0.5.4-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES ADDED
@@ -0,0 +1,103 @@
1
+ == 0.5.4 - 12-Jul-2006
2
+ * Added a gemspec (and a gem on RubyForge).
3
+ * The CPU.architecture method on HP-UX now returns nil if it cannot be
4
+ determined instead of "Unknown" for consistency with the other
5
+ platforms.
6
+ * Inlined the RDoc and made some minor cosmetic source code changes.
7
+
8
+ == 0.5.3 - 4-May-2006
9
+ * Fixed in a bug in the Solaris version where CPU.load_avg returned bad values
10
+ when compiled in 64 bit mode. Thanks go to James Hranicky for the spot and
11
+ both James Hranicky and Peter Tribble (via comp.unix.solaris) for patches.
12
+ * Made some modifications to the test suite. You know longer need to know
13
+ which test suite to run. All platforms now use 'ts_all.rb', which will run
14
+ the appropriate test case behind the scenes.
15
+
16
+ == 0.5.2 - 24-Jun-2005
17
+ * Bug fixed on Linux where empty lines could cause problems. This affected
18
+ both the install.rb and linux.rb files, though it only seems to have been
19
+ an issue on the 2.6+ kernel.
20
+ * Altered the behavior of the CPU.cpu_stats method on Linux. Now, only the
21
+ numbered cpu entries return associated data, unless the numberless entry
22
+ is the only entry.
23
+ * Added a sample program for Linux under the 'examples' directory.
24
+
25
+ == 0.5.1 - 5-May-2005
26
+ * Fixed a potential bug in the FreeBSD version of CPU.model.
27
+ * Eliminated some warnings in the FreeBSD version.
28
+ * Moved examples directory to the toplevel package directory.
29
+ * Renamed and updated the sample scripts.
30
+ * Added a sample script for FreeBSD.
31
+ * Removed the INSTALL file. That information is now included in the README.
32
+ * Made the CHANGES, README, and .txt files rdoc friendly.
33
+ * The dynamic documentation generation for Linux has been altered. Anything
34
+ relating to rd2 has been removed. The doc file generated is now
35
+ doc/linux.txt.
36
+ * Some $LOAD_PATH setup changes in the unit tests.
37
+
38
+ == 0.5.0 - 26-Jun-2004
39
+ * Now requires Ruby 1.8.0 or later.
40
+ * FreeBSD support added.
41
+ * Replaced 'CPUException' with 'CPUError'
42
+ * The MS Windows version has been completely revamped to use WMI instead of
43
+ the C API. Some method names have changed and some methods have been
44
+ dropped entirely. Please see the documentation for details.
45
+ * Corresponding documentation updates and test suite changes.
46
+ * Sample programs have been moved to doc/examples.
47
+ * Installation procedure somewhat revamped.
48
+ * No longer autogenerates test file.
49
+ * The .html files have been removed. You can generate the html on your own
50
+ if you like.
51
+
52
+ == 0.4.0 - 18-Sep-2003
53
+ * Added MS Windows support
54
+ * Changed some method names. The "cpu" has been dropped from most method
55
+ names. See documentation for details.
56
+ * The state() and freq() methods (where supported) now assume a default
57
+ value of zero.
58
+ * More unit tests added.
59
+ * Fixed minor issue with test.rb for those without TestUnit installed.
60
+ * Fixed issue with linux.rb file being auto-installed on non-Linux platforms.
61
+ * Minor API change for the load_avg() method on HP-UX. It now accepts a
62
+ CPU number as an argument.
63
+
64
+ == 0.3.1 - 16-Jul-2003
65
+ * Fixed a bug in the Solaris version that was using up and not
66
+ freeing file descriptors.
67
+ * Added html doc for Solaris under doc directory.
68
+ * Minor changes to test_hpux.rb and test_sunos.rb
69
+ * Minor README changes.
70
+
71
+ == 0.3.0 - 30-Jun-2003
72
+ * Added HP-UX support
73
+ * Removed the VERSION class method. Use the constant instead
74
+ * Changed license to "Artistic"
75
+ * Moved version info into its own file for convenience
76
+ * Some minor mods to the test suites
77
+ * Modified extconf.rb, moving some of the dynamic test generation
78
+ into separate files
79
+
80
+ == 0.2.2 - 25-Mar-2003
81
+ * fpu_type and cpu_type now return nil if not found (Solaris)
82
+ * CPUException is now a direct subclass of StandardError
83
+ * Modified extconf.rb script
84
+ * Minor doc updates
85
+ * Added another test to the solaris test suite
86
+ * Important note added to INSTALL file
87
+
88
+ == 0.2.1 - 12-Mar-2003
89
+ * Added the cpu_stats() class method for Linux, which contains the
90
+ data from the 'cpu' lines of /proc/stat
91
+ * Minor fix for extconf.rb (thanks Michael Granger)
92
+ * Some tests added to Linux test suite
93
+ * MANIFEST correction
94
+
95
+ == 0.2.0 - 13-Feb-2003
96
+ * Linux support added (pure Ruby only)
97
+ * Many changes to extconf.rb to support Linux version
98
+ * sys-uname prerequisite dropped
99
+ * rd2 documentation now kept separate from source
100
+
101
+ == 0.1.0 - 3-Feb-2003
102
+ * Initial release
103
+ * Currently supports Solaris (only)
data/README ADDED
@@ -0,0 +1,51 @@
1
+ == Description
2
+ A Ruby interface for getting cpu information.
3
+
4
+ == Installation
5
+ === Linux and Windows:
6
+ ruby test/ts_all.rb (optional)
7
+ ruby install.rb
8
+
9
+ === All other platforms:
10
+ ruby extconf.rb
11
+ make
12
+ ruby test/ts_all.rb (optional)
13
+ make site-install
14
+
15
+ == Notes
16
+ === All Platforms
17
+ As of version 0.5.0 Ruby 1.8.0 or later is required. It may work with
18
+ earlier versions, but I will not support it. In addition, a test file is
19
+ no longer auto-generated for you. If wish to run the test suite, cd to the
20
+ 'test' directory and run the test suite appropriate for your platform.
21
+
22
+ === Solaris
23
+ Currently there is no 'processors()' iterative method for multi-cpu systems.
24
+ I plan to add it this in a future release.
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 generating during the
36
+ build process. So, don't look at it until *after* you've run make. :)
37
+ You will see a doc/linux.txt file after you run install.rb.
38
+
39
+ === HP-UX
40
+ Unlike other platforms, you can get load averages for an individual cpu (in
41
+ multi-cpu systems). See documentation for more details.
42
+
43
+ === Win32
44
+ This is a pure Ruby implementation using the win32ole package + WMI. The C
45
+ version has been scrapped.
46
+
47
+ As of version 0.5.0, the CPU.usage method has been removed in favor of the
48
+ CPU.load_avg method. This does not (currently) use a perf counter, so there
49
+ is no longer any delay. Also, the 'processors' method has been
50
+ added and the 'supported' method has been dropped. See the documentation
51
+ for other changes.
data/doc/freebsd.txt ADDED
@@ -0,0 +1,65 @@
1
+ == Description
2
+ Sys::CPU - An interface for various cpu statistics
3
+
4
+ == Synopsis
5
+ require "sys/cpu"
6
+ include Sys
7
+
8
+ # FreeBSD
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
+ CPU.load_avg
29
+ Returns an array of three floats indicating the 1, 5 and 15 minute load
30
+ average.
31
+
32
+ CPU.machine
33
+ Returns the class of cpu (probably identical to the architecture).
34
+
35
+ CPU.model
36
+ Returns a string indicating the cpu model.
37
+
38
+ CPU.num_cpu
39
+ Returns an integer indicating the number of cpu's on the system.
40
+
41
+ == Error Classes
42
+ CPUError < StandardError
43
+ Raised is response to internal function errors, usually relating to an
44
+ invalid cpu number.
45
+
46
+ == Known Bugs
47
+ None known. Please post bug reports to the SourceForge home page at
48
+ http://www.rubyforge.org/projects/sysutils
49
+
50
+ == Copyright
51
+ (C) 2003-2005 Daniel J. Berger
52
+ All Rights Reserved
53
+
54
+ == Warranty
55
+ This package is provided "as is" and without any express or
56
+ implied warranties, including, without limitation, the implied
57
+ warranties of merchantability and fitness for a particular purpose.
58
+
59
+ == License
60
+ Ruby's
61
+
62
+ == Author
63
+ Daniel J. Berger
64
+ djberg96 at yahoo dot com
65
+ imperator/rubyhacker1 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
+ CPUError < 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-2005 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 yahoo dot com
75
+ imperator/rubyhacker1 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,76 @@
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
+ CPUError < 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-2006 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
data/doc/windows.txt ADDED
@@ -0,0 +1,152 @@
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
+ puts "CPU Speed (Frequency): " + CPU.freq(0).to_s
15
+ puts "Load avg: " + CPU.load_avg.to_s
16
+ puts "Num CPU: " + CPU.num_cpu.to_s
17
+ puts "Type: " + CPU.type
18
+ puts "Model: " + CPU.model
19
+ puts "Architecture: " + CPU.architecture
20
+
21
+ == Constants
22
+ VERSION
23
+ Returns the current version number for this package.
24
+
25
+ == Class Methods
26
+ CPU.architecture(host=localhost)
27
+ Returns the architecture of the cpu, e.g. x86 Family 15 Model 2
28
+
29
+ CPU.freq(cpu_num=0, host=localhost)
30
+ Returns an integer indicating the speed (i.e. frequency in Mhz) of
31
+ 'cpu_num'. If cpu_num+1 is greater than the number of cpu's on
32
+ your system, or this call fails for any other reason, a CPUError
33
+ is raised.
34
+
35
+ CPU.load_avg(host=localhost)
36
+ Returns the load capacity of each processor, averaged to the last second.
37
+ Processor loading refers to the total computing burden for each
38
+ processor at one time.
39
+
40
+ Note that this attribute is actually the LoadPercentage. I may use
41
+ one of the Win32_Perf* classes in the future.
42
+
43
+ CPU.model(host=localhost)
44
+ Returns a string indicating the cpu model, e.g. Intel Pentium 4
45
+
46
+ CPU.num_cpu(host=localhost)
47
+ Returns an integer indicating the number of cpu's on the system.
48
+
49
+ CPU.processors(host=localhost){ |cpu| ... }
50
+ Returns a CPUStruct for each CPU on the system containing the following
51
+ members:
52
+
53
+ * address_width
54
+ * architecture
55
+ * availability
56
+ * caption
57
+ * config_manager_error_code
58
+ * config_manager_user_config
59
+ * cpu_status
60
+ * creation_class_name
61
+ * freq
62
+ * voltage
63
+ * data_width
64
+ * description
65
+ * device_id
66
+ * error_cleared?
67
+ * error_description
68
+ * ext_clock
69
+ * family
70
+ * install_date
71
+ * l2_cache_size
72
+ * l2_cache_speed
73
+ * last_error_code
74
+ * level
75
+ * load_avg
76
+ * manufacturer
77
+ * max_clock_speed
78
+ * name
79
+ * other_family_description
80
+ * pnp_device_id
81
+ * power_management_supported?
82
+ * power_management_capabilities
83
+ * processor_id
84
+ * processor_type
85
+ * revision
86
+ * role
87
+ * socket_designation
88
+ * status
89
+ * status_info
90
+ * stepping
91
+ * system_creation_class_name
92
+ * system_name
93
+ * unique_id
94
+ * upgrade_method
95
+ * version
96
+ * voltage_caps
97
+
98
+ Note that not all of these members will necessarily be defined. See the
99
+ NOTES section below.
100
+
101
+ CPU.type(host=localhost)
102
+ Returns a string indicating the type of processor, e.g. GenuineIntel.
103
+
104
+ == Exception Classes
105
+ CPUError < StandardError
106
+ Raised is response to internal function errors, most likely to be raised
107
+ in the event that in invalid cpu number is provided for the 'freq'
108
+ method.
109
+
110
+ == Notes
111
+ Some of the CPUStruct members may be nil. As far as I can tell, this
112
+ means that Windows is unable to determine the value for the attribute due
113
+ to your BIOS and/or BIOS settings. There is nothing clear in the
114
+ documentation I could find for this, however.
115
+
116
+ The 'family' attribute may contain the trademark symbol.
117
+
118
+ The 'status_info' attribute was not converted to a string because the
119
+ 'status' attribute already is a string. I'm not even sure why MS has both
120
+ versions.
121
+
122
+ The 'system_name' attribute appears to be the hostname. I have no idea
123
+ why this is included as part of the CPU information, but there you go.
124
+
125
+ See http://tinyurl.com/2mros (and click on 'Win32_Processor' in the left
126
+ frame) for a list of attributes and their meaning. Link courtesy of
127
+ tinyurl.com.
128
+
129
+ == Known Bugs
130
+ No bugs known. Please log any bugs at
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-2004 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 yahoo dot com
152
+ imperator/rubyhacker1 on IRC (Freenode)