patric-r / jvmtop

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

CPU/Memory Sampling? #97

Closed tckb closed 5 years ago

tckb commented 7 years ago

Hey, this surely is a very handy tool. this essentially could be used for monitoring remote VMs. Is there any way for sampling like in JVisualVm? the current stats are "good to know" but, wouldn't help much in monitoring heap/CPU.

patric-r commented 7 years ago

Hi, CPU sampling (sampling CPU profiler) is supported using the --profile argument.

A heap histogramm could be included, however, this would only work on hotspot vms. Let's put this idea on the feature-request list. Thanks for your suggestion!

tckb commented 7 years ago

@patric-r Yeah I just learnt about the CPU sampling. But, a heap histogram would be a great addition! debugging in a remote vm could quite a challenging. let me know if i can contribute in anyway here.

patric-r commented 7 years ago

Pull requests are always welcome ;) As a hint, sun.tools.attach.HotSpotVirtualMachine.heapHisto() looks like a good place to start.

tckb commented 7 years ago

let me check it out as soon as I get time. 👍

tckb commented 7 years ago

@patric-r I prepared a basic functional version of this feature. You can open this view by passing the flag --profile-mem As soon as I clean up my code. I'll send a PR. Oh and I cleaned up the rest of the code, hope you don't mind. :)

./jvmtop.sh --profile-mem 51672

image

I have added another useful flag ( --enable-deltas). This comes quite handy while profile while profiling memory.

./jvmtop.sh --profile-mem 51672 --enable-deltas

image

kant111 commented 5 years ago

Nice! why is this not merged?

hupfdule commented 5 years ago

Nice! why is this not merged?

I can't tell you the reason why the original author didn't integrate it. But tckb unfortunately changed lots of formattings, which makes it very hard to review his commits. An integration is not possible, if the pull request doesn't only change the functionality.

tckb commented 5 years ago

@kant111 Yeh, so the issue was the original code's formatting made my eye's burn and also, I was following some standard formatting in my IDE and inadvertently that was also committed. Furthermore, I didn't want to switch back to original formatting. If you are still interested in it you can look at my fork (https://github.com/tckb/jvmtop). It's not maintained though.