Sometimes we start off a new process and after quite sometime you wish to know details as to how the process was started. Things like current working directory, complete command line, environment variables used. This usually happens for the programs kicked off using a sudo-user and then you mostly quit the shell from where this was invoked. In my specific case, I was looking for the current working directory (to see where it will dump the core) and environment variables in use. In Linux, this is available in /proc/<pid>/ files.
I started browsing other entries and was amazed at the amount of useful information that is being transparently provided by Linux. Some of the notable ones are limits, statm and task. The reference link has details for other interesting details.
Here is the story:
I remember that I started the process on a particular host as the produser so log on there
Now check the current working directory:
Now for the environment settings:
Other interesting info:
References:
1. http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html
I started browsing other entries and was amazed at the amount of useful information that is being transparently provided by Linux. Some of the notable ones are limits, statm and task. The reference link has details for other interesting details.
Here is the story:
I remember that I started the process on a particular host as the produser so log on there
I remember that it is a java process - to get a handle to the process id.
> sudo -u produser ssh localhost
> ps -ef | grep java | grep produser produser 8113 7983 0 02:14 pts/10 00:00:00 grep java produser 21765 21750 0 Aug31 ? 01:46:45 /usr/local/java/jdk/bin/java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8765,suspend=n -Dcom.sun.management.jmxremote.port=8219 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -classpath /tools/apache/maven/boot/classworlds-1.1.jar -Dclassworlds.conf=/tools/apache/maven/bin/m2.conf -Dmaven.home=/tools/apache/maven org.codehaus.classworlds.Launcher "--settings" "/u/produser/.m2/settings.xml" "clean" "compile" "exec:java" "-Dexec.mainClass=com.kilo.DriverCLI" "-Dexec.args=SOMETHING"
Now check the current working directory:
> ls -al /proc/21765/cwd lrwxrwxrwx 1 produser produser 0 Oct 1 08:04 /proc/21765/cwd -> /u/produser/testproject
Now for the environment settings:
> cat /proc/21765/environ #All environment variables were listed - elided for privacy reasons
Other interesting info:
> cat /proc/21765/limits Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 10485760 unlimited bytes Max core file size unlimited unlimited bytes Max resident set unlimited unlimited bytes Max processes 16341 16341 processes Max open files 65536 65536 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 256591 256591 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us
> cat /proc/21765/task/21771/status Name: java State: S (sleeping) Tgid: 21765 Pid: 21771 PPid: 21750 TracerPid: 0 Uid: 5307 5307 5307 5307 Gid: 5307 5307 5307 5307 Utrace: 0 FDSize: 256 Groups: 5307 6135 6584 VmPeak: 11245832 kB VmSize: 11243768 kB VmLck: 0 kB VmHWM: 3575560 kB VmRSS: 2966532 kB VmData: 11064932 kB VmStk: 88 kB VmExe: 4 kB VmLib: 15324 kB VmPTE: 6360 kB VmSwap: 0 kB Threads: 31 SigQ: 0/256591 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000004 SigIgn: 0000000000000000 SigCgt: 2000000181005ccf CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 CapBnd: ffffffffffffffff Cpus_allowed: ff Cpus_allowed_list: 0-7 Mems_allowed: 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001 Mems_allowed_list: 0 voluntary_ctxt_switches: 8189 nonvoluntary_ctxt_switches: 933
References:
1. http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html
No comments:
Post a Comment