Skip to main content

Module agent

Module agent 

Source
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§

AgentMessage
Messages from the agent to the client.
ClientMessage
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 input is closed or output fails.
write_message
Writes one message as a JSON line and flushes it.