Class: Cfruby::Processes::ProcessInfo

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/libcfruby/processes.rb

Overview

A holding object for information about a process. Currently implemented as a simple OpenStruct. Should provide accessor methods for as many of the following as possible (listed in order of importance):

pid

unique process id

program

the name or commandline of the program

username

the username of the user running the program

flags

process flags (zombie, jailed, etc)

starttime

when the program was started

runtime

how long the program has been running (cpu time)

cpu (%)

percentage of cpu being used

mem (%)

percentage of memory being used

Instance Method Summary collapse

Instance Method Details

#to_hashObject



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/libcfruby/processes.rb', line 59

def to_hash()
	keyregex = /^([^=]+)=$/
	hash = Hash.new()
	self.methods.each() { |pkey|
		match = keyregex.match(pkey)
		if(match)
			hash[match[1]] = self.send(match[1].to_sym)
		end
	}
	
	return(hash)
end

#to_sObject



54
55
56
# File 'lib/libcfruby/processes.rb', line 54

def to_s()
	return(self.program)
end