process

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LinuxProcStatusPath = "/proc/{pid}/status"
	LinuxProcSmapsPath  = "/proc/{pid}/smaps"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CpuUsage

type CpuUsage struct {
	Percentage float32 `json:"percentage"`
}

type DarwinProcess added in v0.3.2

type DarwinProcess struct {
	Pid int32
}

func NewDarwinProcess added in v0.3.2

func NewDarwinProcess(pid int32) (*DarwinProcess, error)

func (*DarwinProcess) GetCpuUsage added in v0.3.2

func (p *DarwinProcess) GetCpuUsage() (CpuUsage, error)

func (*DarwinProcess) GetMemoryUsage added in v0.3.2

func (p *DarwinProcess) GetMemoryUsage() (MemoryUsage, error)

func (*DarwinProcess) GetName added in v0.3.2

func (p *DarwinProcess) GetName() (string, error)

func (*DarwinProcess) GetRss added in v0.3.2

func (p *DarwinProcess) GetRss() (int64, error)

func (*DarwinProcess) GetStats added in v0.3.2

func (p *DarwinProcess) GetStats() (ProcessStats, error)

func (*DarwinProcess) GetSwap added in v0.5.5

func (p *DarwinProcess) GetSwap() (int64, error)

func (*DarwinProcess) WatchStats added in v0.3.2

func (p *DarwinProcess) WatchStats(ctx context.Context, interval time.Duration) <-chan ProcessStats

type LinuxProcess

type LinuxProcess struct {
	Pid int32
	// contains filtered or unexported fields
}

func NewLinuxProcess

func NewLinuxProcess(pid int32) (*LinuxProcess, error)

func (*LinuxProcess) GetCpuUsage

func (p *LinuxProcess) GetCpuUsage() (CpuUsage, error)

func (*LinuxProcess) GetMemoryUsage

func (p *LinuxProcess) GetMemoryUsage() (MemoryUsage, error)

func (*LinuxProcess) GetName

func (p *LinuxProcess) GetName() (string, error)

func (*LinuxProcess) GetRss

func (p *LinuxProcess) GetRss() (int64, error)

GetRss returns the current memory usage in kilobytes of the process. This is calculated from the total RSS from all the libraries and itself that the process uses. RSS includes heap and stack memory, but not swap memory.

func (*LinuxProcess) GetStats

func (p *LinuxProcess) GetStats() (ProcessStats, error)

func (*LinuxProcess) GetSwap added in v0.5.5

func (p *LinuxProcess) GetSwap() (int64, error)

GetRssWithSwap returns the current memory usage in kilobytes of the process. This is calculated from the total memory from all the libraries and itself that the process uses.

func (*LinuxProcess) WatchStats

func (p *LinuxProcess) WatchStats(ctx context.Context, interval time.Duration) <-chan ProcessStats

type MemoryUsage

type MemoryUsage struct {
	Rss     int64 `json:"rss"`
	RssSwap int64 `json:"rssSwap"`
}

type Process

type Process interface {
	GetName() (string, error)
	GetStats() (ProcessStats, error)
	WatchStats(ctx context.Context, interval time.Duration) <-chan ProcessStats
	GetCpuUsage() (CpuUsage, error)
	GetMemoryUsage() (MemoryUsage, error)
	GetRss() (int64, error)
	GetSwap() (int64, error)
}

func NewProcess

func NewProcess(pid int32) (Process, error)

type ProcessState

type ProcessState string
const (
	ProcessStateSleeping            ProcessState = "S"
	ProcessStateRunning             ProcessState = "R"
	ProcessStateZombie              ProcessState = "Z"
	ProcessStateUninterruptibleWait ProcessState = "D"
)

type ProcessStats

type ProcessStats struct {
	CpuUsage    CpuUsage    `json:"cpuUsage"`
	MemoryUsage MemoryUsage `json:"memoryUsage"`
	Timestamp   time.Time   `json:"timestamp"`
}

type WindowsProcess added in v0.3.2

type WindowsProcess struct {
	Pid int32
}

func NewWindowsProcess added in v0.3.2

func NewWindowsProcess(pid int32) (*WindowsProcess, error)

func (*WindowsProcess) GetChildrenPids added in v0.3.2

func (p *WindowsProcess) GetChildrenPids() ([]int32, error)

func (*WindowsProcess) GetCpuUsage added in v0.3.2

func (p *WindowsProcess) GetCpuUsage() (CpuUsage, error)

func (*WindowsProcess) GetMemoryUsage added in v0.3.2

func (p *WindowsProcess) GetMemoryUsage() (MemoryUsage, error)

func (*WindowsProcess) GetName added in v0.3.2

func (p *WindowsProcess) GetName() (string, error)

func (*WindowsProcess) GetRss added in v0.3.2

func (p *WindowsProcess) GetRss() (int64, error)

func (*WindowsProcess) GetStats added in v0.3.2

func (p *WindowsProcess) GetStats() (ProcessStats, error)

func (*WindowsProcess) GetSwap added in v0.5.5

func (p *WindowsProcess) GetSwap() (int64, error)

func (*WindowsProcess) WatchStats added in v0.3.2

func (p *WindowsProcess) WatchStats(ctx context.Context, interval time.Duration) <-chan ProcessStats

Jump to

Keyboard shortcuts

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