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

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:

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