Friday, October 8, 2010

proc Utilities

Lets see some process related commands.

The pgrep command displays a list of the process IDs of active processes on the system that match the pattern specified in the command line.

[Displays pid of process matching cro* pattern]
server1:/root# pgrep cro*
5399
20171
20146
20178


[Display pid of process matching cron]
server1:/root# pgrep cron
5399

[Display pid and name of process]
server1:/root# pgrep -l cron
5399 cron


[Display process associated with a user]
server1:/root# pgrep -u pagent
15267
14798
19430
19429
1731
25549

 
[Display pid and process name associated with a username]
server1:/root# pgrep -l -u pagent
15267 PatrolAgent
14798 ds_listener
19430 bgscollect
19429 bgsagent
1731 ksh
25549 ksh



pflags - Print the /proc tracing flags, the pending and held signals, and other /proc status information for each lwp in each process.

server1:/root# pflags 28453
28453: /usr/lib/ssh/sshd
data model = _ILP32 flags = ORPHAN|MSACCT|MSFORK
/1: flags = ASLEEP pollsys(0xffbff3f0,0x1,0x0,0x0)



pcred - Print the credentials (effective, real, saved UIDs and GIDs) of each process.

server1:/root# pcred 15267
15267: euid=1320 ruid=1320 suid=0 e/r/sgid=1300
groups: 1300 7929 32506 7211 32502 13500 32505 7156 32504 32503


pldd - List the dynamic libraries linked into each process, including shared objects explicitly attached using dlopen(3C).

server1:/root# pldd 1731
1731: /bin/ksh
/lib/libc.so.1
/platform/sun4u-us3/lib/libc_psr.so.1



psig - List the signal actions and handlers of each process.

server1:/root# psig 1731
1731: /bin/ksh
HUP ignored
INT caught sh_fault RESTART
QUIT ignored
ILL caught sh_done RESTART
TRAP caught sh_done RESTART
ABRT caught sh_done RESTART
EMT caught sh_done RESTART
FPE ignored
KILL default
BUS caught sh_done RESTART
SEGV default
SYS caught sh_done RESTART
PIPE ignored
ALRM caught sh_fault RESTART
TERM caught sh_done RESTART
USR1 caught sh_done RESTART
USR2 caught sh_done RESTART
CLD caught sh_fault NOCLDSTOP
PWR default
WINCH default
URG default
POLL default
STOP default
TSTP ignored
CONT default
TTIN ignored
TTOU ignored
VTALRM default
PROF default
XCPU caught sh_done RESTART
XFSZ ignored
WAITING default
LWP default
FREEZE default
THAW default
CANCEL default
LOST default
XRES default
JVM1 default
JVM2 default
RTMIN default
RTMIN+1 default
RTMIN+2 default
RTMIN+3 default
RTMAX-3 default
RTMAX-2 default
RTMAX-1 default
RTMAX default



pstack - Print a hex+symbolic stack trace for each lwp in each process.

server1:/root# pstack 1731
1731: /bin/ksh
ff2cc400 read (0, ff339c44, 1)
000233fc io_readbuff (0, ff339c44, 1, 24400, 527e0, 400) + 314
000248c4 ???????? (0, ff339c44, 53444, 1, 527e0, 5)
00024adc io_readc (2, ffbff908, 53d78, 0, ffbff90b, 53000) + 2c
00029f5c ???????? (300000, 0, 0, 53000, 53000, 0)
000299cc main (20000000, 2bc00, ffbffc24, 53000, 53000, ffff8000) + a30
00016b20 _start (0, 0, 0, 0, 0, 0) + 108



pfiles - Report 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.

server1:/root# pfiles 1731
1731: /bin/ksh
Current rlimit: 4096 file descriptors
0: S_IFIFO mode:0000 dev:368,0 ino:751569929 uid:1320 gid:1300 size:0
O_RDWR
1: S_IFIFO mode:0000 dev:368,0 ino:751569928 uid:1320 gid:1300 size:0
O_RDWR
2: S_IFIFO mode:0000 dev:368,0 ino:751569928 uid:1320 gid:1300 size:0
O_RDWR



pwdx - Print the current working directory of each process.

server1:/proc# pwdx 1731
1731: /opt/patrol


pstop - Stop each process (PR_REQUESTED stop).

prun - Set each process running (inverse of pstop).

pwait - Wait for all of the specified processes to terminate.

ptime - Time the command, like time(1), but using microstate accounting for reproducible precision. Unlike time(1), children of the command are not timed.

server1:/# ptime cat /var/tmp/1

real 0.005
user 0.001
sys 0.003



ptree - Print the process trees containing the specified pids or users, with child processes indented from their respective parent processes.

server1:/proc# ptree 23662
28453 /usr/lib/ssh/sshd
23650 /usr/lib/ssh/sshd
23652 /usr/lib/ssh/sshd
23662 -ksh
14517 isql -syb_dba -SDRSBDT5 -w0000000000000000000000000000000000000000000000000000

No comments:

Post a Comment