Only for Solaris Users
This commands are very helpful when you need to debug your application or If you want to monitor application performances.
System and process monitoring commands
- prstat
- ptree
- pstack
- pkill
- pmap
- pfiles
prstat
prstat is a process statistic monitoring utility. It shows CPU utilization, memory usage, user, process ID and few other information of each process.
Example:
$ prstat
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
28465 ex19 46M 44M sleep 59 0 0:17:22 0.3% WSA/1
21861 ex19 67M 50M sleep 59 0 0:17:23 0.3% SHU/1
28385 ex19 120M 101M sleep 59 0 0:15:08 0.2% OrderC/5
4420 ex7 141M 121M sleep 59 0 0:01:29 0.2% FDriver_/4
21784 ex19 12M 11M sleep 59 0 0:14:44 0.2% SGA/1
17050 ex7 120M 96M sleep 59 0 0:03:24 0.2% Orche/5
16684 ex7 18M 16M sleep 59 0 0:02:50 0.2% SGA/1
17413 ex7 121M 97M sleep 59 0 0:03:17 0.2% Iate/4
28433 ex19 41M 17M sleep 59 0 0:11:17 0.2% ServiceD/4
17470 ex7 9160K 7712K sleep 59 0 0:02:09 0.2% SSM/1
3952 ex20 9160K 7860K sleep 59 0 0:00:37 0.2% SSM/1
17214 ex7 25M 20M sleep 59 0 0:02:13 0.2% Sequr/3
28536 ex19 7912K 6464K sleep 59 0 0:10:17 0.2% SSM/1
Total: 13 processes, 575 lwps, load averages: 4.31, 4.32, 4.31
If you need to view information of selected process. You can do by giving process ID.
Example:
$ prstat –p 28465
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
28465 ex19 46M 44M sleep 59 0 0:17:22 0.3% WSA/1
Total: 1 processes, 575 lwps, load averages: 4.31, 4.32, 4.31
ptree
This command shows parent-child relation ship of running processes. When it execute with out any argument then it shows information of all process. If process id is specified then it only shows information regarding that process.
Example:
With out Process ID:
$ptree
7 /lib/svc/bin/svc.startd
258 /usr/lib/saf/sac -t 300
290 /usr/lib/saf/ttymon
270 /usr/lib/saf/ttymon -g -d /dev/console -l console -m ldterm,ttcompat -h -p v20z
9 /lib/svc/bin/svc.configd
109 /usr/lib/sysevent/syseventd
306 /usr/sbin/cron
3119 sh -c chmod 755 $HOME/run_prstat; ./run_prstat
3127 /bin/bash ./run_prstat
11381 prstat -n 50 -c 5
11382 sleep 5
307 /usr/lib/inet/inetd start
16055 /bin/sh /lib/svc/method/rpc-ttdbserverd
16065 /usr/openwin/bin/rpc.ttdbserverd
115 /usr/sbin/in.telnetd
118 -bash
With Process ID:
$ 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
pstack
The stacks of all or specific threads within a process can be displayed with the pstack command. This is very help full when you developing multithreaded applications.
Example:
$ 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)
pkill
The pkill command provides a convenient way to send signals to a list or processes matching certain criteria.
Example:
$ pkill a.out
pmap
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.
Example:
$ 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 -
pfiles
All opened file descriptors of a process can be list by pfiles command.(All disk files, Sockets, and other IO devices)
Example:
$ 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
Referances:
http://www.solarisinternals.com