1. Diese Seite verwendet Cookies. Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies. Weitere Informationen

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

Dieses Thema im Forum "Java Technology News" wurde erstellt von Thomas Darimont, 10. Mai 2012.

  1. Thomas Darimont

    Thomas Darimont Premium-User

    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 (Text):
    1. C:\Users\thomas.darimont>jcmd 3876 help
    2. 3876:
    3. The following commands are available:
    4. VM.commercial_features
    5. ManagementAgent.stop
    6. ManagementAgent.start_local
    7. ManagementAgent.start
    8. Thread.print
    9. GC.class_histogram
    10. GC.heap_dump
    11. GC.run_finalization
    12. GC.run
    13. VM.uptime
    14. VM.flags
    15. VM.system_properties
    16. VM.command_line
    17. VM.version
    18. help
    19.  
    20. For more information about a specific command use 'help <command>'.
    21.  
    22. C:\Users\thomas.darimont>jcmd 3876 VM.version
    23. 3876:
    24. Java HotSpot(TM) 64-Bit Server VM version 23.0-b21
    25. JDK 7.0_04
    Gruß Tom
     
  2. Thomas Darimont

    Thomas Darimont Premium-User

    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 (Text):
    1. C:\Program Files\Java\jdk1.8.0\bin>jcmd 7968 PerfCounter.print
    Ausgabe:
    Code (Text):
    1. 7968:
    2. java.ci.totalTime=5543943
    3. java.cls.loadedClasses=6285
    4. java.cls.sharedLoadedClasses=0
    5. java.cls.sharedUnloadedClasses=0
    6. java.cls.unloadedClasses=0
    7. 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
    8. om\jdk1.8.0\lib\tools.jar"
    9. java.property.java.endorsed.dirs="C:\tom\jdk1.8.0\jre\lib\endorsed"
    10. java.property.java.ext.dirs="C:\tom\jdk1.8.0\jre\lib\ext;C:\Windows\Sun\Java\lib\ext"
    11. java.property.java.home="C:\tom\jdk1.8.0\jre"
    12. 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:\
    13. 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
    14. 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
    15. 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"
    16. java.property.java.version="1.8.0-ea"
    17. java.property.java.vm.info="mixed mode"
    18. java.property.java.vm.name="Java HotSpot(TM) 64-Bit Server VM"
    19. java.property.java.vm.specification.name="Java Virtual Machine Specification"
    20. java.property.java.vm.specification.vendor="Oracle Corporation"
    21. java.property.java.vm.specification.version="1.8"
    22. java.property.java.vm.vendor="Oracle Corporation"
    23. java.property.java.vm.version="25.0-b34"
    24. 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
    25. 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
    26. WorkingSetOnMinimize=true -Dnetbeans.dirs=C:\tom\tools\visualvm_135\visualvm;C:\tom\tools\visualvm_135\profiler"
    27. java.rt.vmFlags=""
    28. java.threads.daemon=23
    29. java.threads.live=27
    30. java.threads.livePeak=30
    31. java.threads.started=34
    32. sun.ci.compilerThread.0.compiles=215
    33. sun.ci.compilerThread.0.method=""
    34. sun.ci.compilerThread.0.time=68
    35. sun.ci.compilerThread.0.type=1
    36. sun.ci.compilerThread.1.compiles=241
    37. sun.ci.compilerThread.1.method=""
    38. sun.ci.compilerThread.1.time=95
    39. sun.ci.compilerThread.1.type=1
    40. sun.ci.lastFailedMethod="org/openide/filesystems/AbstractFolder find"
    41. sun.ci.lastFailedType=1
    42. sun.ci.lastInvalidatedMethod=""
    43. sun.ci.lastInvalidatedType=0
    44. sun.ci.lastMethod="java/util/regex/Matcher lookingAt"
    45. sun.ci.lastSize=119
    46. sun.ci.lastType=1
    47. sun.ci.nmethodCodeSize=401376
    48. sun.ci.nmethodSize=751504
    49. sun.ci.osrBytes=2253
    50. sun.ci.osrCompiles=9
    51. sun.ci.osrTime=157863
    52. sun.ci.standardBytes=84680
    53. sun.ci.standardCompiles=446
    54. sun.ci.standardTime=5386080
    55. sun.ci.threads=2
    56. sun.ci.totalBailouts=1
    57. sun.ci.totalCompiles=455
    58. sun.ci.totalInvalidates=0
    59. sun.classloader.findClassTime=329464430
    60. sun.classloader.findClasses=738
    61. sun.classloader.parentDelegationTime=47788551
    62. sun.cls.appClassBytes=11176718
    63. sun.cls.appClassLoadCount=6247
    64. sun.cls.appClassLoadTime=2020699
    65. sun.cls.appClassLoadTime.self=910359
    66. sun.cls.classInitTime=1772292
    67. sun.cls.classInitTime.self=1242252
    68. sun.cls.classLinkedTime=1848673
    69. sun.cls.classLinkedTime.self=425601
    70. sun.cls.classVerifyTime=1422356
    71. sun.cls.classVerifyTime.self=657674
    72. sun.cls.defineAppClassTime=1016219
    73. sun.cls.defineAppClassTime.self=189508
    74. sun.cls.defineAppClasses=2650
    75. sun.cls.initializedClasses=4903
    76. sun.cls.isUnsyncloadClassSet=0
    77. sun.cls.jniDefineClassNoLockCalls=9
    78. sun.cls.jvmDefineClassNoLockCalls=768
    79. sun.cls.jvmFindLoadedClassNoLockCalls=6026
    80. sun.cls.linkedClasses=5507
    81. sun.cls.loadInstanceClassFailRate=0
    82. sun.cls.loadedBytes=13736744
    83. sun.cls.lookupSysClassTime=149031
    84. sun.cls.methodBytes=6058072
    85. sun.cls.nonSystemLoaderLockContentionRate=40
    86. sun.cls.parseClassTime=1265956
    87. sun.cls.parseClassTime.self=1117822
    88. sun.cls.sharedClassLoadTime=732
    89. sun.cls.sharedLoadedBytes=0
    90. sun.cls.sharedUnloadedBytes=0
    91. sun.cls.sysClassBytes=11913696
    92. sun.cls.sysClassLoadTime=756878
    93. sun.cls.systemLoaderLockContentionRate=0
    94. sun.cls.time=4856773
    95. sun.cls.unloadedBytes=0
    96. sun.cls.unsafeDefineClassCalls=277
    97. sun.cls.verifiedClasses=5504
    98. sun.gc.cause="No GC"
    99. sun.gc.collector.0.invocations=10
    100. sun.gc.collector.0.lastEntryTime=25262094
    101. sun.gc.collector.0.lastExitTime=25272544
    102. sun.gc.collector.0.name="PSScavenge"
    103. sun.gc.collector.0.time=135990
    104. sun.gc.collector.1.invocations=2
    105. sun.gc.collector.1.lastEntryTime=7019894
    106. sun.gc.collector.1.lastExitTime=7124246
    107. sun.gc.collector.1.name="PSParallelCompact"
    108. sun.gc.collector.1.time=174516
    109. sun.gc.generation.0.capacity=60555264
    110. sun.gc.generation.0.maxCapacity=89456640
    111. sun.gc.generation.0.minCapacity=8388608
    112. sun.gc.generation.0.name="new"
    113. sun.gc.generation.0.space.0.capacity=45613056
    114. sun.gc.generation.0.space.0.initCapacity=0
    115. sun.gc.generation.0.space.0.maxCapacity=89325568
    116. sun.gc.generation.0.space.0.name="eden"
    117. sun.gc.generation.0.space.0.used=3970536
    118. sun.gc.generation.0.space.1.capacity=5570560
    119. sun.gc.generation.0.space.1.initCapacity=0
    120. sun.gc.generation.0.space.1.maxCapacity=29818880
    121. sun.gc.generation.0.space.1.name="s0"
    122. sun.gc.generation.0.space.1.used=1900544
    123. sun.gc.generation.0.space.2.capacity=7471104
    124. sun.gc.generation.0.space.2.initCapacity=0
    125. sun.gc.generation.0.space.2.maxCapacity=29818880
    126. sun.gc.generation.0.space.2.name="s1"
    127. sun.gc.generation.0.space.2.used=0
    128. sun.gc.generation.0.spaces=3
    129. sun.gc.generation.1.capacity=33947648
    130. sun.gc.generation.1.maxCapacity=178978816
    131. sun.gc.generation.1.minCapacity=16777216
    132. sun.gc.generation.1.name="old"
    133. sun.gc.generation.1.space.0.capacity=33947648
    134. sun.gc.generation.1.space.0.initCapacity=16777216
    135. sun.gc.generation.1.space.0.maxCapacity=178978816
    136. sun.gc.generation.1.space.0.name="old"
    137. sun.gc.generation.1.space.0.used=15973264
    138. sun.gc.generation.1.spaces=1
    139. sun.gc.lastCause="Allocation Failure"
    140. sun.gc.metaspace.capacity=41398272
    141. sun.gc.metaspace.maxCapacity=144703488
    142. sun.gc.metaspace.minCapacity=524288
    143. sun.gc.metaspace.used=37832512
    144. sun.gc.policy.avgBaseFootprint=268435456
    145. sun.gc.policy.avgMajorIntervalTime=2147
    146. sun.gc.policy.avgMajorPauseTime=52
    147. sun.gc.policy.avgMinorIntervalTime=3187
    148. sun.gc.policy.avgMinorPauseTime=8
    149. sun.gc.policy.avgOldLive=11277451
    150. sun.gc.policy.avgPretenuredPaddedAvg=0
    151. sun.gc.policy.avgPromotedAvg=1305918
    152. sun.gc.policy.avgPromotedDev=742502
    153. sun.gc.policy.avgPromotedPaddedAvg=3533425
    154. sun.gc.policy.avgSurvivedAvg=3433567
    155. sun.gc.policy.avgSurvivedDev=1330222
    156. sun.gc.policy.avgSurvivedPaddedAvg=7424236
    157. sun.gc.policy.avgYoungLive=1767359
    158. sun.gc.policy.boundaryMoved=0
    159. sun.gc.policy.changeOldGenForMajPauses=0
    160. sun.gc.policy.changeOldGenForMinPauses=0
    161. sun.gc.policy.changeYoungGenForMajPauses=0
    162. sun.gc.policy.changeYoungGenForMinPauses=0
    163. sun.gc.policy.collectors=2
    164. sun.gc.policy.decideAtFullGc=0
    165. sun.gc.policy.decreaseForFootprint=0
    166. sun.gc.policy.decrementTenuringThresholdForGcCost=0
    167. sun.gc.policy.decrementTenuringThresholdForSurvivorLimit=0
    168. sun.gc.policy.desiredSurvivorSize=7471104
    169. sun.gc.policy.edenSize=45613056
    170. sun.gc.policy.freeSpace=59899904
    171. sun.gc.policy.fullFollowsScavenge=0
    172. sun.gc.policy.gcTimeLimitExceeded=0
    173. sun.gc.policy.generations=3
    174. sun.gc.policy.increaseOldGenForThroughput=0
    175. sun.gc.policy.increaseYoungGenForThroughput=5
    176. sun.gc.policy.incrementTenuringThresholdForGcCost=1
    177. sun.gc.policy.liveAtLastFullGc=15973264
    178. sun.gc.policy.liveSpace=281480256
    179. sun.gc.policy.majorCollectionSlope=0
    180. sun.gc.policy.majorGcCost=2
    181. sun.gc.policy.majorPauseOldSlope=7324
    182. sun.gc.policy.majorPauseYoungSlope=969
    183. sun.gc.policy.maxTenuringThreshold=15
    184. sun.gc.policy.minorCollectionSlope=0
    185. sun.gc.policy.minorGcCost=1
    186. sun.gc.policy.minorPauseOldSlope=203
    187. sun.gc.policy.minorPauseTime=6
    188. sun.gc.policy.minorPauseYoungSlope=42
    189. sun.gc.policy.mutatorCost=96
    190. sun.gc.policy.name="ParScav:MSC"
    191. sun.gc.policy.oldCapacity=33947648
    192. sun.gc.policy.oldEdenSize=47120384
    193. sun.gc.policy.oldPromoSize=14286848
    194. sun.gc.policy.promoSize=14286848
    195. sun.gc.policy.promoted=0
    196. sun.gc.policy.scavengeSkipped=0
    197. sun.gc.policy.survived=1900544
    198. sun.gc.policy.survivorOverflowed=0
    199. sun.gc.policy.tenuringThreshold=4
    200. sun.gc.policy.youngCapacity=44564480
    201. sun.gc.tlab.alloc=4480253
    202. sun.gc.tlab.allocThreads=13
    203. sun.gc.tlab.fastWaste=0
    204. sun.gc.tlab.fills=358
    205. sun.gc.tlab.gcWaste=125468
    206. sun.gc.tlab.maxFastWaste=0
    207. sun.gc.tlab.maxFills=156
    208. sun.gc.tlab.maxGcWaste=31122
    209. sun.gc.tlab.maxSlowAlloc=20
    210. sun.gc.tlab.maxSlowWaste=9946
    211. sun.gc.tlab.slowAlloc=47
    212. sun.gc.tlab.slowWaste=11887
    213. sun.os.hrt.frequency=1656464
    214. sun.os.hrt.ticks=79821460
    215. sun.perfdata.majorVersion=2
    216. sun.perfdata.minorVersion=0
    217. sun.perfdata.overflow=0
    218. sun.perfdata.size=65536
    219. sun.perfdata.timestamp=117381
    220. sun.perfdata.used=18320
    221. 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
    222. ses"
    223. sun.property.sun.boot.library.path="C:\tom\jdk1.8.0\jre\bin"
    224. sun.rt._sync_ContendedLockAttempts=114
    225. sun.rt._sync_Deflations=207
    226. sun.rt._sync_EmptyNotifications=0
    227. sun.rt._sync_FailedSpins=0
    228. sun.rt._sync_FutileWakeups=11
    229. sun.rt._sync_Inflations=223
    230. sun.rt._sync_MonExtant=384
    231. sun.rt._sync_MonInCirculation=0
    232. sun.rt._sync_MonScavenged=0
    233. sun.rt._sync_Notifications=606
    234. sun.rt._sync_Parks=676
    235. sun.rt._sync_PrivateA=0
    236. sun.rt._sync_PrivateB=0
    237. sun.rt._sync_SlowEnter=0
    238. sun.rt._sync_SlowExit=0
    239. sun.rt._sync_SlowNotify=0
    240. sun.rt._sync_SlowNotifyAll=0
    241. sun.rt._sync_SuccessfulSpins=0
    242. sun.rt.applicationTime=59684035
    243. sun.rt.createVmBeginTime=1370993635056
    244. sun.rt.createVmEndTime=1370993635119
    245. 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)"
    246. sun.rt.interruptedBeforeIO=0
    247. sun.rt.interruptedDuringIO=0
    248. sun.rt.javaCommand="org/netbeans/Main --branding visualvm --cachedir C:\Users\Tom\AppData\Local\VisualVM\Cache/1.3.5"
    249. sun.rt.jvmCapabilities="1100000000000000000000000000000000000000000000000000000000000000"
    250. sun.rt.jvmVersion=419430434
    251. sun.rt.safepointSyncTime=19615
    252. sun.rt.safepointTime=342511
    253. sun.rt.safepoints=163
    254. sun.rt.threadInterruptSignaled=0
    255. sun.rt.vmInitDoneTime=1370993635100
    256. sun.threads.vmOperationTime=316018
    257. sun.urlClassLoader.readClassBytesTime=90311069
    258. sun.zip.zipFile.openTime=23969141
    259. sun.zip.zipFiles=166
    Gruß Tom
     

Diese Seite empfehlen