process

package
v0.0.0-...-da558fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 22 Imported by: 2

Documentation

Overview

Package process performs the following for the "gomon" command: * measurement of each process on the system * observation of the changing state of the process tree * discovery of all the open connections on the system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connections

func Connections(tb Table)

Connections creates a slice of local to remote connections.

func Endpoints

func Endpoints(ctx context.Context) error

Endpoints starts the lsof command to capture process connections.

func Observer

func Observer(ctx context.Context) error

Observer starts capture of process event observations.

Types

type CommandLine

type CommandLine struct {
	Executable string   `json:"executable" gomon:"property"`
	Args       []string `json:"args" gomon:"property"`
	Envs       []string `json:"envs" gomon:"property"`
}

CommandLine contains a process' command line arguments.

type Connection

type Connection struct {
	Type string   `json:"type" gomon:"property"`
	Self Endpoint `json:"self" gomon:"property"`
	Peer Endpoint `json:"peer" gomon:"property"`
}

Connection represents an inter-process or host/data connection.

type Directories

type Directories struct {
	Cwd  string `json:"cwd" gomon:"property"`
	Root string `json:"root" gomon:"property"`
}

Directories reports the process' root and current working directories.

type Endpoint

type Endpoint struct {
	Name string `json:"name" gomon:"property"`
	Pid  Pid    `json:"pid" gomon:"property"`
}

Endpoint identifies one end of a connection.

type Id

type Id struct {
	Name      string    `json:"name" gomon:"property"`
	Pid       Pid       `json:"pid" gomon:"property"`
	Starttime time.Time `json:"starttime" gomon:"property"`
	// contains filtered or unexported fields
}

Id identifies the message.

type Io

type Io struct {
	ReadActual      int `json:"read_actual" gomon:"counter,B"`
	WriteActual     int `json:"write_actual" gomon:"counter,B"`
	ReadRequested   int `json:"read_requested,omitempty" gomon:"counter,B,linux"`
	WriteRequested  int `json:"write_requested,omitempty" gomon:"counter,B,!windows"`
	ReadOperations  int `json:"read_operations,omitempty" gomon:"counter,count,!darwin"`
	WriteOperations int `json:"write_operations,omitempty" gomon:"counter,count,!darwin"`
}

Io contains a process' I/O metrics.

type Metrics

type Metrics struct {
	Priority                    int           `json:"priority,omitempty" gomon:"gauge,none,!windows"`
	Threads                     int           `json:"threads" gomon:"gauge,count"`
	User                        time.Duration `json:"user" gomon:"counter,ns"`
	System                      time.Duration `json:"system" gomon:"counter,ns"`
	Total                       time.Duration `json:"total" gomon:"counter,ns"`
	Size                        int           `json:"size" gomon:"gauge,B"`
	Resident                    int           `json:"resident" gomon:"gauge,B"`
	Share                       int           `json:"share,omitempty" gomon:"gauge,B,linux"`
	VirtualMemoryMax            int           `json:"virtual_memory_max,omitempty" gomon:"counter,B,linux"`
	ResidentMemoryMax           int           `json:"resident_memory_max,omitempty" gomon:"counter,B,linux"`
	PageFaults                  int           `json:"page_faults" gomon:"counter,count"`
	MinorFaults                 int           `json:"minor_faults,omitempty" gomon:"counter,count,linux"`
	MajorFaults                 int           `json:"major_faults,omitempty" gomon:"counter,count,linux"`
	VoluntaryContextSwitches    int           `json:"voluntary_context_switches,omitempty" gomon:"counter,count,linux"`
	NonVoluntaryContextSwitches int           `json:"nonvoluntary_context_switches,omitempty" gomon:"counter,count,linux"`
	ContextSwitches             int           `json:"context_switches,omitempty" gomon:"counter,count,!windows"`
	Io                          `gomon:""`
}

Metrics defines measurement metrics.

type Pid

type Pid int

Pid is the identifier for a process.

func (Pid) Ancestors

func (pid Pid) Ancestors(tb Table) []Pid

func (Pid) String

func (pid Pid) String() string

String formats a pid as a string to comply with fmt.Stringer interface.

type ProcStats

type ProcStats struct {
	Count  int           `json:"count" gomon:"gauge,count"`
	Active int           `json:"active" gomon:"gauge,count"`
	Execed int           `json:"execed" gomon:"gauge,count"`
	Exited int           `json:"exited" gomon:"gauge,count"`
	CPU    time.Duration `json:"cpu" gomon:"gauge,ns"`
}

ProcStats defines system level process summary metrics. Sent to system.Measure() to include in the system measure.

func Measure

func Measure() (ProcStats, []message.Content)

Measure captures all processes' metrics.

type Process

type Process = measurement

type Properties

type Properties struct {
	Ppid        Pid    `json:"ppid" gomon:"property"`
	Pgid        int    `json:"pgid,omitempty" gomon:"property,,!windows"`
	Tgid        int    `json:"tgid,omitempty" gomon:"property,,linux"`
	Tty         string `json:"tty,omitempty" gomon:"property,,!windows"`
	UID         int    `json:"uid,omitempty" gomon:"property,,!windows"`
	GID         int    `json:"gid,omitempty" gomon:"property,,!windows"`
	Username    string `json:"username" gomon:"property"`
	Groupname   string `json:"groupname,omitempty" gomon:"property,,!windows"`
	Status      string `json:"status" gomon:"enum,none"`
	Nice        int    `json:"nice,omitempty" gomon:"gauge,none,!windows"`
	CommandLine `gomon:""`
	Directories `gomon:""`
}

Properties defines measurement properties.

type Table

type Table = gocore.Table[Pid, *measurement]

Table defines a process table as a map of pids to processes.

func BuildTable

func BuildTable() Table

BuildTable builds a process table and captures current process state.

type Taskstats

type Taskstats struct {
	message.Header[netlinkEvent] `gomon:""`
	Version                      uint16        `json:"version" gomon:"property"`
	AcExitcode                   uint32        `json:"ac_exitcode" gomon:"property"`
	AcFlag                       uint8         `json:"ac_flag" gomon:"property"`
	AcNice                       uint8         `json:"ac_nice" gomon:"property"`
	CPUCount                     uint64        `json:"cpu_count" gomon:"gauge,count"`
	CPUDelayTotal                time.Duration `json:"cpu_delay_total" gomon:"counter,ns"`
	BlkioCount                   uint64        `json:"blkio_count" gomon:"counter,count"`
	BlkioDelayTotal              time.Duration `json:"blkio_delay_total" gomon:"counter,ns"`
	SwapinCount                  uint64        `json:"swapin_count" gomon:"counter,count"`
	SwapinDelayTotal             time.Duration `json:"swapin_delay_total" gomon:"counter,ns"`
	CPURunRealTotal              time.Duration `json:"cpu_run_real_total" gomon:"counter,ns"`
	CPURunVirtualTotal           time.Duration `json:"cpu_run_virtual_total" gomon:"counter,ns"`
	AcComm                       [32]int8      `json:"ac_comm" gomon:"property"`
	AcSched                      uint8         `json:"ac_sched" gomon:"property"`
	AcPad                        [3]uint8

	AcUID                 uint32        `json:"ac_uid" gomon:"property"`
	AcGID                 uint32        `json:"ac_gid" gomon:"property"`
	AcPid                 uint32        `json:"ac_pid" gomon:"property"`
	AcPpid                uint32        `json:"ac_ppid" gomon:"property"`
	AcBtime               uint32        `json:"ac_btime" gomon:"property"`
	AcEtime               time.Duration `json:"ac_etime" gomon:"counter,ns"`
	AcUtime               time.Duration `json:"ac_utime" gomon:"counter,ns"`
	AcStime               time.Duration `json:"ac_stime" gomon:"counter,ns"`
	AcMinflt              uint64        `json:"ac_minflt" gomon:"counter,count"`
	AcMajflt              uint64        `json:"ac_majflt" gomon:"counter,count"`
	Coremem               uint64        `json:"coremem" gomon:"gauge,MB/us"`
	Virtmem               uint64        `json:"virtmem" gomon:"gauge,MB/us"`
	HiwaterRss            uint64        `json:"hiwater_rss" gomon:"gauge,B"`
	HiwaterVM             uint64        `json:"hiwater_vm" gomon:"gauge,B"`
	ReadChar              uint64        `json:"read_char" gomon:"counter,count"`
	WriteChar             uint64        `json:"write_char" gomon:"gauge,count"`
	ReadSyscalls          uint64        `json:"read_syscalls" gomon:"gauge,count"`
	WriteSyscalls         uint64        `json:"write_syscalls" gomon:"gauge,count"`
	Read                  uint64        `json:"read" gomon:"counter,B"`
	Write                 uint64        `json:"write" gomon:"counter,B"`
	CancelledWrite        uint64        `json:"cancelled_write" gomon:"counter,B"`
	Nvcsw                 uint64        `json:"nvcsw" gomon:"counter,count"`
	Nivcsw                uint64        `json:"nivcsw" gomon:"counter,count"`
	AcUtimescaled         time.Duration `json:"ac_utimescaled" gomon:"counter,ns"`
	AcStimescaled         time.Duration `json:"ac_stimescaled" gomon:"counter,ns"`
	CPUScaledRunRealTotal time.Duration `json:"cpu_scaled_run_real_total" gomon:"counter,ns"`
	FreepagesCount        uint64        `json:"freepages_count" gomon:"counter,count"`
	FreepagesDelayTotal   time.Duration `json:"freepages_delay_total" gomon:"counter,ns"`
	ThrashingCount        uint64        `json:"thrashing_count" gomon:"counter,count"`
	ThrashingDelayTotal   time.Duration `json:"thrashing_delay_total" gomon:"counter,ns"`
	AcBtime64             uint64        `json:"ac_btime64" gomon:"property"`
	CompactCount          uint64        `json:"compact_count" gomon:"counter,count"`
	CompactDelayTotal     time.Duration `json:"compact_delay_total" gomon:"counter,ns"`
	AcTgid                uint32        `json:"ac_tgid" gomon:"property"`
	AcTgetime             time.Duration `json:"ac_tgettime" gomon:"counter,ns"`
	AcExeDev              uint64        `json:"ac_exe_dev" gomon:"counter,count"`
	AcExeInode            uint64        `json:"ac_exe_inode" gomon:"counter,count"`
	WpcopyCount           uint64        `json:"wpcopy_count" gomon:"counter,count"`
	WpcopyDelayTotal      uint64        `json:"wpcopy_delay_total" gomon:"counter,ns"`
	// contains filtered or unexported fields
}

Taskstats metrics reported on netlink

type Tree

type Tree = gocore.Tree[Pid, int, *measurement]

Tree organizes the processes into a hierarchy

func BuildTree

func BuildTree(tb Table) Tree

BuildTree builds the process tree.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL