org.rhq.core.system
Class ProcessInfo

java.lang.Object
  extended by org.rhq.core.system.ProcessInfo
Direct Known Subclasses:
AggregateProcessInfo

public class ProcessInfo
extends Object

Encapsulates information about a known process.


Field Summary
protected  String baseName
           
protected  String[] commandLine
           
protected  Map<String,String> environmentVariables
           
protected  boolean initialized
           
protected  String name
           
protected  long pid
           
protected  org.hyperic.sigar.ProcCpu procCpu
           
protected  org.hyperic.sigar.ProcCred procCred
           
protected  org.hyperic.sigar.ProcCredName procCredName
           
protected  Map<String,String> procEnv
           
protected  org.hyperic.sigar.ProcExe procExe
           
protected  org.hyperic.sigar.ProcFd procFd
           
protected  org.hyperic.sigar.ProcMem procMem
           
protected  org.hyperic.sigar.ProcState procState
           
protected  org.hyperic.sigar.ProcTime procTime
           
protected  org.hyperic.sigar.SigarProxy sigar
           
 
Constructor Summary
protected ProcessInfo()
           
  ProcessInfo(long pid)
           
  ProcessInfo(long pid, org.hyperic.sigar.SigarProxy sigar)
           
 
Method Summary
 void destroy()
           
 boolean equals(Object obj)
          Two ProcessInfo objects are equal if their pids are the same.
 AggregateProcessInfo getAggregateProcessTree()
          Returns an object that provides aggregate information on this process and all its children.
 String getBaseName()
          Similar to getName(), this is a convenience method that returns the first command line argument, which is the name of the program that the process is executing.
 String[] getCommandLine()
           
 org.hyperic.sigar.ProcCpu getCpu()
           
 org.hyperic.sigar.ProcCred getCredentials()
           
 org.hyperic.sigar.ProcCredName getCredentialsName()
           
 String getCurrentWorkingDirectory()
           
 String getEnvironmentVariable(String name)
          Retrieves a specific environment property if it exists, null otherwise.
 Map<String,String> getEnvironmentVariables()
           
 org.hyperic.sigar.ProcExe getExecutable()
           
 org.hyperic.sigar.ProcFd getFileDescriptor()
           
 org.hyperic.sigar.ProcMem getMemory()
           
 String getName()
          Convenience method that returns the first command line argument, which is the name of the program that the process is executing.
 long getParentPid()
           
 long getPid()
           
 org.hyperic.sigar.ProcState getState()
           
 org.hyperic.sigar.ProcTime getTime()
           
 int hashCode()
          A process' pid makes it unique - this returns the getPid() itself.
 boolean isRunning()
           
 void refresh()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

initialized

protected boolean initialized

pid

protected long pid

name

protected String name

baseName

protected String baseName

commandLine

protected String[] commandLine

environmentVariables

protected Map<String,String> environmentVariables

sigar

protected org.hyperic.sigar.SigarProxy sigar

procState

protected org.hyperic.sigar.ProcState procState

procExe

protected org.hyperic.sigar.ProcExe procExe

procTime

protected org.hyperic.sigar.ProcTime procTime

procMem

protected org.hyperic.sigar.ProcMem procMem

procCpu

protected org.hyperic.sigar.ProcCpu procCpu

procFd

protected org.hyperic.sigar.ProcFd procFd

procCred

protected org.hyperic.sigar.ProcCred procCred

procCredName

protected org.hyperic.sigar.ProcCredName procCredName

procEnv

protected Map<String,String> procEnv
Constructor Detail

ProcessInfo

protected ProcessInfo()

ProcessInfo

public ProcessInfo(long pid)
            throws SystemInfoException
Throws:
SystemInfoException

ProcessInfo

public ProcessInfo(long pid,
                   org.hyperic.sigar.SigarProxy sigar)
            throws SystemInfoException
Throws:
SystemInfoException
Method Detail

refresh

public void refresh()
             throws SystemInfoException
Throws:
SystemInfoException

destroy

public void destroy()
             throws SystemInfoException
Throws:
SystemInfoException

getPid

public long getPid()

getName

public String getName()
Convenience method that returns the first command line argument, which is the name of the program that the process is executing.

Returns:
full name of program that is executing
See Also:
getBaseName(), getCommandLine()

getBaseName

public String getBaseName()
Similar to getName(), this is a convenience method that returns the first command line argument, which is the name of the program that the process is executing. However, this is only the relative filename of the program, which does not include the full path to the program (e.g. this would return "sh" if the name of the process is "/usr/bin/sh").

Returns:
filename of program that is executing
See Also:
getName(), getCommandLine()

getCommandLine

public String[] getCommandLine()

getEnvironmentVariables

public Map<String,String> getEnvironmentVariables()

getEnvironmentVariable

@Nullable
public String getEnvironmentVariable(@NotNull
                                              String name)
Retrieves a specific environment property if it exists, null otherwise.

Parameters:
name - the name of the property to find
Returns:
the environment value

getParentPid

public long getParentPid()
                  throws SystemInfoException
Throws:
SystemInfoException

getState

public org.hyperic.sigar.ProcState getState()
                                     throws SystemInfoException
Throws:
SystemInfoException

getExecutable

public org.hyperic.sigar.ProcExe getExecutable()
                                        throws SystemInfoException
Throws:
SystemInfoException

getTime

public org.hyperic.sigar.ProcTime getTime()
                                   throws SystemInfoException
Throws:
SystemInfoException

getMemory

public org.hyperic.sigar.ProcMem getMemory()
                                    throws SystemInfoException
Throws:
SystemInfoException

getCpu

public org.hyperic.sigar.ProcCpu getCpu()
                                 throws SystemInfoException
Throws:
SystemInfoException

getFileDescriptor

public org.hyperic.sigar.ProcFd getFileDescriptor()
                                           throws SystemInfoException
Throws:
SystemInfoException

getCredentials

public org.hyperic.sigar.ProcCred getCredentials()
                                          throws SystemInfoException
Throws:
SystemInfoException

getCredentialsName

public org.hyperic.sigar.ProcCredName getCredentialsName()
                                                  throws SystemInfoException
Throws:
SystemInfoException

getCurrentWorkingDirectory

public String getCurrentWorkingDirectory()
                                  throws SystemInfoException
Throws:
SystemInfoException

isRunning

public boolean isRunning()
                  throws SystemInfoException
Throws:
SystemInfoException

getAggregateProcessTree

public AggregateProcessInfo getAggregateProcessTree()
Returns an object that provides aggregate information on this process and all its children.

Returns:
aggregate information on this process and its children

hashCode

public int hashCode()
A process' pid makes it unique - this returns the getPid() itself.

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Two ProcessInfo objects are equal if their pids are the same.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.