Documentation
¶
Overview ¶
Package process discovers and inspects running processes. A snapshot carries process identity (pid, start identity, parent), the executable and owner, and, on request, bounded file, mapping, socket and IPC evidence and usage. Coverage says whether an empty answer means nothing was there or the OS did not allow looking. Arguments, environment contents and file contents are never collected.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstanceID ¶
func InstanceID(host string, p ProcessInfo) string
InstanceID returns the identifier of one process instance on a host. The host, pid and start identity together make it up, so a reused pid is a different instance.
Types ¶
type ApplicationInfo ¶
ApplicationInfo identifies an application through OS packaging conventions. It does not assign product capabilities or infer an engine from a name.
type CollectionStatus ¶
type CollectionStatus struct {
State string `json:"state"`
// Reason says why something is missing, from the set every package shares
// (testdata/capability/v1): unsupported, permission, no_device or tool_missing.
Reason string `json:"reason,omitempty"`
Detail string `json:"detail,omitempty"`
ObservedAt *time.Time `json:"observed_at,omitempty"`
}
CollectionStatus distinguishes an empty observation from inaccessible data. State is complete, partial, permission-denied, unsupported, exited, or unavailable. Detail is a diagnostic, never process arguments or environment contents.
func (CollectionStatus) Validate ¶ added in v0.4.0
func (s CollectionStatus) Validate() error
Validate checks that the state is known and the reason fits it (see the capability fixtures).
type ProcessInfo ¶
type ProcessInfo struct {
PID int `json:"pid"`
ParentPID int `json:"parent_pid"`
Name string `json:"name"`
StartID string `json:"start_id,omitempty"`
Executable string `json:"executable,omitempty"`
Owner string `json:"owner,omitempty"`
Application *ApplicationInfo `json:"application,omitempty"`
Usage *ProcessUsage `json:"usage,omitempty"`
Coverage map[string]CollectionStatus `json:"coverage"`
Resources []ProcessResource `json:"resources,omitempty"`
// contains filtered or unexported fields
}
ProcessInfo identifies a process instance using PID and an OS start identity. StartID is opaque and platform-specific. Empty StartID means identity could not be established; such entries are returned but never projected as stable nodes.
type ProcessOptions ¶
ProcessOptions bounds returned records and collection time. Zero values select 4096 processes, 1024 resources per category, and a ten-second deadline. Detailed resource inspection is opt-in through InspectProcess.
type ProcessResource ¶
type ProcessResource struct {
Kind string `json:"kind"`
Path string `json:"path,omitempty"`
Descriptor string `json:"descriptor,omitempty"`
Protocol string `json:"protocol,omitempty"`
LocalAddress string `json:"local_address,omitempty"`
RemoteAddress string `json:"remote_address,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
State string `json:"state,omitempty"`
}
ProcessResource is OS evidence. A socket does not imply an automation API. Endpoint preserves an OS-rendered address when its roles cannot be established. Descriptors are process-local observations, not reusable handles.
type ProcessSnapshot ¶
type ProcessSnapshot struct {
HostID string `json:"host_id"`
Scope string `json:"scope"`
ObservedAt time.Time `json:"observed_at"`
Enumeration CollectionStatus `json:"enumeration"`
Processes []ProcessInfo `json:"processes"`
}
ProcessSnapshot is a non-atomic, point-in-time OS observation. Scope is all or process; only complete all-process enumeration permits removing absent PIDs. HostID includes the boot/namespace identity so records cannot cross reboots.
func DiscoverProcesses ¶
func DiscoverProcesses(ctx context.Context, options ProcessOptions) (ProcessSnapshot, error)
DiscoverProcesses collects identities without scanning every process's files. Processes hidden by the OS are outside this caller-visible inventory.
func InspectProcess ¶
func InspectProcess(ctx context.Context, pid int, options ProcessOptions) (ProcessSnapshot, error)
InspectProcess inspects one process and checks its identity again afterwards. Resources collected during exit or PID reuse are discarded, never reassigned.