Process
The processes of the host. osapi dsl behavior get --name process and
osapi dsl behavior method get show the same.
Behavior
| Name | process |
| Description | The processes of the host |
| Placement | node |
| Area | node |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | linux, darwin |
| Sudo | none |
| Runs | none |
| Writes | none |
| Keeps state | no |
| Uses | none |
| Used by | none |
Methods (3)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|---|---|---|---|---|
| list | read | GET | /api/node/{hostname}/process | process:read | List the processes of the host |
| get | read | GET | /api/node/{hostname}/process/{pid} | process:read | Get one process |
| signal | write | POST | /api/node/{hostname}/process/{pid}/signal | process:write | Send a signal to a process |
Types (3)
| NAME | INPUT | OUTPUT |
|---|---|---|
| list | ListInput | []Entry { pid, name, user, state, cpu_percent, mem_percent, mem_rss, command, start_time } |
| get | GetInput { pid* } | Entry { pid, name, user, state, cpu_percent, mem_percent, mem_rss, command, start_time } |
| signal | SignalInput { pid*, signal* } | Result { pid, signal, changed } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| Span | behavior.process.<method> |
| Child spans | exec kill, exec ps |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | pid (get, signal), signal (signal) |
Method list
| Name | list |
| Verb | read |
| Description | List the processes of the host |
| Detail | Lists each process with its user, state, CPU and memory, its command line and when it started, through gohai: from /proc on Linux and from ps on macOS. A process that stops while the list is read is not in it. |
| HTTP | GET |
| Route | /api/node/{hostname}/process |
| Permission | process:read |
| Command | osapi client node process list |
| Input type | ListInput |
| Output type | []Entry |
Input (0)
None. The method takes no input; its command needs only --target.
Output (9)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| pid | integer | The process ID |
| name | string | The name of the process |
| user | string | The user that runs it |
| state | string | Its state, such as running or sleep |
| cpu_percent | number | Its CPU time as a percent of the time since it started |
| mem_percent | number | Its resident memory as a percent of the host's memory |
| mem_rss | integer | Its resident memory in bytes |
| command | string | Its full command line |
| start_time | string | When it started, in RFC 3339 |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| A Linux host that runs sleep | (none) | [command=sleep 300, cpu_percent=5, mem_percent=1, mem_rss=2.097152e+07, name=sleep, pid=1234, start_time=2026-01-02T02:55:45Z, state=sleep, user=alice] |
| A Mac that runs sleep | (none) | [command=sleep 300, cpu_percent=5, mem_percent=1, mem_rss=2.097152e+07, name=sleep, pid=1234, state=sleep, user=alice] |
Method get
| Name | get |
| Verb | read |
| Description | Get one process |
| Detail | Reads one process by its ID, without the others. A process that the host does not have is not found. |
| HTTP | GET |
| Route | /api/node/{hostname}/process/{pid} |
| Permission | process:read |
| Command | osapi client node process get |
| Input type | GetInput |
| Output type | Entry |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| pid | integer | yes | min 1 | The process ID, such as 1234 |
Output (9)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| pid | integer | The process ID |
| name | string | The name of the process |
| user | string | The user that runs it |
| state | string | Its state, such as running or sleep |
| cpu_percent | number | Its CPU time as a percent of the time since it started |
| mem_percent | number | Its resident memory as a percent of the host's memory |
| mem_rss | integer | Its resident memory in bytes |
| command | string | Its full command line |
| start_time | string | When it started, in RFC 3339 |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| A process of a Linux host | pid=1234 | pid=1234, name=sleep, user=alice, state=sleep, cpu_percent=5, mem_percent=1, mem_rss=2.097152e+07, command=sleep 300, start_time=2026-01-02T02:55:45Z |
| A process of a Mac | pid=1234 | pid=1234, name=sleep, user=alice, state=sleep, cpu_percent=5, mem_percent=1, mem_rss=2.097152e+07, command=sleep 300 |
Method signal
| Name | signal |
| Verb | write |
| Description | Send a signal to a process |
| Detail | Sends TERM, KILL, HUP, INT, USR1 or USR2 to one process with kill, and reports changed: true. A process that the host does not have is not found. A process ID below 1 is refused, because kill sends to a group of processes for 0 and for a negative ID. |
| HTTP | POST |
| Route | /api/node/{hostname}/process/{pid}/signal |
| Permission | process:execute |
| Command | osapi client node process signal |
| Input type | SignalInput |
| Output type | Result |
Input (2)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| pid | integer | yes | min 1 | The process ID, such as 1234 |
| signal | string | yes | one of TERM KILL HUP INT USR1 USR2 | The signal: TERM, KILL, HUP, INT, USR1 or USR2 |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| pid | integer | The process ID |
| signal | string | The signal that was sent |
| changed | boolean | Whether the signal was sent |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Stop a process | pid=1234, signal=TERM | pid=1234, signal=TERM, changed=true |