process

package
v0.0.0-...-305c77d Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PID            = report.PID
	Name           = report.Name
	PPID           = report.PPID
	Cmdline        = report.Cmdline
	Threads        = report.Threads
	CPUUsage       = "process_cpu_usage_percent"
	MemoryUsage    = "process_memory_usage_bytes"
	OpenFilesCount = "open_files_count"
)

We use these keys in node metadata

Variables

View Source
var (
	MetadataTemplates = report.MetadataTemplates{
		PID:     {ID: PID, Label: "PID", From: report.FromLatest, Datatype: report.Number, Priority: 1},
		Cmdline: {ID: Cmdline, Label: "Command", From: report.FromLatest, Priority: 2},
		PPID:    {ID: PPID, Label: "Parent PID", From: report.FromLatest, Datatype: report.Number, Priority: 3},
		Threads: {ID: Threads, Label: "# Threads", From: report.FromLatest, Datatype: report.Number, Priority: 4},
	}

	MetricTemplates = report.MetricTemplates{
		CPUUsage:       {ID: CPUUsage, Label: "CPU", Format: report.PercentFormat, Priority: 1},
		MemoryUsage:    {ID: MemoryUsage, Label: "Memory", Format: report.FilesizeFormat, Priority: 2},
		OpenFilesCount: {ID: OpenFilesCount, Label: "Open files", Format: report.IntegerFormat, Priority: 3},
	}
)

Exposed for testing

Functions

func GetDeltaTotalJiffies

func GetDeltaTotalJiffies() (uint64, float64, error)

GetDeltaTotalJiffies returns the number of jiffies that have passed since it was last called. In that respect, it is side-effect-ful.

func IsProcInAccept

func IsProcInAccept(procRoot, pid string) (ret bool)

IsProcInAccept returns true if the process has a at least one thread blocked on the accept() system call

Types

type CachingWalker

type CachingWalker struct {
	// contains filtered or unexported fields
}

CachingWalker is a walker than caches a copy of the output from another Walker, and then allows other concurrent readers to Walk that copy.

func NewCachingWalker

func NewCachingWalker(source Walker) *CachingWalker

NewCachingWalker returns a new CachingWalker

func (*CachingWalker) Name

func (*CachingWalker) Name() string

Name of this ticker, for metrics gathering

func (*CachingWalker) Tick

func (c *CachingWalker) Tick() error

Tick updates cached copy of process list

func (*CachingWalker) Walk

func (c *CachingWalker) Walk(f func(Process, Process)) error

Walk walks a cached copy of process list

type Jiffies

type Jiffies func() (uint64, float64, error)

Jiffies is the type for the function used to fetch the elapsed jiffies.

type Process

type Process struct {
	PID, PPID         int
	Name              string
	Cmdline           string
	Threads           int
	Jiffies           uint64
	RSSBytes          uint64
	RSSBytesLimit     uint64
	OpenFilesCount    int
	OpenFilesLimit    uint64
	IsWaitingInAccept bool
}

Process represents a single process.

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

Reporter generates Reports containing the Process topology.

func NewReporter

func NewReporter(walker Walker, scope string, jiffies Jiffies, noCommandLineArguments bool) *Reporter

NewReporter makes a new Reporter.

func (Reporter) Name

func (Reporter) Name() string

Name of this reporter, for metrics gathering

func (*Reporter) Report

func (r *Reporter) Report() (report.Report, error)

Report implements Reporter.

type Tree

type Tree interface {
	GetParent(pid int) (int, error)
}

Tree represents all processes on the machine.

func NewTree

func NewTree(walker Walker) (Tree, error)

NewTree returns a new Tree that can be polled.

type Walker

type Walker interface {
	Walk(func(Process, Process)) error
}

Walker is something that walks the /proc directory

func NewWalker

func NewWalker(procRoot string, gatheringWaitingInAccept bool) Walker

NewWalker creates a new process Walker.

Jump to

Keyboard shortcuts

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