---
title: "List local simulation debug probes from the command line"
url: https://recursiveai.org/onescope/cookbook/list-local-simulation-probes/
description: "Use onescope attach to list local simulation debug probes as JSON and find your host’s process ID without opening the live stream."
version: "1.0.0"
---

# List local simulation debug probes from the command line

**OneScope** is a free, open-source viewer for simulation recordings, with a desktop window or command-line control, from Recursive AI. MIT or Apache-2.0.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneScope.Tool) · [GitHub](https://github.com/recursive-ai-oss/onescope-csharp) · [Docs](https://recursiveai.org/onescope/docs/) · [Download example (.zip)](https://recursiveai.org/onescope/cookbook/list-local-simulation-probes/list-local-simulation-probes.zip)

A probe is a local endpoint your simulation opens so a viewer can find it.

```shell
dotnet tool install --global RecursiveAI.OneScope.Tool
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```shell
onescope attach
```

With no process ID (PID), it lists probes as JSON instead of opening the viewer. For an empty probe directory, it prints:

```json
{"probes":[],"removedStale":[],"unreadable":[]}
```

`removedStale` lists leftover socket files the tool removed. `unreadable` reports sockets the tool couldn’t read or stale files it couldn’t remove.

Unzip [the example](https://recursiveai.org/onescope/cookbook/list-local-simulation-probes/list-local-simulation-probes.zip), then `dotnet run`.

## Full program

To try a nonempty listing without a game, the example starts one probe with module ID `demo`, version `1.0.0`, and format `1`. It lists only its private temporary directory and checks that the PID returned by the command is its own. No input files are needed. The example pins and installs the tool into that temporary directory; its project references the host-side package:

```shell
dotnet add package RecursiveAI.OneScope.Probe
```

```csharp
using System.Buffers;
using System.Diagnostics;
using System.Text.Json;
using OneScope.Probe;

var directory = Directory.CreateTempSubdirectory("scope-");
try
{
    string tools = Path.Combine(directory.FullName, "tools");
    Run("dotnet", "tool", "install", "RecursiveAI.OneScope.Tool",
        "--version", "1.0.0", "--tool-path", tools);
    using var probe = ScopeProbe.Attach(
        new ProbeInfo("demo", "1.0.0", 1), new DiscoveryOnly(),
        new ProbeOptions { Directory = directory.FullName });

    string command = OperatingSystem.IsWindows() ? "onescope.exe" : "onescope";
    var json = Run(Path.Combine(tools, command), "attach", "--dir", directory.FullName);
    using var document = JsonDocument.Parse(json);
    var entry = document.RootElement.GetProperty("probes").EnumerateArray().Single();
    Console.WriteLine($"Module: {entry.GetProperty("module").GetString()}");
    Console.WriteLine($"PID matches host: {entry.GetProperty("pid").GetInt32() == Environment.ProcessId}");
}
finally
{
    directory.Delete(recursive: true);
}

static string Run(string command, params string[] args)
{
    var start = new ProcessStartInfo(command) { RedirectStandardOutput = true };
    if (Environment.GetEnvironmentVariable("DOTNET_ROOT") is null &&
        Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") is string dotnet)
        start.Environment["DOTNET_ROOT"] = Path.GetDirectoryName(dotnet)!;
    foreach (string arg in args)
        start.ArgumentList.Add(arg);
    using var child = Process.Start(start) ?? throw new InvalidOperationException("Cannot start the command.");
    string output = child.StandardOutput.ReadToEnd();
    child.WaitForExit();
    if (child.ExitCode != 0)
        throw new InvalidOperationException(output);
    return output;
}

sealed class DiscoveryOnly : ISnapshotSource
{
    public void WriteSnapshot(IBufferWriter<byte> writer) =>
        throw new NotSupportedException("This example lists probes only.");
}
```

```text
Module: demo
PID matches host: True
```

Here’s the entry from that run’s `probes` array, with the socket directory shortened. Your PID and socket path will differ.

```json
{
  "pid": 2252952,
  "socket": "…/p2252952-1.sock",
  "module": "demo",
  "library": "1.0.0",
  "format": 1
}
```

If your own host isn’t listed, make sure it is still running with a listening probe and that the command is reading the directory where the host created its socket.

## Variations

If you launched your host with a custom probe directory, list only that directory. Here `./simulation-probes` is the directory set in your host’s `ProbeOptions.Directory`:

```shell
onescope attach --dir ./simulation-probes
```

## Related recipes

- [Attach to a running physics game](https://recursiveai.org/onescope/cookbook/attach-to-a-running-game/)
- [Write a custom replay viewer module](https://recursiveai.org/onescope/cookbook/write-a-onescope-module/)

## The short answer

Run `onescope attach` with no PID and look inside the `probes` array. Each entry includes `pid`, `socket`, `module`, `library`, and `format`. Use the PID of the host you launched to distinguish it from another instance with the same module and library version. The PID goes in a separate command only if you want to open the live recording. Listing doesn’t open the live stream.

## What is a simulation debug probe?

A OneScope probe is part of the host program, not a system-wide debugger that discovers every running game. An instrumented host opens a local Unix-domain socket and supplies a module ID and version information in an initial message. Listing connects long enough to read that message and then closes the connection without requesting the replay stream. That distinction is why the download can list a probe that does not implement a working snapshot writer. To actually watch a live world you also need a viewer module that understands the host’s snapshots and replay records, as described in the [live attach guide](https://recursiveai.org/onescope/docs/live-attach/).

## Why isn’t my simulation in the probe list?

First check that you started the build with the probe enabled. If you use `ProbeOptions.Directory` or set `ONESCOPE_SOCKET_DIR` for the host, check where the socket was created. Pass that same directory to `--dir` on the listing command. Without an override, the default is per user: `$XDG_RUNTIME_DIR/onescope` on Unix when that variable is set to an absolute path, or `onescope/probes` under the user’s local application data otherwise.

Read the other two arrays before treating an empty `probes` array as conclusive. A stale socket that OneScope could remove appears in `removedStale`; it isn’t a running simulation. `unreadable` contains sockets the tool couldn’t read or stale sockets it couldn’t remove. Listing can therefore clean up abandoned socket files even though it doesn’t open a live stream. For an isolated check, point `--dir` at the directory for your own host instead of using the shared default for that account.
