Description

A Ruby interface for getting cpu information.

Installation

Linux and Windows:

ruby test/ts_all.rb (optional) ruby install.rb

All other platforms:

ruby extconf.rb make ruby test/ts_all.rb (optional) make site-install

Notes

All Platforms

As of version 0.5.0 Ruby 1.8.0 or later is required. It may work with earlier versions, but I will not support it. In addition, a test file is no longer auto-generated for you. If wish to run the test suite, cd to the ‘test’ directory and run the test suite appropriate for your platform.

Solaris

Currently there is no ‘processors()’ iterative method for multi-cpu systems. I plan to add it this in a future release.

Linux

This is pure Ruby. This version reads information out of /proc/cpuinfo and /proc/loadavg, so if /proc isn’t mounted it won’t work.

The key-value information in /proc/cpuinfo is stored internally (i.e. in memory) as an array of hashes when you first ‘require’ this package. This overhead is exceptionally minimal, given that your average cpuinfo file contains less than 1k of text (and I don’t store whitespace or newlines).

The text documentation for Linux is dynamically generating during the build process. So, don’t look at it until after you’ve run make. :) You will see a doc/linux.txt file after you run install.rb.

HP-UX

Unlike other platforms, you can get load averages for an individual cpu (in multi-cpu systems). See documentation for more details.

Win32

This is a pure Ruby implementation using the win32ole package + WMI. The C version has been scrapped.

As of version 0.5.0, the CPU.usage method has been removed in favor of the CPU.load_avg method. This does not (currently) use a perf counter, so there is no longer any delay. Also, the ‘processors’ method has been added and the ‘supported’ method has been dropped. See the documentation for other changes.