среда, 8 октября 2014 г.

Poor`s man jvisualvm on Windows 2008+

If running java processes as services on Windows 2008 and later, there is no way to profile them using jvisualvm - you can`t connect to them directly.

Yes, you can use - jmx, jstatd. But there is a way to gather performance data without all that fuzz.

Using psexec (from SysInternals) you can dump all performat data for all java processes with one command line:

psexec \\HOST -accepteula -u DOMAIN_USER -p DOMAIN_PASSWORD -h cmd /c for /f "tokens=1" %i in ('%JAVA_HOME%/bin/jps.exe') do jcmd %i PerfCounter.print

It uses jcmd for dumping all information. You must use the same DOMAIN_USER, DOMAIN_PASSWORD used for services. Do not run java services as LocalSystem!

This will produce output like this:

java.ci.totalTime=1228659786
java.cls.loadedClasses=15499
java.cls.sharedLoadedClasses=0
java.cls.sharedUnloadedClasses=0
java.cls.unloadedClasses=827
java.property.java.ext.dirs="C:\Program Files\Java\jre7\lib\ext;C:\Windows\Sun\Java\lib\ext"
java.property.java.home="C:\Program Files\Java\jre7"
java.property.java.version="1.7.0_51"
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.7"
java.property.java.vm.vendor="Oracle Corporation"
java.property.java.vm.version="24.51-b03"
java.rt.vmArgs="-XX:MaxPermSize=256m"
java.rt.vmFlags=""
java.threads.daemon=34
java.threads.live=49
java.threads.livePeak=52
java.threads.started=883
sun.ci.compilerThread.0.compiles=2118
sun.ci.compilerThread.0.method=""
sun.ci.compilerThread.0.time=218574
sun.ci.compilerThread.0.type=1
sun.ci.compilerThread.1.compiles=2295
sun.ci.compilerThread.1.method=""
sun.ci.compilerThread.1.time=48838
sun.ci.compilerThread.1.type=1
sun.ci.lastFailedMethod="org/apache/catalina/deploy/WebXml merge"
sun.ci.lastFailedType=1
sun.ci.lastInvalidatedMethod=""
sun.ci.lastInvalidatedType=0
sun.ci.lastMethod="org/apache/jsp/test_jsp setSessionValue"
sun.ci.lastSize=464
sun.ci.lastType=1
sun.ci.nmethodCodeSize=13122880
sun.ci.nmethodSize=27225752
sun.ci.osrBytes=196768
sun.ci.osrCompiles=189
sun.ci.osrTime=130282719
sun.ci.standardBytes=1847119
sun.ci.standardCompiles=4223
sun.ci.standardTime=1098377067
sun.ci.threads=2
sun.ci.totalBailouts=1
sun.ci.totalCompiles=4412
sun.ci.totalInvalidates=0
sun.classloader.findClassTime=1530872262
sun.classloader.findClasses=2870
sun.classloader.parentDelegationTime=429614286
sun.cls.appClassBytes=50258481
sun.cls.appClassLoadCount=27926
sun.cls.appClassLoadTime=223738631
sun.cls.appClassLoadTime.self=147142773
sun.cls.classInitTime=63151285
sun.cls.classInitTime.self=29464471
sun.cls.classLinkedTime=247080356
sun.cls.classLinkedTime.self=93732190
sun.cls.classVerifyTime=152894417
sun.cls.classVerifyTime.self=56639620
sun.cls.defineAppClassTime=62104628
sun.cls.defineAppClassTime.self=10003112
sun.cls.defineAppClasses=11762
sun.cls.initializedClasses=12167
sun.cls.isUnsyncloadClassSet=0
sun.cls.jniDefineClassNoLockCalls=4
sun.cls.jvmDefineClassNoLockCalls=1973
sun.cls.jvmFindLoadedClassNoLockCalls=31832
sun.cls.linkedClasses=13431
sun.cls.loadInstanceClassFailRate=0
sun.cls.loadedBytes=33357168
sun.cls.lookupSysClassTime=16909046
sun.cls.methodBytes=19614304
sun.cls.nonSystemLoaderLockContentionRate=33
sun.cls.parseClassTime=59194772
sun.cls.parseClassTime.self=43502764
sun.cls.sharedClassLoadTime=316102
sun.cls.sharedLoadedBytes=0
sun.cls.sharedUnloadedBytes=0
sun.cls.sysClassBytes=12333137
sun.cls.sysClassLoadTime=29347566
sun.cls.systemLoaderLockContentionRate=0
sun.cls.time=431357421
sun.cls.unloadedBytes=1336448
sun.cls.unsafeDefineClassCalls=1174
sun.cls.verifiedClasses=13431
sun.gc.cause="No GC"
sun.gc.collector.0.invocations=5050
sun.gc.collector.0.lastEntryTime=891728329630
sun.gc.collector.0.lastExitTime=891731952966
sun.gc.collector.0.name="PCopy"
sun.gc.collector.0.time=963845684
sun.gc.collector.1.invocations=157
sun.gc.collector.1.lastEntryTime=891731953023
sun.gc.collector.1.lastExitTime=891744771425
sun.gc.collector.1.name="CMS"
sun.gc.collector.1.time=296007075
sun.gc.generation.0.agetable.bytes.00=0
sun.gc.generation.0.agetable.bytes.01=13364936
sun.gc.generation.0.agetable.bytes.02=335824
sun.gc.generation.0.agetable.bytes.03=1454016
sun.gc.generation.0.agetable.bytes.04=1022432
sun.gc.generation.0.agetable.bytes.05=498952
sun.gc.generation.0.agetable.bytes.06=2482632
sun.gc.generation.0.agetable.bytes.07=680280
sun.gc.generation.0.agetable.bytes.08=323992
sun.gc.generation.0.agetable.bytes.09=765240
sun.gc.generation.0.agetable.bytes.10=95832
sun.gc.generation.0.agetable.bytes.11=58072
sun.gc.generation.0.agetable.bytes.12=0
sun.gc.generation.0.agetable.bytes.13=0
sun.gc.generation.0.agetable.bytes.14=0
sun.gc.generation.0.agetable.bytes.15=0
sun.gc.generation.0.agetable.size=16
sun.gc.generation.0.capacity=314572800
sun.gc.generation.0.maxCapacity=314572800
sun.gc.generation.0.minCapacity=11141120
sun.gc.generation.0.name="new"
sun.gc.generation.0.space.0.capacity=251658240
sun.gc.generation.0.space.0.initCapacity=0
sun.gc.generation.0.space.0.maxCapacity=251658240
sun.gc.generation.0.space.0.name="eden"
sun.gc.generation.0.space.0.used=51514680
sun.gc.generation.0.space.1.capacity=31457280
sun.gc.generation.0.space.1.initCapacity=0
sun.gc.generation.0.space.1.maxCapacity=31457280
sun.gc.generation.0.space.1.name="s0"
sun.gc.generation.0.space.1.used=0
sun.gc.generation.0.space.2.capacity=31457280
sun.gc.generation.0.space.2.initCapacity=0
sun.gc.generation.0.space.2.maxCapacity=31457280
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.0.threads=4
sun.gc.generation.1.capacity=629145600
sun.gc.generation.1.maxCapacity=629145600
sun.gc.generation.1.minCapacity=22413312
sun.gc.generation.1.name="old"
sun.gc.generation.1.space.0.capacity=629145600
sun.gc.generation.1.space.0.initCapacity=22413312
sun.gc.generation.1.space.0.maxCapacity=629145600
sun.gc.generation.1.space.0.name="old"
sun.gc.generation.1.space.0.used=266672216
sun.gc.generation.1.spaces=1
sun.gc.generation.2.capacity=169287680
sun.gc.generation.2.maxCapacity=268435456
sun.gc.generation.2.minCapacity=21757952
sun.gc.generation.2.name="perm"
sun.gc.generation.2.space.0.capacity=169287680
sun.gc.generation.2.space.0.initCapacity=21757952
sun.gc.generation.2.space.0.maxCapacity=268435456
sun.gc.generation.2.space.0.name="perm"
sun.gc.generation.2.space.0.used=101570248
sun.gc.generation.2.spaces=1
sun.gc.lastCause="Allocation Failure"
sun.gc.policy.collectors=2
sun.gc.policy.desiredSurvivorSize=28311552
sun.gc.policy.generations=3
sun.gc.policy.maxTenuringThreshold=31
sun.gc.policy.name="ParNew:CMS"
sun.gc.policy.tenuringThreshold=16
sun.gc.tlab.alloc=7505432
sun.gc.tlab.allocThreads=20
sun.gc.tlab.fastWaste=0
sun.gc.tlab.fills=186
sun.gc.tlab.gcWaste=295904
sun.gc.tlab.maxFastWaste=0
sun.gc.tlab.maxFills=65
sun.gc.tlab.maxGcWaste=99679
sun.gc.tlab.maxSlowAlloc=56
sun.gc.tlab.maxSlowWaste=16716
sun.gc.tlab.slowAlloc=159
sun.gc.tlab.slowWaste=17361
sun.java2d.d3d.available=1
sun.management.JMXConnectorServer.address="service:jmx:rmi://127.0.0.1/stub/..."
sun.os.hrt.frequency=14318180
sun.os.hrt.ticks=891781799649
sun.perfdata.majorVersion=2
sun.perfdata.minorVersion=0
sun.perfdata.overflow=0
sun.perfdata.size=65536
sun.perfdata.timestamp=880818947018
sun.perfdata.used=16824
sun.property.sun.boot.class.path="C:\Program Files\Java\jre7\lib\rt.jar"
sun.property.sun.boot.library.path="C:\Program Files\Java\jre7\bin"
sun.rt._sync_ContendedLockAttempts=4621
sun.rt._sync_Deflations=7458
sun.rt._sync_EmptyNotifications=0
sun.rt._sync_FailedSpins=0
sun.rt._sync_FutileWakeups=982
sun.rt._sync_Inflations=7468
sun.rt._sync_MonExtant=1408
sun.rt._sync_MonInCirculation=0
sun.rt._sync_MonScavenged=0
sun.rt._sync_Notifications=12914
sun.rt._sync_Parks=17188
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=890341636002
sun.rt.createVmBeginTime=1412769193370
sun.rt.createVmEndTime=1412769193451
sun.rt.internalVersion="Java HotSpot(TM) 64-Bit Server VM (24.51-b03) for windows-amd64 JRE (1.7.0_51-b13)
sun.rt.interruptedBeforeIO=0
sun.rt.interruptedDuringIO=0
sun.rt.javaCommand="org.apache.catalina.startup.Bootstrap start"
sun.rt.jvmCapabilities="1000000000000000000000000000000000000000000000000000000000000000"
sun.rt.jvmVersion=405995523
sun.rt.safepointSyncTime=41171439
sun.rt.safepointTime=1402882008
sun.rt.safepoints=19547
sun.rt.threadInterruptSignaled=0
sun.rt.vmInitDoneTime=1412769193417
sun.threads.vmOperationTime=1293787916
sun.urlClassLoader.readClassBytesTime=5780815336
sun.zip.zipFile.openTime=7467857453
sun.zip.zipFiles=18942

Комментариев нет:

Отправить комментарий