Documentation
¶
Index ¶
- func Environment(ctx context.Context, pid int) (map[string]string, error)
- type Descriptor
- type EnvironmentOptions
- type Process
- type ProcessIO
- type ResourceUsage
- type Snapshot
- func (s *Snapshot) AggregateSubtree(pid int) ResourceUsage
- func (s *Snapshot) All() []Process
- func (s *Snapshot) Ancestors(pid int) []Process
- func (s *Snapshot) Get(pid int) (Process, bool)
- func (s *Snapshot) PopulateIO(ctx context.Context, pids []int) error
- func (s *Snapshot) PopulateWorkingDirectories(ctx context.Context, pids []int)
- func (s *Snapshot) Subtree(pid int) []Process
- type SnapshotOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Descriptor ¶ added in v1.21.79
type Descriptor struct {
FD string `json:"fd"`
Type string `json:"type"`
Name string `json:"name"`
Protocol string `json:"protocol,omitempty"`
State string `json:"state,omitempty"`
LocalAddr string `json:"localAddr,omitempty"`
RemoteAddr string `json:"remoteAddr,omitempty"`
Port int `json:"port,omitempty"`
}
Descriptor is one file a process holds open, as lsof reports it: a regular file, directory, device, pipe or socket. Internet sockets carry their protocol, TCP state and endpoints.
func Descriptors ¶ added in v1.21.79
func Descriptors(ctx context.Context, pid int) ([]Descriptor, error)
Descriptors lists the files and sockets pid holds open, read with lsof.
func (Descriptor) IsListening ¶ added in v1.21.79
func (d Descriptor) IsListening() bool
IsListening reports whether d accepts traffic on its port: a listening TCP socket, or a UDP socket bound without a peer.
func (Descriptor) IsSocket ¶ added in v1.21.79
func (d Descriptor) IsSocket() bool
IsSocket reports whether d is an internet or unix-domain socket.
type EnvironmentOptions ¶
type Process ¶
type Process struct {
PID int `json:"pid"`
PPID int `json:"ppid,omitempty"`
Status string `json:"status,omitempty"`
Active bool `json:"active"`
CPUPercent float64 `json:"cpuPercent,omitempty"`
MemoryPercent float64 `json:"memoryPercent,omitempty"`
RSSBytes uint64 `json:"rssBytes,omitempty"`
IO *ProcessIO `json:"io,omitempty"`
StartedAt *time.Time `json:"startedAt,omitempty"`
Command string `json:"command,omitempty"`
CWD string `json:"cwd,omitempty"`
CWDError string `json:"cwdError,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
EnvironmentError string `json:"environmentError,omitempty"`
}
type ResourceUsage ¶
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
func Discover ¶
func Discover(ctx context.Context, opts SnapshotOptions) (*Snapshot, error)
Discover lists the host's processes, leaving out the ps it runs to list them: a caller sampling its own process tree would otherwise see a new child of its own at every sample.
func NewSnapshot ¶
func (*Snapshot) AggregateSubtree ¶
func (s *Snapshot) AggregateSubtree(pid int) ResourceUsage
func (*Snapshot) PopulateIO ¶ added in v1.21.72
func (*Snapshot) PopulateWorkingDirectories ¶
type SnapshotOptions ¶
type SnapshotOptions struct {
Environment *EnvironmentOptions
}
Click to show internal directories.
Click to hide internal directories.