Class Sys::CPU
In: lib/windows/sys/cpu.rb
lib/unix/sys/cpu.rb
lib/linux/sys/cpu.rb
lib/unix/sys/cpu.rb
lib/unix/sys/cpu.rb
Parent: Object

Encapsulates system CPU information

Methods

architecture   architecture   architecture   architecture   cpu_stats   cpu_type   fpu_type   fpu_type   fpu_type   freq   freq   freq   freq   load_avg   load_avg   load_avg   load_avg   load_avg   machine   machine   machine   model   model   model   model   num_cpu   num_cpu   num_cpu   num_cpu   processors   processors   state   state   state  

Classes and Modules

Class Sys::CPU::Error
Class Sys::CPU::ProcInfo

Constants

VERSION = '0.7.0'   The version of the sys-cpu library
VERSION = '0.7.0'   The version of the sys-cpu library
CTL_HW = 6
HW_MACHINE = 1
HW_MODEL = 2
HW_NCPU = 3
HW_CPU_FREQ = 15
HW_MACHINE_ARCH = 11
HW_MACHINE_ARCH = 12
SI_MACHINE = 5
SI_ARCHITECTURE = 6
SC_NPROCESSORS_ONLN = 15
P_OFFLINE = 1
P_ONLINE = 2
P_FAULTED = 4
P_POWEROFF = 5
P_NOINTR = 6
P_SPARE = 7
CPU_ARCH_ABI64 = 0x01000000
CPU_TYPE_X86 = 7
CPU_TYPE_X86_64 = (CPU_TYPE_X86 | CPU_ARCH_ABI64)
CPU_TYPE_SPARC = 14
CPU_TYPE_POWERPC = 18
CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64
VERSION = '0.7.0'   The version of the sys-cpu library.
VERSION = '0.7.0'   The version of the sys-cpu library
CTL_HW = 6
HW_MACHINE = 1
HW_MODEL = 2
HW_NCPU = 3
HW_CPU_FREQ = 15
HW_MACHINE_ARCH = 11
HW_MACHINE_ARCH = 12
SI_MACHINE = 5
SI_ARCHITECTURE = 6
SC_NPROCESSORS_ONLN = 15
P_OFFLINE = 1
P_ONLINE = 2
P_FAULTED = 4
P_POWEROFF = 5
P_NOINTR = 6
P_SPARE = 7
CPU_ARCH_ABI64 = 0x01000000
CPU_TYPE_X86 = 7
CPU_TYPE_X86_64 = (CPU_TYPE_X86 | CPU_ARCH_ABI64)
CPU_TYPE_SPARC = 14
CPU_TYPE_POWERPC = 18
CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64
VERSION = '0.7.0'   The version of the sys-cpu library
CTL_HW = 6
HW_MACHINE = 1
HW_MODEL = 2
HW_NCPU = 3
HW_CPU_FREQ = 15
HW_MACHINE_ARCH = 11
HW_MACHINE_ARCH = 12
SI_MACHINE = 5
SI_ARCHITECTURE = 6
SC_NPROCESSORS_ONLN = 15
P_OFFLINE = 1
P_ONLINE = 2
P_FAULTED = 4
P_POWEROFF = 5
P_NOINTR = 6
P_SPARE = 7
CPU_ARCH_ABI64 = 0x01000000
CPU_TYPE_X86 = 7
CPU_TYPE_X86_64 = (CPU_TYPE_X86 | CPU_ARCH_ABI64)
CPU_TYPE_SPARC = 14
CPU_TYPE_POWERPC = 18
CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64

Public Class methods

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 a string indicating the type of processor, e.g. GenuineIntel.

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 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 a 3 element Array corresponding to the 1, 5 and 15 minute load average for the system.

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 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.

[Validate]