patric-r / jvmtop

Java monitoring for the command-line, profiler included
GNU General Public License v2.0
1.23k stars 253 forks source link

An arugment along with --once to filter exact JVM Process name to query. #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

hi,

In order to Minimize CPU time and CPU % taken by jvmtop.sh to find and display 
all the JVM found, can we have an argument like

./jvmtop.sh --once  <jvm name>

eg:

./jvmtop.sh --once  org.jboss.Main

OUTPUT:-
JvmTop 0.7.1 alpha - 06:13:38,  amd64,  4 cpus, Linux 2.6.18-19, load avg 0.00
 http://code.google.com/p/jvmtop

  PID MAIN-CLASS      HPCUR HPMAX NHCUR NHMAX    CPU     GC    VM USERNAME   #T DL
11228 org.jboss.Main   549m 3993m   70m  304m  0.00%  0.00% S6U25 compiere   74 

This would limit what jvmtop search and query for. making less CPU usage and 
intensive.

Original issue reported on code.google.com by j...@sodexis.com on 13 Aug 2013 at 11:18

GoogleCodeExporter commented 9 years ago

Original comment by patric.r...@gmail.com on 13 Aug 2013 at 11:27

laurent149 commented 8 years ago

On Unix, you can use awk to apply such kind of filtering: ./jvmtop.sh --once | awk '$1 == "JvmTop" || $1 == "PID" || $2 == "org.jboss.Main"' (the first two || arguments are there so that the header and column lines are displayed ⇒ remove them if such behavior is not desired)

Notice that this works even without the --once option but then filter on "JvmTop" on 2nd column for dynamic refresh: ./jvmtop.sh | awk '$2 == "JvmTop" || $1 == "PID" || $2 == "org.jboss.Main"'