Linux Java Process Status (PS)

The Linux ps (report process status) utility is not very helpful when it comes to Java processes :

  1. The java executable path is usually so long, that the ps listing does not show any of its paramaters even in long mode.
  2. The ps utility shows each Java thread as a separate process making for cluttered presentation

The table below shows the part of the output of the Linux ps command on a system running multiple multithreaded Java applications:

15379 ?        S      0:01 /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -Djava.se
15393 ?        S      0:00  \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -Djav
15394 ?        S      0:00      \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -
15395 ?        S      0:00      \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -
15396 ?        S      0:00      \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -
15399 ?        S      0:00      \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -
12116 pts/4    S      0:02  |   \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -
12130 pts/4    S      0:00  |       \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/ja
12131 pts/4    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
12132 pts/4    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
...
26633 pts/8    S      0:56  |   \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -
26649 pts/8    S      0:00  |       \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/ja
26650 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26651 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26652 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26655 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26656 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26657 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26660 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26662 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26664 pts/8    S      0:04  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26665 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26667 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
 2379 pts/8    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
26692 pts/9    S      0:04  |   \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/java -
26705 pts/9    S      0:00  |       \_ /usr/local/java/ibm-jdk1.3/jre/bin/exe/ja
26706 pts/9    S      0:00  |           \_ /usr/local/java/ibm-jdk1.3/jre/bin/ex
...

javaps

Java PS is a bash (GNU bourne shell) script that queries the Linux /proc filesystem to print a concise listing of Java processes.

The table below shows the output of the javaps script on using the -noflags argument that strips Java flags.

$ javaps -noflags
PID	Process
12116	 /usr/local/java/ibm-jdk1.3/jre/bin/exe/java edu.columbia.nestor.gaia.repository.Gaia /home/akonstan/Unix/packages/jdk-1.2/nestor-2.1a/etc/repository.conf
15379	 /usr/local/java/ibm-jdk1.3/jre/bin/exe/java edu.columbia.nestor.util.HttpServer 8080 /home/akonstan/Unix/packages/jdk-1.2/nestor-2.1a/lib-dl
26633	 /usr/local/java/ibm-jdk1.3/jre/bin/exe/java edu.columbia.nestor.agent.linux.LinuxAgent nestor://localhost
26692	 /usr/local/java/ibm-jdk1.3/jre/bin/exe/java edu.columbia.nestor.agent.snmp.NestorMIB2Adapter /home/akonstan/Unix/packages/jdk-1.2/nestor-2.1a/mibs snorkel public nestor://localhost
27869	 /usr/local/java/ibm-jdk1.3/jre/bin/exe/java edu.columbia.nestor.browser.Browser
31823	 /usr/local/java/ibm-jdk1.3/jre/bin/exe/java Monitor nestor://localhost

Usage

javaps { -noflag }

Copyright

Copyright (c) 2000 Alexander V. Konstantinou

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Alexander V. Konstantinou makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

Download


Please address all comments/questions to Alexander V. Konstantinou akonstan@acm.org.