Skip to content

top

top

Monitor commands — mzt top real-time system monitor.

Provides four operating modes:

  1. TUI (default) — Rich Textual-based terminal UI showing job-centric process tree, event timeline, and system metrics.

  2. JSON (--json) — Streams NDJSON snapshots to stdout for piping to other tools or AI consumption.

  3. History (--history 1h) — Replays historical snapshots from the profiler SQLite database.

  4. Trace (--trace PID) — Attaches full strace to a specific process and streams trace output to the terminal.

Classes

Functions

top

top(json_output=Option(False, '--json', help='Stream JSON snapshots (NDJSON)'), history=Option(None, '--history', help="Replay historical data (e.g., '1h', '30m')"), trace_pid=Option(None, '--trace', help='Attach full strace to PID and stream output'), filter_job=Option(None, '--score', '-s', help='Filter by score ID'), interval=Option(2.0, '--interval', '-i', help='Refresh interval in seconds'))

Real-time system monitor for Marianne — like htop for your conductor.

Shows score-centric process tree, resource metrics, event timeline, anomaly detection, and learning insights.

Examples:

mzt top # Launch TUI monitor mzt top --json # Stream NDJSON snapshots mzt top --history 1h # Replay last hour mzt top --score my-review # Filter by score mzt top --interval 5 # 5-second refresh mzt top --trace 12345 # Attach full strace to PID

Source code in src/marianne/cli/commands/top.py
def top(
    json_output: bool = typer.Option(
        False, "--json", help="Stream JSON snapshots (NDJSON)"
    ),
    history: str | None = typer.Option(
        None, "--history", help="Replay historical data (e.g., '1h', '30m')"
    ),
    trace_pid: int | None = typer.Option(
        None, "--trace", help="Attach full strace to PID and stream output"
    ),
    filter_job: str | None = typer.Option(
        None, "--score", "-s", help="Filter by score ID"
    ),
    interval: float = typer.Option(
        2.0, "--interval", "-i", help="Refresh interval in seconds"
    ),
) -> None:
    """Real-time system monitor for Marianne — like htop for your conductor.

    Shows score-centric process tree, resource metrics, event timeline,
    anomaly detection, and learning insights.

    Examples:
        mzt top                    # Launch TUI monitor
        mzt top --json             # Stream NDJSON snapshots
        mzt top --history 1h       # Replay last hour
        mzt top --score my-review  # Filter by score
        mzt top --interval 5       # 5-second refresh
        mzt top --trace 12345      # Attach full strace to PID
    """
    if trace_pid is not None:
        asyncio.run(_trace_mode(trace_pid))
    elif history is not None:
        duration_seconds = _parse_duration(history)
        if json_output:
            asyncio.run(_history_json(duration_seconds, filter_job=filter_job))
        else:
            asyncio.run(_history_tui(duration_seconds, filter_job=filter_job))
    elif json_output:
        asyncio.run(_json_mode(filter_job=filter_job, interval=interval))
    else:
        _tui_mode(filter_job=filter_job, interval=interval)