org.bootchart.parser.linux
Class PsParser

java.lang.Object
  extended byorg.bootchart.parser.linux.PsParser

public class PsParser
extends java.lang.Object

PsParser parses log files produced by ps.


Nested Class Summary
static class PsParser.PsStats
          Process statistics.
 
Constructor Summary
PsParser()
           
 
Method Summary
static int getState(java.util.Map procInfo)
          Returns the process state.
static PsParser.PsStats parseLog(java.io.InputStream is, java.util.Map pidNameMap, java.util.Map forkMap)
          Parses the ps.log file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PsParser

public PsParser()
Method Detail

parseLog

public static PsParser.PsStats parseLog(java.io.InputStream is,
                                        java.util.Map pidNameMap,
                                        java.util.Map forkMap)
                                 throws java.io.IOException
Parses the ps.log file. Consecutive ps samples are parsed and returned in a list. The ps samples are only parsed up to the point where one of the specified exitProcesses is running and the system is idle.

If pidNameMap is set, it is used to map PIDs to command names. This is useful when init scripts are sourced, and thus ps is unable to report the proper process name. A sysinit modification is necessary to generate the mapping log file.

forkMap is an optional map that provides detailed information about process forking.

Parameters:
is - the input stream to read from
pidNameMap - PID to name mapping map (optional)
forkMap - process forking map (optional)
Returns:
ps statistics and a list of processes
Throws:
java.io.IOException - if an I/O error occurs

getState

public static int getState(java.util.Map procInfo)
Returns the process state. State can be one of:

Parameters:
procInfo - process info map
Returns:
process state