Translate

Sunday, 21 September 2014

/proc filesystem

There is a lot of useful information about all the active processes in "/proc" filesystem, unfortunately you need canot just "cat" the files as "/proc" is not a normal filesystem and contains a snapshot of the current system status, and may well have changed before you get the chance to examine it.  e.g.

# ps
      PID    TTY  TIME CMD
  8847424  pts/0  0:00 -ksh
  9437218  pts/0  0:00 ps


# find /proc/8847424
/proc/8847424
/proc/8847424/as
/proc/8847424/cred
/proc/8847424/ctl
/proc/8847424/cwd
/proc/8847424/fd
/proc/8847424/fd/0
/proc/8847424/fd/1
/proc/8847424/fd/2
/proc/8847424/fd/10
/proc/8847424/fd/63
/proc/8847424/lwp
/proc/8847424/lwp/38404245
/proc/8847424/lwp/38404245/lwpctl
/proc/8847424/lwp/38404245/lwpsinfo
/proc/8847424/lwp/38404245/lwpstatus
/proc/8847424/map
/proc/8847424/object
/proc/8847424/object/a.out
/proc/8847424/object/jfs2.10.5.487607
/proc/8847424/object/jfs2.10.5.1664
/proc/8847424/object/jfs2.10.5.4220
/proc/8847424/object/jfs2.10.5.13168
/proc/8847424/object/jfs2.10.5.339
/proc/8847424/object/jfs2.10.5.4250
/proc/8847424/psinfo
/proc/8847424/sigact
/proc/8847424/status
/proc/8847424/sysent
/proc/8847424/root
/proc/8847424/mmap


Just listing the "/proc" filesystem tree for a process does give you a good idea of what the system is doing and which resources it requires, however you need to use specialist tools such as:

ToolDescription
procstackGet Process Stack Trace
procflagsShow Pending and Held Signals for Process
procsigDisplay Signal Action and Handlers for Process
procfiles -n pidReport stat and fcntl Info for All Open Files in Each Process
procwdxDisplay the Current Working Directory of the Process
proctreeDisplay the Process Tree

to get more information.

The "/proc" entries contain the following information:

Directory or filenameDescription
/proc/pid/asAddress space used by this process.
/proc pid/credContains a description of the credentials associated with this process.
/proc/pid/ctlProcess control file.
/proc/pid/cwdA link that provides access to the current working directory of this process. Any process can access the current working directory of the process through this ink, provided it has the necessary permissions.
If you run "strings" against this file it gives the same output as "ls".
/proc/pid/fdContains files for all open file descriptors for this process.
/proc/pid/mapAddress space map for this process.
/proc/pid/objectDirectory for objects.
/proc/pid/psinfoProcess status information.
/proc/pid/sigactSignal actions for this process.
/proc/pid/statusProcess status.
/proc/pid/sysentSystem call information for process PID.
Thread specific files
/proc/pid/lwp/tidDirectory for thread.
/proc/pid/lwp/tid/lwpctlControl file for thread.
/proc/pid/lwp/tid/lwpsinfoProcess status info for thread.
/proc/pid/lwp/tid/lwpstatusStatus of thread.


No comments:

Post a Comment