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.
Remote application profiler agent port
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Remote application profiler agent port
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:
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.
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;
}
}
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.
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Remote application profiler agent port
Version 7.0.2 has been released.
Please find below the modified example which prints port, PID and name for each found profiled application:
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;
}
}