Programmatically invoke Yourkit

Questions about YourKit Java Profiler
Post Reply
sranjan
Posts: 4
Joined: Thu Aug 18, 2016 5:49 am

Programmatically invoke Yourkit

Post by sranjan »

Hi,

My company has an enterprise license for Yourkit.

For one of our use cases, we would like to programmatically invoke Yourkit to do some sampling and parse the snapshot file and display some statistics. We were looking at the javadocs api at https://www.yourkit.com/docs/80/api/index.html and while it does seem to expose some interfaces we would like to try out, we can’t find how to pass the license server/license key details programmatically.

In summary, invoking Yourkit to generate the snapshot seems easy, the tricky part seems to be programmatically reading this snapshot and generating some statistics from it. Is this possible at all? If so, please could you point me to some docs or samples that could be helpful.
Vladimir Kondratyev
Posts: 1619
Joined: Tue Aug 10, 2004 7:52 pm

Re: Programmatically invoke Yourkit

Post by Vladimir Kondratyev »

Hello,

which profiler version do you use?

Best regards,
Vladimir Kondratyev
YourKit GmbH
http://www.yourkit.com
"Don't get lost in data, get information!"
sranjan
Posts: 4
Joined: Thu Aug 18, 2016 5:49 am

Re: Programmatically invoke Yourkit

Post by sranjan »

11.0.10
Vladimir Kondratyev
Posts: 1619
Joined: Tue Aug 10, 2004 7:52 pm

Re: Programmatically invoke Yourkit

Post by Vladimir Kondratyev »

Version 11.x is not supported, so we recommend to upgrade to latest v2016.2.

In v2016.2 you can load snapshot from command line and export it into different formats. Please find details at https://www.yourkit.com/docs/java/help/export.jsp

Best regards,
Vladimir Kondratyev
YourKit GmbH
http://www.yourkit.com
"Don't get lost in data, get information!"
sranjan
Posts: 4
Joined: Thu Aug 18, 2016 5:49 am

Re: Programmatically invoke Yourkit

Post by sranjan »

Hi Vladimir,

Thanks for the tip. I had couple of other related questions -

1.) Other than running the export locally on the same machine as you mentioned, is it possible to invoke the export programmatically using the API? We are able to connect to the remote agent programmatically and trigger the sampling so, it would have been kind of useful to be able to export also programmatically.

2.) The snapshot file is generated on the remote host (where the agent is running). Now, we know that the YourKit UI is able to retrieve the snapshot from the remote agent and display the statistics on the UI. Is it also possible to be able to retrieve the generated snapshot file programmatically from the remote host?

Please could you help?

Kind Regards
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Programmatically invoke Yourkit

Post by Anton Katilin »

Hi,

1) The export functionality requires a full installed copy of the profiler which is properly activated with a license key. Thus to perform export on a remote machine you need to dedicate a license seat for it. You decide whether this makes sense in your particular case.

2) There is no built-in support for that, but since snapshots are just files you can transfer them via any means for file transfer e.g. scp.
sranjan
Posts: 4
Joined: Thu Aug 18, 2016 5:49 am

Re: Programmatically invoke Yourkit

Post by sranjan »

Hi Anton,
Anton Katilin wrote: 2) There is no built-in support for that, but since snapshots are just files you can transfer them via any means for file transfer e.g. scp.
The idea is to be able to do it programmatically without involving a lot of operational overhead - e.g. scp or SFTP etc.

We were wondering how does the UI do it? For e.g. if you are using the Yourkit UI to profile a remote server, once you stop the sampling, it gives you an option to save the snapshot locally. Surely, it must be the Yourkit agent running on the remote host that must be transferring the files to it maybe in some sort of native way. Direct socket?

We were wondering if it was possible to mimic this behaviour programmatically too as it would be more efficient.

Kind Regards
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Programmatically invoke Yourkit

Post by Anton Katilin »

The profiler UI collects information from the profiler agent, periodically updating it. In other words, the UI maintains a local copy of the agent data. There is no public API for doing the same. The profiler agent is listening on port. The communication protocol is binary, internal and is subject to change between versions.
Post Reply