Processes

From Siwiki

Jump to: navigation, search

Contents

[edit] Why should I monitor Processes?

Monitoring process activity is a routine task during the administration of systems. Fortunately, a large number of tools examine process details, most of which make use of procfs. Many of these tools are suitable for troubleshooting application problems and for analyzing performance.

[edit] Which Tools Should I use for Process Analysis?

Since there are so many tools for process analysis, it can be helpful to group them into general categories.

  • Overall status tools - The prstat command immediately provides a by-process indication of CPU and memory consumption. prstat can also fetch microstate accounting details and by-thread details. The original command for listing process status is ps, the output of which can be customized.
  • Control tools - Various commands, such as pkill, pstop, prun and preap, control the state of a process. These commands can be used to repair application issues, especially runaway processes.
  • Introspection tools - Numerous commands, such as pstack, pmap, pfiles, and pargs inspect process details. pmap and pfiles examine the memory and file resources of a process; pstack can view the stack backtrace of a process and its threads, providing a glimpse of which functions are currently running.
  • Lock activity examination tools - Excessive lock activity and contention can be identified with the plockstat command and DTrace.
  • Tracing tools - Tracing system calls and function calls provides the best insight into process behavior. Solaris provides tools including truss, apptrace, and dtrace to trace processes.

The following table summarizes and cross-references the tools covered in this section.

Tools for Process Analysis
Tool Description
prstat For viewing overall process status
ps To print process status and information
ptree To print a process ancestry tree
pgrep; pkill To match a process name; to send a signal
pstop; prun To freeze a process; to continue a process
pwait To wait for a process to finish
preap To reap zombies
pstack For inspecting stack backtraces
pmap For viewing memory segment details
pfiles For listing file descriptor details
ptime For timing a command
psig To list signal handlers
pldd To list dynamic libraries
pflags; pcred To list tracing flags; to list process credentials
pargs; pwdx To list arguments, env; to list working directory
plgrp To list and change home lgroup and lgroup affinity
pmadvise To apply madvise(3C) to nenory segments of a process
plockstat For observing lock activity
truss For tracing system calls and signals, and tracing function calls with primitive detail
apptrace For tracing library calls with processed details
dtrace For safely tracing any process activity, with minimal effect on the process and system


Many of these tools read statistics from the /proc file system, procfs. See Solaris Internals Second Edition, Section 2.10 , "The Process File System," on page 115 which discusses procfs from introduction to implementation. Also refer to /usr/include/sys/procfs.h and the proc(4) man page.

[edit] Process Statistics Summary: prstat

The process statistics utility, prstat, shows us a top-level summary of the processes that are using system resources. The prstat utility summarizes this information every 5 seconds by default and reports the statistics for that period.

$ prstat
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
 25646 rmc      1613M   42M cpu15    0   10   0:33:10 3.1% filebench/2
 25661 rmc      1613M   42M cpu8     0   10   0:33:11 3.1% filebench/2
 25652 rmc      1613M   42M cpu20    0   10   0:33:09 3.1% filebench/2
 25647 rmc      1613M   42M cpu0     0   10   0:33:10 3.1% filebench/2
 25641 rmc      1613M   42M cpu27    0   10   0:33:10 3.1% filebench/2
 25656 rmc      1613M   42M cpu7     0   10   0:33:10 3.1% filebench/2
 25634 rmc      1613M   42M cpu11    0   10   0:33:11 3.1% filebench/2
 25637 rmc      1613M   42M cpu17    0   10   0:33:10 3.1% filebench/2
 25643 rmc      1613M   42M cpu12    0   10   0:33:10 3.1% filebench/2
 25648 rmc      1613M   42M cpu1     0   10   0:33:10 3.1% filebench/2
 25640 rmc      1613M   42M cpu26    0   10   0:33:10 3.1% filebench/2
 25651 rmc      1613M   42M cpu31    0   10   0:33:10 3.1% filebench/2
 25654 rmc      1613M   42M cpu29    0   10   0:33:10 3.1% filebench/2
 25650 rmc      1613M   42M cpu5     0   10   0:33:10 3.1% filebench/2
 25653 rmc      1613M   42M cpu10    0   10   0:33:10 3.1% filebench/2
 25638 rmc      1613M   42M cpu18    0   10   0:33:10 3.1% filebench/2
 25660 rmc      1613M   42M cpu13    0   10   0:33:10 3.1% filebench/2
 25635 rmc      1613M   42M cpu25    0   10   0:33:10 3.1% filebench/2
 25642 rmc      1613M   42M cpu28    0   10   0:33:10 3.1% filebench/2
 25649 rmc      1613M   42M cpu19    0   10   0:33:08 3.1% filebench/2
 25645 rmc      1613M   42M cpu3     0   10   0:33:10 3.1% filebench/2
 25657 rmc      1613M   42M cpu4     0   10   0:33:09 3.1% filebench/2
Total: 91 processes, 521 lwps, load averages: 29.06, 28.84, 26.68

The default output for prstat shows one line of output per process. Entries are sorted by CPU consumption. The columns are as follows:

  • PID - The process ID of the process.
  • USERNAME - The real user (login) name or real user ID.
  • SIZE - The total virtual memory size of mappings within the process, including all mapped files and devices.
  • RSS - Resident set size. The amount of physical memory mapped into the process, including that shared with other processes. See "Process Virtual and Resident Set Size" on page 165.
  • STATE - The state of the process. See Solaris Internals Second Edition, Section , "Scheduling Classes and the Dispatcher," on page 167.
  • PRI - The priority of the process. Larger numbers mean higher priority. See Solaris Internals Second Edition, Section 3.7 , "Thread Priorities," on page 224.
  • NICE - Nice value used in priority computation. See Solaris Internals Second Edition, Section 3.7 , "Thread Priorities," on page 224.
  • TIME - The cumulative execution time for the process, printed in CPU hours, minutes, and seconds.
  • CPU - The percentage of recent CPU time used by the process.
  • PROCESS/NLWP - The name of the process (name of executed file) and the number of threads in the process.

[edit] Thread Summary: prstat -L

The -L option causes prstat to show one thread per line instead of one process per line.

$ prstat -L
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/LWPID
 25689 rmc      1787M  217M sleep   59    0   0:00:08 0.1% filebench/1
 25965 rmc      1785M  214M cpu22   60   10   0:00:00 0.1% filebench/2
 26041 rmc      1785M  214M cpu4    60   10   0:00:00 0.0% filebench/2
 26016 rmc      1785M  214M sleep   60   10   0:00:00 0.0% filebench/2
     9 root       10M 9648K sleep   59    0   0:00:14 0.0% svc.configd/14
     9 root       10M 9648K sleep   59    0   0:00:26 0.0% svc.configd/12
 26174 rmc      5320K 5320K cpu30   59    0   0:00:00 0.0% prstat/1
     9 root       10M 9648K sleep   59    0   0:00:36 0.0% svc.configd/10
     7 root       19M   17M sleep   59    0   0:00:11 0.0% svc.startd/9
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/12
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/11
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/10
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/9
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/8
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/7
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/6
    93 root     2600K 1904K sleep   59    0   0:00:00 0.0% syseventd/5
...

The output is similar to the previous example, but the last column is now represented by process name and thread number:

  • PROCESS/LWPID - The name of the process (name of executed file) and the lwp ID of the lwp being reported.

[edit] Process Microstates: prstat -m

The process microstates can be very useful to help identify why a process or thread is performing suboptimally. By specifying the -m (show microstates) and -L (show per-thread) options, you can observe the per-thread microstates. The microstates represent a time-based summary broken into percentages of each thread. The columns USR through LAT sum to 100% of the time spent for each thread during the prstat sample.

$ prstat -mL
   PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID
 25644 rmc       98 1.5 0.0 0.0 0.0 0.0 0.0 0.1   0  36 693   0 filebench/2
 25660 rmc       98 1.7 0.1 0.0 0.0 0.0 0.0 0.1   2  44 693   0 filebench/2
 25650 rmc       98 1.4 0.1 0.0 0.0 0.0 0.0 0.1   0  45 699   0 filebench/2
 25655 rmc       98 1.4 0.1 0.0 0.0 0.0 0.0 0.2   0  46 693   0 filebench/2
 25636 rmc       98 1.6 0.1 0.0 0.0 0.0 0.0 0.2   1  50 693   0 filebench/2
 25651 rmc       98 1.6 0.1 0.0 0.0 0.0 0.0 0.2   0  54 693   0 filebench/2
 25656 rmc       98 1.5 0.1 0.0 0.0 0.0 0.0 0.2   0  60 693   0 filebench/2
 25639 rmc       98 1.5 0.1 0.0 0.0 0.0 0.0 0.2   1  61 693   0 filebench/2
 25634 rmc       98 1.3 0.1 0.0 0.0 0.0 0.0 0.4   0  63 693   0 filebench/2
 25654 rmc       98 1.3 0.1 0.0 0.0 0.0 0.0 0.4   0  67 693   0 filebench/2
 25659 rmc       98 1.7 0.1 0.0 0.0 0.0 0.0 0.4   1  68 693   0 filebench/2
 25647 rmc       98 1.5 0.1 0.0 0.0 0.0 0.0 0.4   0  73 693   0 filebench/2
 25648 rmc       98 1.6 0.1 0.0 0.0 0.0 0.3 0.2   2  48 693   0 filebench/2
 25643 rmc       98 1.6 0.1 0.0 0.0 0.0 0.0 0.5   0  75 693   0 filebench/2
 25642 rmc       98 1.4 0.1 0.0 0.0 0.0 0.0 0.5   0  80 693   0 filebench/2
 25638 rmc       98 1.4 0.1 0.0 0.0 0.0 0.0 0.6   0  76 693   0 filebench/2
 25657 rmc       97 1.8 0.1 0.0 0.0 0.0 0.4 0.3   6  64 693   0 filebench/2
 25646 rmc       97 1.7 0.1 0.0 0.0 0.0 0.0 0.6   6  83 660   0 filebench/2
 25645 rmc       97 1.6 0.1 0.0 0.0 0.0 0.0 0.9   0  55 693   0 filebench/2
 25652 rmc       97 1.7 0.2 0.0 0.0 0.0 0.0 0.9   2 106 693   0 filebench/2
 25658 rmc       97 1.5 0.1 0.0 0.0 0.0 0.0 1.0   0  72 693   0 filebench/2
 25637 rmc       97 1.7 0.1 0.0 0.0 0.0 0.3 0.6   4  95 693   0 filebench/2
Total: 91 processes, 510 lwps, load averages: 28.94, 28.66, 24.39

As discussed in "CPU Run Queue Latency" on page 24, you can use the USR and SYS states to see what percentage of the elapsed sample interval a process spent on the CPU, and LAT as the percentage of time waiting for CPU. Likewise, you can use the TFL and DTL to determine if and by how much a process is waiting for memory paging-see "Using prstat to Estimate Memory Slowdowns" on page 164. The remainder of important events such as disk and network waits are bundled into the SLP state, along with other kernel wait events. While SLP column is inclusive of disk I/O, other types of blocking can cause time to be spent in the SLP state. For example, kernel locks or condition variables also accumulate time in this state.

[edit] Sorting by a Key: prstat -s

The output from prstat can be sorted by a set of keys, as directed by the -s option. For example, if we want to show processes with the largest physical memory usage, we can use prstat -s rss.

$ prstat -s rss  
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
 20340 ftp       183M  176M sleep   59    0   0:00:24 0.0% httpd/1
  4024 daemon     11M   10M sleep   59    0   0:00:06 0.0% nfsmapid/19
  2632 daemon     11M 9980K sleep   59    0   0:00:06 0.0% nfsmapid/5
     7 root       10M 9700K sleep   59    0   0:00:05 0.0% svc.startd/14
     9 root     9888K 8880K sleep   59    0   0:00:08 0.0% svc.configd/46
 21091 ftp        13M 8224K sleep   59    0   0:00:00 0.0% httpd/1
   683 root     7996K 7096K sleep   59    0   0:00:07 0.0% svc.configd/16
   680 root     7992K 7096K sleep   59    0   0:00:07 0.0% svc.configd/15
   671 root     7932K 7068K sleep   59    0   0:00:04 0.0% svc.startd/13
   682 root     7956K 7064K sleep   59    0   0:00:07 0.0% svc.configd/43
   668 root     7924K 7056K sleep   59    0   0:00:03 0.0% svc.startd/13
   669 root     7920K 7056K sleep   59    0   0:00:03 0.0% svc.startd/15
   685 root     7876K 6980K sleep   59    0   0:00:07 0.0% svc.configd/15
   684 root     7824K 6924K sleep   59    0   0:00:07 0.0% svc.configd/16
   670 root     7796K 6924K sleep   59    0   0:00:03 0.0% svc.startd/12
   687 root     7712K 6816K sleep   59    0   0:00:07 0.0% svc.configd/17
   664 root     7668K 6756K sleep   59    0   0:00:03 0.0% svc.startd/12
   681 root     7644K 6752K sleep   59    0   0:00:08 0.0% svc.configd/13
   686 root     7644K 6744K sleep   59    0   0:00:08 0.0% svc.configd/17
...

The following are valid keys for sorting:

  • cpu - Sort by process CPU usage. This is the default.
  • pri - Sort by process priority.
  • rss - Sort by resident set size.
  • size - Sort by size of process image.
  • time - Sort by process execution time.

The -S option sorts by ascending order, rather than descending.

[edit] User Summary: prstat -t

A summary by user ID can be printed with the -t option.

$ prstat -t
 NPROC USERNAME  SIZE   RSS MEMORY      TIME  CPU
   233 root      797M  477M    48%   0:05:31 0.4%
    50 daemon    143M   95M   9.6%   0:00:12 0.0%
    14 40000     112M   28M   2.8%   0:00:00 0.0%
     2 rmc      9996K 3864K   0.4%   0:00:04 0.0%
     2 ftp       196M  184M    19%   0:00:24 0.0%
     2 50000    4408K 2964K   0.3%   0:00:00 0.0%
    18 nobody    104M   51M   5.2%   0:00:00 0.0%
     8 webservd   48M   21M   2.1%   0:00:00 0.0%
     7 smmsp      47M   10M   1.0%   0:00:00 0.0%
Total: 336 processes, 1201 lwps, load averages: 0.02, 0.01, 0.01

[edit] Project Summary: prstat -J

A summary by project ID can be generated with the -J option. This is very useful for summarizing per-project resource utilization. See Solaris Internals Second Edition, Chapter 7, "Projects, Tasks, and Resource Controls" for information about using projects.

$ prstat -J
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
 21130 root     4100K 3264K cpu0    59    0   0:00:00 0.2% prstat/1
 21109 root     7856K 2052K sleep   59    0   0:00:00 0.0% sshd/1
 21111 root     1200K  952K sleep   59    0   0:00:00 0.0% ksh/1
  2632 daemon     11M 9980K sleep   59    0   0:00:06 0.0% nfsmapid/5
   118 root     3372K 2372K sleep   59    0   0:00:06 0.0% nscd/24
PROJID    NPROC  SIZE   RSS MEMORY      TIME  CPU PROJECT
     3        8   39M   18M   1.8%   0:00:00 0.2% default
     0      323 1387M  841M    85%   0:05:58 0.0% system     
    10        3   18M 8108K   0.8%   0:00:04 0.0% group.staff
     1        2   19M 6244K   0.6%   0:00:09 0.0% user.root     
Total: 336 processes, 1201 lwps, load averages: 0.02, 0.01, 0.01

[edit] Zone Summary: prstat -Z

The -Z option provides a summary per zone. See Solaris Internals Second Edition, Chapter 6, "Zones" for more information about Solaris Zones.

$ prstat -Z
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
 21132 root     2952K 2692K cpu0    49    0   0:00:00 0.1% prstat/1
 21109 root     7856K 2052K sleep   59    0   0:00:00 0.0% sshd/1
  2179 root     4952K 2480K sleep   59    0   0:00:21 0.0% automountd/3
 21111 root     1200K  952K sleep   49    0   0:00:00 0.0% ksh/1
  2236 root     4852K 2368K sleep   59    0   0:00:06 0.0% automountd/3
  2028 root     4912K 2428K sleep   59    0   0:00:10 0.0% automountd/3
   118 root     3372K 2372K sleep   59    0   0:00:06 0.0% nscd/24
ZONEID    NPROC  SIZE   RSS MEMORY      TIME  CPU ZONE  
     0       47  177M  104M    11%   0:00:31 0.1% global 
     5       33  302M  244M    25%   0:01:12 0.0% gallery
     3       40  161M   91M   9.2%   0:00:40 0.0% nakos          
     4       43  171M   94M   9.5%   0:00:44 0.0% mcdougallfamily
     2       30   96M   56M   5.6%   0:00:23 0.0% shared
     1       32  113M   60M   6.0%   0:00:45 0.0% packer
     7       43  203M   87M   8.7%   0:00:55 0.0% si            
Total: 336 processes, 1202 lwps, load averages: 0.02, 0.01, 0.01

[edit] Tools for Listing and Controlling Processes

Solaris provides a set of tools for listing and controlling processes. The general syntax is as follows:

$ ptool pid
$ ptool pid/lwpid

The following is a summary for each. Refer to the man pages for additional details.

[edit] Process tree: ptree

The process parent-child relationship can be displayed with the ptree command. By default, all processes within the same process group ID are displayed. See Solaris Internals Second Edition, Section 2.12 , "Sessions and Process Groups," on page 157 for information about how processes are grouped in Solaris.

$ ptree 22961
301   /usr/lib/ssh/sshd
  21571 /usr/lib/ssh/sshd
    21578 /usr/lib/ssh/sshd
      21580 -ksh
        22961 /opt/filebench/bin/filebench
          22962 shadow -a shadow -i 1 -s ffffffff10000000 -m /var/tmp/fbench9Ca
          22963 shadow -a shadow -i 2 -s ffffffff10000000 -m /var/tmp/fbench9Ca
          22964 shadow -a shadow -i 3 -s ffffffff10000000 -m /var/tmp/fbench9Ca
          22965 shadow -a shadow -i 4 -s ffffffff10000000 -m /var/tmp/fbench9Ca
...

[edit] Grepping for Processes: pgrep

The pgrep command provides a convenient way to produce a process ID list matching certain criteria.

$ pgrep filebench
22968
22961
22966
22979
...

The search term will do partial matching, which can be disabled with the -x option (exact match). The -l option lists matched process names.

[edit] Killing Processes: pkill

The pkill command provides a convenient way to send signals to a list or processes matching certain criteria.

$ pkill -HUP in.named

If the signal is not specified, the default is to send a SIGTERM. Typing pkill d by accident as root may have a disastrous effect; it will match every process containing a "d" (which is usually quite a lot) and send them all a SIGTERM. Due to the way pkill doesn't use getopt() for the signal, aliasing isn't perfect; and writing a shell function is non-trivial.

[edit] Temporarily Stop a Process: pstop

A process can be temporarily suspended with the pstop command.

$ pstop 22961

[edit] Making a Process Runnable: prun

A process can be made runnable with the prun command.

$ prun 22961

[edit] Wait for Process Completion: pwait

The pwait command blocks and waits for termination of a process.

$ pwait 22961
(sleep...)

[edit] Reap a Zombie Process: preap

A zombie process can be reaped with the preap command, which was added in Solaris 9.

$ preap 22961
(sleep...)

[edit] Process Introspection Commands

Solaris provides a set of utilities for inspecting the state of processes. Most of the introspection tools can be used either on a running process or postmortem on a core file resulting from a process dump.The general syntax is as follows:

$ ptool pid
$ ptool pid/lwpid
$ ptool core

See the man pages for each of these tools for additional details.

[edit] Process Stack: pstack

The stacks of all or specific threads within a process can be displayed with the pstack command.

$ pstack 23154
23154:  shadow -a shadow -i 193 -s ffffffff10000000 -m /var/tmp/fbench9Cai2S
-----------------  lwp# 1 / thread# 1  --------------------
 ffffffff7e7ce0f4 lwp_wait (2, ffffffff7fffe9cc)
 ffffffff7e7c9528 _thrp_join (2, 0, 0, 1, 100000000, ffffffff7fffe9cc)   38
 0000000100018300 threadflow_init (ffffffff3722f1b0, ffffffff10000000, 10006a658, 0, 0, 1000888b0)   184
 00000001000172f8 procflow_exec (6a000, 10006a000, 0, 6a000, 5, ffffffff3722f1b0)   15c
 0000000100026558 main (a3400, ffffffff7ffff948, ffffffff7fffeff8, a4000, 0, 1)   414
 000000010001585c _start (0, 0, 0, 0, 0, 0)   17c
-----------------  lwp# 2 / thread# 2  --------------------
 000000010001ae90 flowoplib_hog (30d40, ffffffff651f3650, 30d40, ffffffff373aa3b8, 1, 2e906)   68
 00000001000194a4 flowop_start (ffffffff373aa3b8, 0, 1, 0, 1, 1000888b0)   408
 ffffffff7e7ccea0 _lwp_start (0, 0, 0, 0, 0, 0)

The pstack command can be very useful for diagnosing process hangs or the status of core dumps. By default it shows a stack backtrace for all the threads within a process. It can also be used as a crude performance analysis technique; by taking a few samples of the process stack, you can often determine where the process is spending most of its time. You can also dump a specific thread's stacks by supplying the lwpid on the command line.

sol8$ pstack 26258/2
26258:  shadow -a shadow -i 62 -s ffffffff10000000 -m /var/tmp/fbenchI4aGkZ
-----------------  lwp# 2 / thread# 2  --------------------
 ffffffff7e7ce138 lwp_mutex_timedlock (ffffffff10000060, 0)
 ffffffff7e7c4e8c mutex_lock_internal (ffffffff10000060, 0, 0, 1000, ffffffff7e8eef80, ffffffff7f402400)   248
 000000010001da3c ipc_mutex_lock (ffffffff10000060, 1000888b0, 100088800, 88800, 100000000, 1)   4
 0000000100019d94 flowop_find (ffffffff651e2278, 100088800, ffffffff651e2180, 88800, 100000000, 1)   34
 000000010001b990 flowoplib_sempost (ffffffff3739a768, ffffffff651e2180, 0, 6ac00, 1, 1)   4c
 00000001000194a4 flowop_start (ffffffff3739a768, 0, 1, 0, 1, 1000888b0)   408
 ffffffff7e7ccea0 _lwp_start (0, 0, 0, 0, 0, 0)

[edit] Process Memory Map: pmap -x

The pmap command inspects a process, displaying every mapping within the process's address space. The amount of resident, nonshared anonymous, and locked memory is shown for each mapping. This allows you to estimate shared and private memory usage.

 sol9$ pmap -x 102908
 102908:   sh
 Address   Kbytes Resident   Anon  Locked Mode   Mapped File
 00010000      88      88       -       - r-x--  sh
 00036000       8       8       8       - rwx--  sh
 00038000      16      16      16       - rwx--    [ heap ]
 FF260000      16      16       -       - r-x--  en_.so.2  
 FF272000      16      16       -       - rwx--  en_US.so.2
 FF280000     664     624       -       - r-x--  libc.so.1
 FF336000      32      32       8       - rwx--  libc.so.1
 FF360000      16      16       -       - r-x--  libc_psr.so.1
 FF380000      24      24       -       - r-x--  libgen.so.1
 FF396000       8       8       -       - rwx--  libgen.so.1
 FF3A0000       8       8       -       - r-x--  libdl.so.1
 FF3B0000       8       8       8       - rwx--    [ anon ]
 FF3C0000     152     152       -       - r-x--  ld.so.1
 FF3F6000       8       8       8       - rwx--  ld.so.1
 FFBFE000       8       8       8       - rw---    [ stack ]
 --------   -----   -----   -----   ------
 total Kb    1072    1032      56       -

This example shows the address space of a Bourne shell, with the executable at the top and the stack at the bottom. The total Resident memory is 1032 Kbytes, which is an approximation of physical memory usage. Much of this memory will be shared by other processes mapping the same files. The total Anon memory is 56 Kbytes, which is an indication of the private memory for this process instance. You can find more information on interpreting pmap -x output in "Using pmap to Inspect Process Memory Usage" on page 166.

[edit] Process File Table: pfiles

A list of files open within a process can be obtained with the pfiles command.

sol10# pfiles 21571
21571:  /usr/lib/ssh/sshd
  Current rlimit: 256 file descriptors
   0: S_IFCHR mode:0666 dev:286,0 ino:6815752 uid:0 gid:3 rdev:13,2
      O_RDWR|O_LARGEFILE
      /devices/pseudo/mm@0:null
   1: S_IFCHR mode:0666 dev:286,0 ino:6815752 uid:0 gid:3 rdev:13,2
      O_RDWR|O_LARGEFILE
      /devices/pseudo/mm@0:null
   2: S_IFCHR mode:0666 dev:286,0 ino:6815752 uid:0 gid:3 rdev:13,2
      O_RDWR|O_LARGEFILE
      /devices/pseudo/mm@0:null
   3: S_IFCHR mode:0000 dev:286,0 ino:38639 uid:0 gid:0 rdev:215,2
      O_RDWR FD_CLOEXEC
      /devices/pseudo/crypto@0:crypto
   4: S_IFIFO mode:0000 dev:294,0 ino:13099 uid:0 gid:0 size:0
      O_RDWR|O_NONBLOCK FD_CLOEXEC
   5: S_IFDOOR mode:0444 dev:295,0 ino:62 uid:0 gid:0 size:0
      O_RDONLY|O_LARGEFILE FD_CLOEXEC  door to nscd[89]
      /var/run/name_service_door
   6: S_IFIFO mode:0000 dev:294,0 ino:13098 uid:0 gid:0 size:0
      O_RDWR|O_NONBLOCK FD_CLOEXEC
   7: S_IFDOOR mode:0644 dev:295,0 ino:55 uid:0 gid:0 size:0
      O_RDONLY FD_CLOEXEC  door to keyserv[169]
      /var/run/rpc_door/rpc_100029.1
   8: S_IFCHR mode:0000 dev:286,0 ino:26793 uid:0 gid:0 rdev:41,134
      O_RDWR FD_CLOEXEC
      /devices/pseudo/udp@0:udp
   9: S_IFSOCK mode:0666 dev:292,0 ino:31268 uid:0 gid:0 size:0
      O_RDWR|O_NONBLOCK
        SOCK_STREAM
        SO_REUSEADDR,SO_KEEPALIVE,SO_SNDBUF(49152),SO_RCVBUF(49640)
        sockname: AF_INET6 ::ffff:129.146.238.66  port: 22
        peername: AF_INET6 ::ffff:129.146.206.91  port: 63374
  10: S_IFIFO mode:0000 dev:294,0 ino:13098 uid:0 gid:0 size:0
      O_RDWR|O_NONBLOCK
  11: S_IFIFO mode:0000 dev:294,0 ino:13099 uid:0 gid:0 size:0
      O_RDWR|O_NONBLOCK FD_CLOEXEC

The Solaris 10 version of pfiles prints path names if possible.

[edit] Execution Time Statistics for a Process: ptime

A process can be timed with the ptime command for accurate microstate accounting instrumentation.

$ ptime sleep 1
real        1.203
user        0.022
sys         0.140

[edit] Process Signal Disposition: psig

A list of the signals and their current disposition can be displayed with psig.

sol8$ psig $$
15481:	-zsh
HUP	caught	0
INT	blocked,caught	0
QUIT	blocked,ignored
ILL	blocked,default
TRAP	blocked,default
ABRT	blocked,default
EMT	blocked,default
FPE	blocked,default
KILL	default
BUS	blocked,default
SEGV	blocked,default
SYS	blocked,default
PIPE	blocked,default
ALRM	blocked,caught	0
TERM	blocked,ignored
USR1	blocked,default
USR2	blocked,default
CLD	caught	0
PWR	blocked,default
WINCH	blocked,caught	0
URG	blocked,default
POLL	blocked,default
STOP	default

[edit] Process Libraries: pldd

A list of the libraries currently mapped into a process can be displayed with pldd. This is useful for verifying which version or path of a library is being dynamically linked into a process.

sol8$ pldd $$
482764: -ksh
/usr/lib/libsocket.so.1
/usr/lib/libnsl.so.1
/usr/lib/libc.so.1
/usr/lib/libdl.so.1
/usr/lib/libmp.so.2

[edit] Process Flags: pflags

The pflags command shows a variety of status information for a process. Information includes the mode-32-bit or 64-bit-in which the process is running and the current state for each thread within the process (see Solaris Internals Second Edition, Section 3.1 , "Fundamentals," on page 168 for information on thread state). In addition, the top-level function on each thread's stack is displayed.

sol8$ pflags $$
482764: -ksh
	data model = _ILP32  flags = PR_ORPHAN
  /1:	flags = PR_PCINVAL|PR_ASLEEP [ waitid(0x7,0x0,0xffbff938,0x7) ]

[edit] Process Credentials: pcred

The credentials for a process can be displayed with pcred.

sol8$ pcred $$
482764: e/r/suid=36413  e/r/sgid=10
        groups: 10 10512 570

[edit] Process Arguments: pargs

The full process arguments and optionally a list of the current environment settings can be displayed for a process with the pargs command.

$ pargs -ae 22961
22961:  /opt/filebench/bin/filebench
argv[0]: /opt/filebench/bin/filebench
envp[0]: _=/opt/filebench/bin/filebench
envp[1]: MANPATH=/usr/man:/usr/dt/man:/usr/local/man:/opt/SUNWspro/man:/ws/on998-tools/teamware/man:/home/rmc/local/man
envp[2]: VISUAL=/bin/vi
...

[edit] Process Working Directory: pwdx

The current working directory of a process can be displayed with the pwdx command.

$ pwdx  22961    
22961:  /tmp/filebench

[edit] Lgroups: plgrp

The home lgroup and lgroup affinities of threads can be observed and affected with the plgrp command.

$ plgrp $$
     PID/LWPID    HOME
   24464/1        2     
$ plgrp -H 1 $$
     PID/LWPID    HOME
   24464/1        2 => 1     
$  plgrp -a all $$
     PID/LWPID    HOME  AFFINITY
   24464/1        1     0-2/none
$ plgrp -A 2/strong $$
     PID/LWPID    HOME       AFFINITY
   24464/1        1 => 2     2/none => 2/strong

[edit] Memory advise: pmadvise

The madvise(3C) can be applied to memory segments of a running process with pmadvise.

$ pmadvise -v -o heap=access_lwp $$
24464:  bash
08044000      16K rw---    [ stack ]
08050000     588K r-x--  /usr/bin/bash
080F2000      76K rwx--  /usr/bin/bash
08105000     308K rwx--    [ heap ]     <= access_lwp
BFD23000       4K rwxs-    [ anon ]
BFD30000      64K rwx--    [ anon ]
BFD50000      24K rwx--    [ anon ]
BFD60000     916K r-x--  /lib/libc.so.1
BFE55000      28K rw---  /lib/libc.so.1
BFE5C000       8K rw---    [ anon ]
BFE70000       4K rwx--    [ anon ]
BFE80000     568K r-x--  /lib/libnsl.so.1
BFF1E000      20K rw---  /lib/libnsl.so.1
BFF23000      24K rw---    [ anon ]
BFF30000      48K r-x--  /lib/libsocket.so.1
BFF4C000       4K rw---  /lib/libsocket.so.1
BFF50000     160K r-x--  /lib/libcurses.so.1
BFF88000      28K rw---  /lib/libcurses.so.1
BFF8F000       8K rw---    [ anon ]
BFFA0000       4K r-x--  /lib/libdl.so.1
BFFB0000       4K rwx--    [ anon ]
BFFC2000     164K r-x--  /lib/ld.so.1
BFFFB000       4K rwx--  /lib/ld.so.1
BFFFC000       8K rwx--    [ anon ]
Solaris Internals
Personal tools
The Books
The Ads