Home / Solaris 10 / Solaris Process Inspection Commands

Solaris Process Inspection Commands

Oracle Solaris provides many utilities for inspecting the state of process which are running on the system.Using the process inspection commands ,we can dig in to the process  in detail manner for in depth troubleshooting.Here we are going to see many process introspection command which will very handy on application trouble shooting.This article is based on Solaris internals book.
Please see the below table to know more about process introspection tools in Solaris.

table.tableizer-table { border: 1px solid #CCC; font-family: ; font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

Process Introspection tools
PTOOLS DESCRIPTION
pstack Process Stack:The stack of all or threads within a process can be displayed
pmap -x Process Memory Map:Inspects a process, displaying every mapping within the process’s address space
pfiles Process File Table:A list of files open within a process
ptime Execution Time Statistics for a Process
psig Process Signal Disposition
pldd Process Libraries
pflags Process Flags
pcred Process Credentials
pargs Process Arguments
pwdx Process Working Directory
Now we will how about each command in details and its use.
pstack:
pstack command displays the stack of all or threads within a process. It is very useful to find the root cause of process hung or coredump.It also very helpful to find the root cause of performance issues  by simply taking few samples of the process of stack.
# pstack 391
391: /usr/lib/sysevent/syseventd
----------------- lwp# 1 / thread# 1 --------------------
feeeaed5 pause ()
08052346 main (1, 8047e88, 8047e90) + 3d3
08051c7e ???????? (1, 8047f10, 0, 8047f2c, 8047f44, 8047f6a)
----------------- lwp# 2 / thread# 2 --------------------
feee7e99 lwp_park (0, 0, 0)
feedd624 sema_wait (8065d88) + d
080525da ???????? (0)
feee7b30 _thr_setup (fec30200) + 4e
feee7e20 _lwp_start (fec30200, 0, 0, fed3eff8, feee7e20, fec30200)
----------------- lwp# 3 / thread# 3 --------------------
feee7e99 lwp_park (0, 0, 0)
feee26a0 cond_wait_queue (8065de8, 8065cd0, 0) + 5e
feee2b74 _cond_wait (8065de8, 8065cd0) + 64
feee2bb6 cond_wait (8065de8, 8065cd0) + 21
08052b34 ???????? (0)
feee7b30 _thr_setup (fec30a00) + 4e
feee7e20 _lwp_start (fec30a00, 0, 0, fec2eff8, feee7e20, fec30a00)
----------------- lwp# 4 / thread# 4 --------------------
feeea2f5 sigtimedwait (feb2fee0, feb2fef0, 0)
feedcec1 sigwait (feb2ffc0) + 1c
feed50ea __posix_sigwait (feb2ffc0, feb2ffd4) + 2e
08051ed8 ???????? (0)
feee7b30 _thr_setup (fec31200) + 4e
feee7e20 _lwp_start (fec31200, 0, 0, feb2fff8, feee7e20, fec31200)


pmap -x:
Using pmap command,we can display every mapping within the process’s address space.
The amount of resident, non-shared anonymous, and locked memory is shown for each mapping.This allows you to estimate shared and private memory usage.
(Refer:Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture)

Resident (RSS)=Physical memory usage
Anon = private memory for this process instance.
# pmap -x 16480
16480: /usr/lib/ssh/sshd
Address Kbytes RSS Anon Locked Mode Mapped File
08043000 20 20 20 - rw--- [ stack ]08050000 308 268 - - r-x-- sshd
080AD000 12 12 12 - rw--- sshd
080B0000 108 108 88 - rw--- [ heap ]FE960000 64 64 64 - rwx-- [ anon ]FE980000 64 8 8 - rwx-- [ anon ]FE9A0000 64 28 28 - rwx-- [ anon ]FE9C0000 240 192 - - r-x-- pkcs11_softtoken_extra.so.1
FEA0C000 8 8 8 - rw--- pkcs11_softtoken_extra.so.1
FEA0E000 4 4 4 - rw--- pkcs11_softtoken_extra.so.1
-------- ------- ------- ------- -------
total Kb 4800 3616 408 -
# pmap  16480
16480: /usr/lib/ssh/sshd
08043000 20K rw--- [ stack ]08050000 308K r-x-- /usr/lib/ssh/sshd
080AD000 12K rw--- /usr/lib/ssh/sshd
080B0000 108K rw--- [ heap ]FE960000 64K rwx-- [ anon ]FE980000 64K rwx-- [ anon ]FE9A0000 64K rwx-- [ anon ]FE9C0000 240K r-x-- /usr/lib/security/pkcs11_softtoken_extra.so.1
FEA0C000 8K rw--- /usr/lib/security/pkcs11_softtoken_extra.so.1
FEA0E000 4K rw--- /usr/lib/security/pkcs11_softtoken_extra.so.1

pfiles:
Using pfiles command,we see all the files which are opened for that process id (pid).

# pfiles 16480
16480: /usr/lib/ssh/sshd
Current rlimit: 256 file descriptors
0: S_IFCHR mode:0666 dev:296,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:296,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:296,0 ino:6815752 uid:0 gid:3 rdev:13,2
O_RDWR|O_LARGEFILE
/devices/pseudo/mm@0:null
3: S_IFSOCK mode:0666 dev:303,0 ino:700 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK
SOCK_STREAM
SO_REUSEADDR,SO_KEEPALIVE,SO_SNDBUF(49152),SO_RCVBUF(49640),IP_NEXTHOP(232.193.0.0)
sockname: AF_INET6 ::ffff:192.168.56.130 port: 22
peername: AF_INET6 ::ffff:192.168.56.1 port: 57270
4: S_IFDOOR mode:0444 dev:305,0 ino:60 uid:0 gid:0 size:0
O_RDONLY|O_LARGEFILE FD_CLOEXEC door to nscd[405] /var/run/name_service_door
5: S_IFIFO mode:0000 dev:294,0 ino:47069 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC
6: S_IFIFO mode:0000 dev:294,0 ino:47073 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC
7: S_IFIFO mode:0000 dev:294,0 ino:47069 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK
8: S_IFIFO mode:0000 dev:294,0 ino:47073 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC

ptime:
Ptime is useful command to find the execution time statistics for a process.

# ptime sleep 1
real 1.003
user 0.000
sys 0.002

psig:
The psig used to list the signals and their current disposition.

# psig 16480
16480: /usr/lib/ssh/sshd
HUP caught 0x806de76 0
INT caught 0x806de76 0
QUIT default
ILL default
TRAP default
ABRT default
EMT default
FPE default
KILL default
BUS default
SEGV default
SYS default
PIPE ignored
ALRM default
TERM caught 0x806de76 0
USR1 default
USR2 default
CLD caught 0x806deac 0

pldd:
The pldd used to list of the  libraries currently mapped into a process.

# pldd 16480
16480: /usr/lib/ssh/sshd
/lib/libsocket.so.1
/lib/libnsl.so.1
/usr/lib/libz.so.1
/lib/libpam.so.1
/lib/libbsm.so.1
/usr/sfw/lib/libwrap.so.1.0
/usr/sfw/lib/libcrypto.so.0.9.7
/usr/lib/libgss.so.1
/lib/libcmd.so.1


pflags:
Pflags command output show various process status information.It help us to provide mode of the application whether 32-bit or 64-bit.

# pflags 16480
16480: /usr/lib/ssh/sshd
data model = _ILP32 flags = ORPHAN|MSACCT|MSFORK
/1: flags = ASLEEP pollsys(0x80473f0,0x2,0x0,0x0)


pcred:
If you want to know the credentials of running process ,use pcred to identify that.

# pcred 16480
16480: e/r/suid=0 e/r/sgid=0
groups: 0 1 2 3 4 5 6 7 8 9 12


pargs:
The pargs show full argument list and current environment settings.

# pargs 16480
16480: /usr/lib/ssh/sshd
argv[0]: /usr/lib/ssh/sshd

# pargs -ae 16480
16480: /usr/lib/ssh/sshd
argv[0]: /usr/lib/ssh/sshd

envp[0]: PATH=/usr/sbin:/usr/bin
envp[1]: SMF_FMRI=svc:/network/ssh:default
envp[2]: SMF_METHOD=/lib/svc/method/sshd start
envp[3]: SMF_RESTARTER=svc:/system/svc/restarter:default
envp[4]: TZ=Asia/Calcutta


pwdx:
Using the pwdx command ,we can determine the current working directory for process.

# pwdx 3229
3229: /
# pwdx 15150
15150: /export/zone/sollz1/root
# pwdx 3371
3371: /var/vx/vxdba


Hope you have learned more about Solaris process introspection tools.Please see the main page for more information.

Thank you for reading this article.Please leave a comment if you have any doubt.I will get back to you.

VMTURBO-CLOUD-CAPACITY

Leave a Reply

Your email address will not be published. Required fields are marked *