Expand description
The agent protocol for remote monitoring, and the agent loop itself.
A client runs ssh host rigtop --agent; the agent writes snapshots to
stdout and reads commands from stdin. Both directions use JSON Lines: one
JSON object per line, tagged by "type":
agent -> client {"type":"hello","protocol":1,"version":"0.1.0"}
agent -> client {"type":"snapshot","snapshot":{...}}
client -> agent {"type":"set_interval","ms":2000}
client -> agent {"type":"set_process_limit","limit":10}
client -> agent {"type":"signal","pid":1234,"signal":"Terminate"}
agent -> client {"type":"signal_result","pid":1234,"signal":"Terminate","error":null}The agent exits when stdin reaches end of file, so it never outlives the SSH connection that started it.
Enums§
- Agent
Message - Messages from the agent to the client.
- Client
Message - Messages from the client to the agent.
Constants§
- PROTOCOL_
VERSION - Version of the wire format. Bumped on incompatible changes; adding fields to snapshots does not need a bump (all snapshot types default missing fields).
Functions§
- run_
agent - Runs the agent until
inputis closed oroutputfails. - write_
message - Writes one message as a JSON line and flushes it.