cpuinfo

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RxProcSmapsPssLine = regexp.MustCompile(`^\s*(Pss|SwapPss):\s*(\d+)\s*\S*\s*$`)

Functions

func CpuTick

func CpuTick() (t int64)

func GetMemStats

func GetMemStats(pid int) (used uint64)

func GetPidStats

func GetPidStats(pid int) (t int64, ppid, pgrp, nice, threads int)

func NumCores

func NumCores() (n int)

func TimeFromPid

func TimeFromPid(pid int) (t int64)

Types

type ByPid

type ByPid []Process

func (ByPid) Len

func (a ByPid) Len() int

func (ByPid) Less

func (a ByPid) Less(i, j int) bool

func (ByPid) Swap

func (a ByPid) Swap(i, j int)

type ByUsage

type ByUsage []Process

func (ByUsage) Len

func (a ByUsage) Len() int

func (ByUsage) Less

func (a ByUsage) Less(i, j int) bool

func (ByUsage) Swap

func (a ByUsage) Swap(i, j int)

type CProcess

type CProcess struct {
	Pid      int
	Ppid     int
	Pgrp     int
	Nice     int
	Threads  int
	TimePrev int64
	TimeThis int64
	Dirty    bool
	Active   bool
	Usage    float32
}

type CpuInfo

type CpuInfo struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New() (t *CpuInfo, err error)

func (*CpuInfo) GetProcesses

func (t *CpuInfo) GetProcesses(sortByUsage bool) (list []Process, err error)

func (*CpuInfo) GetStats

func (t *CpuInfo) GetStats() (stats Stats, err error)

func (*CpuInfo) Update

func (t *CpuInfo) Update() (err error)

type Process

type Process struct {
	Pid     int
	Ppid    int
	Pgrp    int
	Nice    int
	Threads int
	Usage   float32
	MemUsed uint64
}

type Stats

type Stats struct {
	MemUsed   uint64
	MemFree   uint64
	MemTotal  uint64
	SwapUsed  uint64
	SwapFree  uint64
	SwapTotal uint64
	CpuUsage  []float32
	Uptime    time.Duration
}

func (Stats) String

func (s Stats) String() (text string)

func (Stats) UptimeString

func (s Stats) UptimeString() (up string)

Jump to

Keyboard shortcuts

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