top

package
v0.0.0-...-2aa8b88 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupedProcessInfo

type GroupedProcessInfo struct {
	Name      string   `json:"name"`
	PIDs      []uint32 `json:"pid.list"`
	ParentPID uint32   `json:"parent_pid"`
	Command   string   `json:"command,omitempty"`
	Load1     float64  `json:"load1_percent"`
	Load5     float64  `json:"load5_percent"`
	Load15    float64  `json:"load15_percent"`
}

GroupedProcessInfo is grouped stats for the processes with same (ParentPID, Name, Command)

type Process

type Process struct {
	PID        uint32
	ParentPID  uint32
	Load       float64
	Load1      *ring.Ring
	Load5      *ring.Ring
	Load15     *ring.Ring
	Command    string
	Identifier string
}

Process is used to store aggregated load data about an OS process

type ProcessInfoSlice

type ProcessInfoSlice []*GroupedProcessInfo

ProcessInfoSlice is used for sorting

func (ProcessInfoSlice) Len

func (s ProcessInfoSlice) Len() int

func (ProcessInfoSlice) Less

func (s ProcessInfoSlice) Less(i, j int) bool

func (ProcessInfoSlice) Swap

func (s ProcessInfoSlice) Swap(i, j int)

type ProcessInfoSnapshot

type ProcessInfoSnapshot struct {
	Name      string
	PID       uint32
	ParentPID uint32
	Command   string
	Load      float64
}

ProcessInfoSnapshot is used to store a snapshot of load data about an OS process

type Top

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

Top holds a map with information about process loads

func New

func New() *Top

New returns a new instance of Top struct

func (*Top) GetProcesses

func (t *Top) GetProcesses(interval time.Duration) ([]*ProcessInfoSnapshot, error)

func (*Top) HighestNLoad

func (t *Top) HighestNLoad(n int) []*GroupedProcessInfo

func (*Top) Run

func (t *Top) Run()

Run starts measuring process load on the system

func (*Top) Stop

func (t *Top) Stop()

Stop signals that load measuring should be stopped

Jump to

Keyboard shortcuts

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