Class Sys::CPU
In: lib/linux/sys/cpu.rb
lib/windows/sys/cpu.rb
ext/bsd/bsd.c
Parent: Object

The CPU class provides class methods for obtaining CPU information

Methods

architecture   architecture   cpu_stats   freq   freq   load_avg   load_avg   load_avg   machine   model   model   num_cpu   num_cpu   processors   processors   type  

Classes and Modules

Class Sys::CPU::Error

Constants

VERSION = '0.6.3'   The version of the sys-cpu library.
VERSION = '0.6.3'   The version of the sys-cpu library
VERSION = 0.6.3   The version of the sys-cpu library

Public Class methods

Returns the cpu‘s architecture. On most systems this will be identical to the CPU.machine method. On OpenBSD it will be identical to the CPU.model method.

Returns the host CPU‘s architecture, or nil if it cannot be determined.

Returns a hash of arrays that contain the number of seconds that the system spent in user mode, user mode with low priority (nice), system mode, and the idle task, respectively.

Returns an integer indicating the speed (i.e. frequency in Mhz) of the cpu.

Not supported on OS X.

Returns an integer indicating the speed (i.e. frequency in Mhz) of cpu_num on host, or the localhost if no host is specified. If cpu_num +1 is greater than the number of cpu‘s on your system or this call fails for any other reason, a Error is raised.

Returns a 3 element Array corresponding to the 1, 5 and 15 minute load average for the system.

Returns an array of three floats indicating the 1, 5 and 15 minute load average.

Returns the load capacity for cpu_num on host, or the localhost if no host is specified, averaged to the last second. Processor loading refers to the total computing burden for each processor at one time.

Note that this attribute is actually the LoadPercentage. I may use one of the Win32_Perf* classes in the future.

Returns the cpu‘s class type. On most systems this will be identical to the CPU.architecture method. On OpenBSD it will be identical to the CPU.model method.

Returns a string indicating the cpu model.

Returns a string indicating the cpu model, e.g. Intel Pentium 4.

Returns an integer indicating the number of cpu‘s on the system.

Returns the number of cpu‘s on your system. Note that each core on multi-core systems are counted as a cpu, e.g. one dual core cpu would return 2, not 1.

Returns a CPUStruct for each CPU on host, or the localhost if no host is specified. A CPUStruct contains the following members:

  • address_width
  • architecture
  • availability
  • caption
  • config_manager_error_code
  • config_manager_user_config
  • cpu_status
  • creation_class_name
  • freq
  • voltage
  • data_width
  • description
  • device_id
  • error_cleared?
  • error_description
  • ext_clock
  • family
  • install_date
  • l2_cache_size
  • l2_cache_speed
  • last_error_code
  • level
  • load_avg
  • manufacturer
  • max_clock_speed
  • name
  • other_family_description
  • pnp_device_id
  • power_management_supported?
  • power_management_capabilities
  • processor_id
  • processor_type
  • revision
  • role
  • socket_designation
  • status
  • status_info
  • stepping
  • system_creation_class_name
  • system_name
  • unique_id
  • upgrade_method
  • version
  • voltage_caps

Note that not all of these members will necessarily be defined.

In block form, yields a CPUStruct for each CPU on the system. In non-block form, returns an Array of CPUStruct‘s.

The exact members of the struct vary on Linux systems.

Returns a string indicating the type of processor, e.g. GenuineIntel.

[Validate]