Fully featured low overhead profiler for Java EE and Java SE platforms.
Ultimate profiling and monitoring solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Remote application profiler agent port

Moderators: Vladimir Kondratyev, Anton Katilin

Remote application profiler agent port

Postby sandeep » Wed May 16, 2012 3:44 pm

I want to profile all .NET applications on a remoter machine. I've copied the ynpagent.dll and setup as described in he docs. Is there a way to get a list of processes and the port the profiling agent is listening on for all the processes that have started with profiling agent on the remote machine?

I can see this list when I click "Connect to Remote application" in the UI and specify the host machine.
sandeep
 
Posts: 24
Joined: Wed May 16, 2012 3:08 pm

Re: Remote application profiler agent port

Postby Anton Katilin » Wed May 16, 2012 5:54 pm

The only way to explicitly get the list is to use "Connect to Remote application" in the UI.

You can use the API to get this information programmatically:
http://www.yourkit.com/docs/net70/help/api.jsp

The following simple code enumerates the ports of at a given host and prints them out to the console:
Code: Select all
using System;
using YourKit.Profiler.Api;

class ListProfiledApplications {
  static int Main(string[] args) {
    if (args.Length != 1) {
      Console.WriteLine("use: <remote host name or IP address>");
      return 1;
    }

    String host = args[0];

    Console.WriteLine("Probing profiler agents at " + host);

    int found = 0;

    for (int port = 10001; port <= 10010; port++) {
      try {
        Controller controller = new Controller(host, port);
        Console.WriteLine("port=" + port);
        found++;
      }
      catch (Exception) {
        // no agent at this port
      }
    }

    Console.WriteLine("Totally found: " + found);

    return 0;
  }
}

Notes:

1. The API dll is located in <profiler installation directory>\api\YourKit.Profiler.Api.dll
You will need to reference it when compiling this example. When running the example, it should be in the PATH or in the current directory.

2. A method to retrieve the PID is not exposed in the public API now. We will add Controller.GetPID() method it in the next build 7.0.2.
Anton Katilin
 
Posts: 5576
Joined: Wed Aug 11, 2004 8:37 am

Re: Remote application profiler agent port

Postby Anton Katilin » Fri May 18, 2012 3:34 pm

Version 7.0.2 has been released.

Please find below the modified example which prints port, PID and name for each found profiled application:
Code: Select all
using System;
using YourKit.Profiler.Api;

class ListProfiledApplications {
  static int Main(string[] args) {
    if (args.Length != 1) {
      Console.WriteLine("use: <remote host name or IP address>");
      return 1;
    }

    String host = args[0];

    Console.WriteLine("Probing profiler agents at " + host);

    int found = 0;

    for (int port = 10001; port <= 10010; port++) {
      try {
        Controller controller = new Controller(host, port);
        Console.WriteLine("port=" + port + " pid=" + controller.GetPID() + " name=" + controller.GetSessionName());
        found++;
      }
      catch (Exception) {
        // no agent at this port
      }
    }

    Console.WriteLine("Totally found: " + found);

    return 0;
  }
}
Anton Katilin
 
Posts: 5576
Joined: Wed Aug 11, 2004 8:37 am


Return to .NET Profiler

Who is online

Users browsing this forum: No registered users and 3 guests