Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (81 sloc) 3.12 KB
= Description
A Ruby interface for gathering process information. For MS Windows,
the process information is gathered via OLE + WMI, using pure Ruby.
= Synopsis
require 'sys/proctable'
include Sys
# Everything{ |p|
puts p.comm
# A single pid
p =
puts p.comm
# Return the results as an array of ProcTableStructs
a =
a.each do |p|
= Constants
Returns the current version number for this library (as a string).
= Class Methods
Returns an Array of fields available on the current OS in the
ProcTableStruct., host='localhost'){ |s| ... }
Returns a struct of type ProcTableStruct for every process in the proc
table in block form. Otherwise it returns an array of ProcTableStruct's.
If 'pid' is provided, then only a struct for that pid is returned, or
nil if it is not found.
If 'host' is provided, then processes from that host are gathered. By
default, process information is gathered on the local host.
= Supported fields
You can also view the supported fields with the Sys::ProcTable.fields
= Notes
For the sake of attempting to provide a somewhat common API, the 'comm'
and 'cmdline' fields have been included as part of the structure. The
'comm' member corresponds to the Name attribute of Win32_Process. The
'cmdline' attribute corresponds to either the Executable_Path attribute
(on Windows 2000 or earlier) or the CommandLine attribute (on Windows XP
and later).
Also note that the ProcessId and ParentProcessId attributes have been
abbreviated as 'pid' and 'ppid' in the struct members, again to keep the
members more consistent between platforms.
The "Mem Usage" and "VM Size" that you may be used to seeing in your Task
Manager window (probably) correspond to the 'working_set_size' and
'page_file_usage' struct members, respectively, keeping in mind that
those values are in bytes, not kilobytes. I say 'probably' because
comments that I've read online indicate that it may not always line up
with what you see in the Task Manager, based on the current version (or
even Service Pack) of Windows that you are using.
= Future Plans
Possibly use the Win32_PerfFormattedData_PerfProc_Process class to get
additional process information.
= Known Bugs
Versions of Ruby earlier than 1.8.2 resulted in segfaults when trying to
run this code. You will likely encounter the same behavior.
Please log any additional bug reports on the project page at
= License
Artistic 2.0
= Copyright
(C) 2003-2009 Daniel J. Berger
All Rights Reserved
= Warranty
This package is provided "as is" and without any express or
implied warranties, including, without limitation, the implied
warranties of merchantability and fitness for a particular purpose.
= Author
Daniel J. Berger
= See Also
Jump to Line
Something went wrong with that request. Please try again.