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 Administrator

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

    Thomas Darimont Administrator

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

Diese Seite empfehlen