Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On my Linux server I run tomcat as root and when I run ps aux it gives the following output.

root     25667  0.1 29.2 4574004 306980 ?      Sl   Apr27  33:57 /usr/local/java/bin/java -Djava.util.logging.config.file...

Thre is only parent process, but when I run htop I can see all other child process (which are threads?). Sample output for a few lines given below.

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command                                                              
25668 root       15   0 4466M  299M 14208 S  0.0 29.3  0:01.23 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t
25669 root       18   0 4466M  299M 14208 S  0.0 29.3  0:54.84 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t
25670 root       15   0 4466M  299M 14208 S  0.0 29.3  0:00.25 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t
25671 root       15   0 4466M  299M 14208 S  0.0 29.3  0:00.54 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t
25672 root       18   0 4466M  299M 14208 S  0.0 29.3  0:00.00 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t
25673 root       15   0 4466M  299M 14208 S  0.0 29.3  0:17.96 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t
25674 root       15   0 4466M  299M 14208 S  0.0 29.3  0:20.01 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t
25675 root       19   0 4466M  299M 14208 S  0.0 29.3  0:00.00 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/t

So I want to get child process list with a single command. I set maxThreads to 200 in config file, and want to check current thread count by counting child threads.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Easy enough to do: ps -eLf | grep java

Might have to adjust (grep can be refined to get what you're looking for).

share|improve this answer

You can launch:

ps -o nlwp PID

(PID will be the pid of your process)

nlwp = number of lightweight process

share|improve this answer

If you have a JDK installed, one very useful way of monitoring this (and the various heaps sizes) in real-time is jconsole, which is a GUI program (if you have javac, you should also have this). There are also things like jstat and jinfo and others. To benefit from jconsole, you may need to enable JMX (this can also be done for remote connections). You'll need to run these tools as the same user that is running the JVM you want to inspect.

If you're using top, then you can type h to toggle display of threads. Its worth looking at the various top keystrokes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.