org.bootchart.parser.linux

## Class ProcPsParser

- java.lang.Object
- - org.bootchart.parser.linux.ProcPsParser

-     public class ProcPsParser
      extends java.lang.Object

  ProcPsParser parses log files produced by logging the output of `/proc/[PID]/stat` files. The samples contain status information about processes (PID, command, state, PPID, user and system CPU times, etc.).

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProcPsParser()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getState(java.lang.String state)` Returns the process state.
    `static PsStats` | `parseLog(java.io.InputStream is, java.util.Map pidNameMap, java.util.Map forkMap)` Parses the `proc_ps.log` file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ProcPsParser

          public ProcPsParser()

  - ### Method Detail

    - #### parseLog

          public static PsStats parseLog(java.io.InputStream is,
                                         java.util.Map pidNameMap,
                                         java.util.Map forkMap)
                                  throws java.io.IOException

      Parses the `proc_ps.log` file. The output from `/proc/[PID]stat` is used to collect process information.

      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:
        process statistics
      Throws:
        `java.io.IOException` - if an I/O error occurs

    - #### getState

          public static int getState(java.lang.String state)

      Returns the process state. State can be one of:
      - "D": uninterruptible sleep
      - "R": running
      - "S": sleeping
      - "T": traced or stopped
      - "Z": zombie
      Parameters:
        `state` - process state string
      Returns:
        process state