Process Introspection

Process Introspection

The next step in a performance analysis is to figure out what the application is doing. Configuring application is one thing. Checking if the application actually pulled all configration information is another thing. The tools below tell you what your application is doing.

Solaris provides a large collection of tools to list and control processes. For an overview and detailed description, please refer to the manual pages of proc(1). The following chapter introduces the most commonly used commands.

pgrep – Find Processes by Name and other Attributes

The pgrep command finds processes by name and other attributes. For that, the pgrep utility examines the active processes on the system and reports the process IDs of the processes whose attributes match the criteria specified on the command line. Each process ID is printed as a decimal value and is separated from the next ID by a delimiter string, which defaults to a newline.

pgrep – find processes by name and other attributes

pkill – Signal Processes by Name and other Attributes

The pkill signals processes by name and other attributes. pkill functions identically to pgrep, except that each matching process is signaled as if by kill(1) instead of having its process ID printed. A signal name or number may be specified as the first command line option to pkill.

pkill – signal processes by name and other attributes

ptree - Print Process Trees

The ptree prints parent-child relationship of processes. For that, it prints the process trees containing the specified pids or users, with child processes indented from their respective parent processes. An argument of all digits is taken to be a process-ID, otherwise it is assumed to be a user login name. The default is all processes.

ptree – no options

sta [Tools CD] – Print Process Trees

The sta tool provides similar output to ptree. See example run below.

sta – sample output

pargs - Print Process Arguments, Environment, or auxiliary Vector

The pargs utility examines a target process or process core file and prints arguments, environment variables and values, or the process auxiliary vector.

pargs – sample output

pfiles – Report on open Files in Process

The pfiles command reports fstat(2) and fcntl(2) information for all open files in each process. In addition, a path to the file is reported if the information is available from /proc/pid/path. This is not necessarily the same name used to open the file. See proc(4) for more information.

pfiles – sample output

pstack – Print lwp/process Stack Trace

The pstack command prints a hex+symbolic stack trace for each process or specified lwps in each process.

Note: use jstack for java processes

pstack – sample output

jstack – Print Java Thread Stack Trace [see $JAVA_HOME/bin]

The jstack command prints Java stack traces of Java threads for a given Java process or core file or a remote debug server. For each Java frame, the full class name, method name, 'bci' (byte code index) and line number, if available, are printed.

jstack – sample output

pwdx – Print Process current Working Directory

The pwdx utility prints the current working directory of each process.

pwdx – sample output

pldd – Print Process dynamic Libraries

The pldd command lists the dynamic libraries linked into each process, including shared objects explicitly attached using dlopen(3C). See also ldd(1).

pldd – sample output

pmap - Display Information about the Address Space of a Process

The pmap utility prints information about the address space of a process. By default, pmap displays all of the mappings in the virtual address order they are mapped into the process. The mapping size, flags and mapped object name are shown.

pmap – default output

An extended output is available by adding the -x option (additional information about each mapping) and the -s option (additional HAT size information).

pmap – extended output

showmem [Tools CD] – Process private and shared Memory usage

The showmem utility wraps around pmap and ps todetermine how much private and shared memory a process is using.

showmem – sample output

plimit - Get or set the Resource Limits of running Processes

In the first form, the plimit utility prints the resource limits of running processes.

plimit – displaying process resource limits

 

In the second form, the plimit utility sets the soft (current) limit and/or the hard (maximum) limit of the indicated resource(s) in the processes identified by the process-ID list, pid. As an example, let's limit the current (soft) core file size of the trashapplet process with PID 897 to five (5) MB, using the command: plimit -c 5m,unlimited 897.

plimit – setting the current (soft) core file limit to 5 MB 

Thomas Bastian was a coauthor of an earlier version of this document. The earlier version of this page has been published in the "The Developers Edge" in 2009.

Stefan Schneider Sat, 06/05/2010 - 14:42