JCMD in Java - Neues Command-line Utility in JDK 7

#1
Hallo,

mit JCMD (findet man im \bin-Verzeichnis der JDK 7 Installation zBsp: C:\Program Files\Java\jdk1.7.0_04\bin) kann man wie mit dem Tool jps JVM Prozesse auflisten.
Zusätzlich kann man aber über sogenannte Diagnostic Commands verschiedene Informationen des Java Prozesses auslesen.

schaut mal hier:
http://hirt.se/blog/?p=211

Beispiel:
Code:
C:\Users\thomas.darimont>jcmd 3876 help
3876:
The following commands are available:
VM.commercial_features
ManagementAgent.stop
ManagementAgent.start_local
ManagementAgent.start
Thread.print
GC.class_histogram
GC.heap_dump
GC.run_finalization
GC.run
VM.uptime
VM.flags
VM.system_properties
VM.command_line
VM.version
help

For more information about a specific command use 'help <command>'.

C:\Users\thomas.darimont>jcmd 3876 VM.version
3876:
Java HotSpot(TM) 64-Bit Server VM version 23.0-b21
JDK 7.0_04
Gruß Tom
 
#2
Hallo,

über das Command PerfCounter.print kann man sich einige interne Performance Counter (Kann man auch über VisualVM einsehen) eines Java Prozesses ausgeben lassen.

Aufruf: (Ausgabe für Java Prozess mit PID 7968)
Code:
C:\Program Files\Java\jdk1.8.0\bin>jcmd 7968 PerfCounter.print
Ausgabe:
Code:
7968:
java.ci.totalTime=5543943
java.cls.loadedClasses=6285
java.cls.sharedLoadedClasses=0
java.cls.sharedUnloadedClasses=0
java.cls.unloadedClasses=0
java.property.java.class.path="C:\tom\tools\visualvm_135\platform\lib\boot.jar;C:\tom\tools\visualvm_135\platform\lib\org-openide-modules.jar;C:\tom\tools\visualvm_135\platform\lib\org-openide-util-lookup.jar;C:\tom\tools\visualvm_135\platform\lib\org-openide-util.jar;C:\tom\jdk1.8.0\lib\dt.jar;C:\t
om\jdk1.8.0\lib\tools.jar"
java.property.java.endorsed.dirs="C:\tom\jdk1.8.0\jre\lib\endorsed"
java.property.java.ext.dirs="C:\tom\jdk1.8.0\jre\lib\ext;C:\Windows\Sun\Java\lib\ext"
java.property.java.home="C:\tom\jdk1.8.0\jre"
java.property.java.library.path="C:\tom\jdk1.8.0\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\tom\tools\cygwin\bin;C:\Windows\Microsoft.NET\Framework\v2.0.50727;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\
Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Prog
ram Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engin
e Components\IPT;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Java\jdk1.7.0_21\bin;C:\Program Files (x86)\Git\cmd;C:\tom\dev\frameworks\grails"
java.property.java.version="1.8.0-ea"
java.property.java.vm.info="mixed mode"
java.property.java.vm.name="Java HotSpot(TM) 64-Bit Server VM"
java.property.java.vm.specification.name="Java Virtual Machine Specification"
java.property.java.vm.specification.vendor="Oracle Corporation"
java.property.java.vm.specification.version="1.8"
java.property.java.vm.vendor="Oracle Corporation"
java.property.java.vm.version="25.0-b34"
java.rt.vmArgs="-Xms24m -Xmx256m -XX:MaxPermSize=96m -Dnetbeans.accept_license_class=com.sun.tools.visualvm.modules.startup.AcceptLicense -Dsun.jvmstat.perdata.syncWaitMs=10000 -Dsun.java2d.noddraw=true -Dsun.java2d.d3d=false -Djdk.home=C:\tom\jdk1.8.0 -Dnetbeans.home=C:\tom\tools\visualvm_135\platf
orm -Dnetbeans.user=C:\Users\Tom\AppData\Roaming\VisualVM\1.3.5 -Dnetbeans.default_userdir_root=C:\Users\Tom\AppData\Roaming\VisualVM -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\Users\Tom\AppData\Roaming\VisualVM\1.3.5\var\log\heapdump.hprof -Dnetbeans.system_http_proxy=DIRECT -Dsun.awt.keep
WorkingSetOnMinimize=true -Dnetbeans.dirs=C:\tom\tools\visualvm_135\visualvm;C:\tom\tools\visualvm_135\profiler"
java.rt.vmFlags=""
java.threads.daemon=23
java.threads.live=27
java.threads.livePeak=30
java.threads.started=34
sun.ci.compilerThread.0.compiles=215
sun.ci.compilerThread.0.method=""
sun.ci.compilerThread.0.time=68
sun.ci.compilerThread.0.type=1
sun.ci.compilerThread.1.compiles=241
sun.ci.compilerThread.1.method=""
sun.ci.compilerThread.1.time=95
sun.ci.compilerThread.1.type=1
sun.ci.lastFailedMethod="org/openide/filesystems/AbstractFolder find"
sun.ci.lastFailedType=1
sun.ci.lastInvalidatedMethod=""
sun.ci.lastInvalidatedType=0
sun.ci.lastMethod="java/util/regex/Matcher lookingAt"
sun.ci.lastSize=119
sun.ci.lastType=1
sun.ci.nmethodCodeSize=401376
sun.ci.nmethodSize=751504
sun.ci.osrBytes=2253
sun.ci.osrCompiles=9
sun.ci.osrTime=157863
sun.ci.standardBytes=84680
sun.ci.standardCompiles=446
sun.ci.standardTime=5386080
sun.ci.threads=2
sun.ci.totalBailouts=1
sun.ci.totalCompiles=455
sun.ci.totalInvalidates=0
sun.classloader.findClassTime=329464430
sun.classloader.findClasses=738
sun.classloader.parentDelegationTime=47788551
sun.cls.appClassBytes=11176718
sun.cls.appClassLoadCount=6247
sun.cls.appClassLoadTime=2020699
sun.cls.appClassLoadTime.self=910359
sun.cls.classInitTime=1772292
sun.cls.classInitTime.self=1242252
sun.cls.classLinkedTime=1848673
sun.cls.classLinkedTime.self=425601
sun.cls.classVerifyTime=1422356
sun.cls.classVerifyTime.self=657674
sun.cls.defineAppClassTime=1016219
sun.cls.defineAppClassTime.self=189508
sun.cls.defineAppClasses=2650
sun.cls.initializedClasses=4903
sun.cls.isUnsyncloadClassSet=0
sun.cls.jniDefineClassNoLockCalls=9
sun.cls.jvmDefineClassNoLockCalls=768
sun.cls.jvmFindLoadedClassNoLockCalls=6026
sun.cls.linkedClasses=5507
sun.cls.loadInstanceClassFailRate=0
sun.cls.loadedBytes=13736744
sun.cls.lookupSysClassTime=149031
sun.cls.methodBytes=6058072
sun.cls.nonSystemLoaderLockContentionRate=40
sun.cls.parseClassTime=1265956
sun.cls.parseClassTime.self=1117822
sun.cls.sharedClassLoadTime=732
sun.cls.sharedLoadedBytes=0
sun.cls.sharedUnloadedBytes=0
sun.cls.sysClassBytes=11913696
sun.cls.sysClassLoadTime=756878
sun.cls.systemLoaderLockContentionRate=0
sun.cls.time=4856773
sun.cls.unloadedBytes=0
sun.cls.unsafeDefineClassCalls=277
sun.cls.verifiedClasses=5504
sun.gc.cause="No GC"
sun.gc.collector.0.invocations=10
sun.gc.collector.0.lastEntryTime=25262094
sun.gc.collector.0.lastExitTime=25272544
sun.gc.collector.0.name="PSScavenge"
sun.gc.collector.0.time=135990
sun.gc.collector.1.invocations=2
sun.gc.collector.1.lastEntryTime=7019894
sun.gc.collector.1.lastExitTime=7124246
sun.gc.collector.1.name="PSParallelCompact"
sun.gc.collector.1.time=174516
sun.gc.generation.0.capacity=60555264
sun.gc.generation.0.maxCapacity=89456640
sun.gc.generation.0.minCapacity=8388608
sun.gc.generation.0.name="new"
sun.gc.generation.0.space.0.capacity=45613056
sun.gc.generation.0.space.0.initCapacity=0
sun.gc.generation.0.space.0.maxCapacity=89325568
sun.gc.generation.0.space.0.name="eden"
sun.gc.generation.0.space.0.used=3970536
sun.gc.generation.0.space.1.capacity=5570560
sun.gc.generation.0.space.1.initCapacity=0
sun.gc.generation.0.space.1.maxCapacity=29818880
sun.gc.generation.0.space.1.name="s0"
sun.gc.generation.0.space.1.used=1900544
sun.gc.generation.0.space.2.capacity=7471104
sun.gc.generation.0.space.2.initCapacity=0
sun.gc.generation.0.space.2.maxCapacity=29818880
sun.gc.generation.0.space.2.name="s1"
sun.gc.generation.0.space.2.used=0
sun.gc.generation.0.spaces=3
sun.gc.generation.1.capacity=33947648
sun.gc.generation.1.maxCapacity=178978816
sun.gc.generation.1.minCapacity=16777216
sun.gc.generation.1.name="old"
sun.gc.generation.1.space.0.capacity=33947648
sun.gc.generation.1.space.0.initCapacity=16777216
sun.gc.generation.1.space.0.maxCapacity=178978816
sun.gc.generation.1.space.0.name="old"
sun.gc.generation.1.space.0.used=15973264
sun.gc.generation.1.spaces=1
sun.gc.lastCause="Allocation Failure"
sun.gc.metaspace.capacity=41398272
sun.gc.metaspace.maxCapacity=144703488
sun.gc.metaspace.minCapacity=524288
sun.gc.metaspace.used=37832512
sun.gc.policy.avgBaseFootprint=268435456
sun.gc.policy.avgMajorIntervalTime=2147
sun.gc.policy.avgMajorPauseTime=52
sun.gc.policy.avgMinorIntervalTime=3187
sun.gc.policy.avgMinorPauseTime=8
sun.gc.policy.avgOldLive=11277451
sun.gc.policy.avgPretenuredPaddedAvg=0
sun.gc.policy.avgPromotedAvg=1305918
sun.gc.policy.avgPromotedDev=742502
sun.gc.policy.avgPromotedPaddedAvg=3533425
sun.gc.policy.avgSurvivedAvg=3433567
sun.gc.policy.avgSurvivedDev=1330222
sun.gc.policy.avgSurvivedPaddedAvg=7424236
sun.gc.policy.avgYoungLive=1767359
sun.gc.policy.boundaryMoved=0
sun.gc.policy.changeOldGenForMajPauses=0
sun.gc.policy.changeOldGenForMinPauses=0
sun.gc.policy.changeYoungGenForMajPauses=0
sun.gc.policy.changeYoungGenForMinPauses=0
sun.gc.policy.collectors=2
sun.gc.policy.decideAtFullGc=0
sun.gc.policy.decreaseForFootprint=0
sun.gc.policy.decrementTenuringThresholdForGcCost=0
sun.gc.policy.decrementTenuringThresholdForSurvivorLimit=0
sun.gc.policy.desiredSurvivorSize=7471104
sun.gc.policy.edenSize=45613056
sun.gc.policy.freeSpace=59899904
sun.gc.policy.fullFollowsScavenge=0
sun.gc.policy.gcTimeLimitExceeded=0
sun.gc.policy.generations=3
sun.gc.policy.increaseOldGenForThroughput=0
sun.gc.policy.increaseYoungGenForThroughput=5
sun.gc.policy.incrementTenuringThresholdForGcCost=1
sun.gc.policy.liveAtLastFullGc=15973264
sun.gc.policy.liveSpace=281480256
sun.gc.policy.majorCollectionSlope=0
sun.gc.policy.majorGcCost=2
sun.gc.policy.majorPauseOldSlope=7324
sun.gc.policy.majorPauseYoungSlope=969
sun.gc.policy.maxTenuringThreshold=15
sun.gc.policy.minorCollectionSlope=0
sun.gc.policy.minorGcCost=1
sun.gc.policy.minorPauseOldSlope=203
sun.gc.policy.minorPauseTime=6
sun.gc.policy.minorPauseYoungSlope=42
sun.gc.policy.mutatorCost=96
sun.gc.policy.name="ParScav:MSC"
sun.gc.policy.oldCapacity=33947648
sun.gc.policy.oldEdenSize=47120384
sun.gc.policy.oldPromoSize=14286848
sun.gc.policy.promoSize=14286848
sun.gc.policy.promoted=0
sun.gc.policy.scavengeSkipped=0
sun.gc.policy.survived=1900544
sun.gc.policy.survivorOverflowed=0
sun.gc.policy.tenuringThreshold=4
sun.gc.policy.youngCapacity=44564480
sun.gc.tlab.alloc=4480253
sun.gc.tlab.allocThreads=13
sun.gc.tlab.fastWaste=0
sun.gc.tlab.fills=358
sun.gc.tlab.gcWaste=125468
sun.gc.tlab.maxFastWaste=0
sun.gc.tlab.maxFills=156
sun.gc.tlab.maxGcWaste=31122
sun.gc.tlab.maxSlowAlloc=20
sun.gc.tlab.maxSlowWaste=9946
sun.gc.tlab.slowAlloc=47
sun.gc.tlab.slowWaste=11887
sun.os.hrt.frequency=1656464
sun.os.hrt.ticks=79821460
sun.perfdata.majorVersion=2
sun.perfdata.minorVersion=0
sun.perfdata.overflow=0
sun.perfdata.size=65536
sun.perfdata.timestamp=117381
sun.perfdata.used=18320
sun.property.sun.boot.class.path="C:\tom\jdk1.8.0\jre\lib\resources.jar;C:\tom\jdk1.8.0\jre\lib\rt.jar;C:\tom\jdk1.8.0\jre\lib\sunrsasign.jar;C:\tom\jdk1.8.0\jre\lib\jsse.jar;C:\tom\jdk1.8.0\jre\lib\jce.jar;C:\tom\jdk1.8.0\jre\lib\charsets.jar;C:\tom\jdk1.8.0\jre\lib\jfr.jar;C:\tom\jdk1.8.0\jre\clas
ses"
sun.property.sun.boot.library.path="C:\tom\jdk1.8.0\jre\bin"
sun.rt._sync_ContendedLockAttempts=114
sun.rt._sync_Deflations=207
sun.rt._sync_EmptyNotifications=0
sun.rt._sync_FailedSpins=0
sun.rt._sync_FutileWakeups=11
sun.rt._sync_Inflations=223
sun.rt._sync_MonExtant=384
sun.rt._sync_MonInCirculation=0
sun.rt._sync_MonScavenged=0
sun.rt._sync_Notifications=606
sun.rt._sync_Parks=676
sun.rt._sync_PrivateA=0
sun.rt._sync_PrivateB=0
sun.rt._sync_SlowEnter=0
sun.rt._sync_SlowExit=0
sun.rt._sync_SlowNotify=0
sun.rt._sync_SlowNotifyAll=0
sun.rt._sync_SuccessfulSpins=0
sun.rt.applicationTime=59684035
sun.rt.createVmBeginTime=1370993635056
sun.rt.createVmEndTime=1370993635119
sun.rt.internalVersion="Java HotSpot(TM) 64-Bit Server VM (25.0-b34) for windows-amd64 JRE (1.8.0-ea-b92), built on May 30 2013 04:08:11 by "java_re" with MS VC++ 10.0 (VS2010)"
sun.rt.interruptedBeforeIO=0
sun.rt.interruptedDuringIO=0
sun.rt.javaCommand="org/netbeans/Main --branding visualvm --cachedir C:\Users\Tom\AppData\Local\VisualVM\Cache/1.3.5"
sun.rt.jvmCapabilities="1100000000000000000000000000000000000000000000000000000000000000"
sun.rt.jvmVersion=419430434
sun.rt.safepointSyncTime=19615
sun.rt.safepointTime=342511
sun.rt.safepoints=163
sun.rt.threadInterruptSignaled=0
sun.rt.vmInitDoneTime=1370993635100
sun.threads.vmOperationTime=316018
sun.urlClassLoader.readClassBytesTime=90311069
sun.zip.zipFile.openTime=23969141
sun.zip.zipFiles=166
Gruß Tom