monitor

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(bytes uint64) string

func FormatCPU

func FormatCPU(percent float64) string

Types

type ChildInfo

type ChildInfo struct {
	PID         int32
	Name        string
	CPUPercent  float64
	MemoryBytes uint64
	IsThread    bool
}

type ConfigInterface

type ConfigInterface interface {
	GetCPUThreshold() float64
	GetMemoryThreshold() uint64
	GetRefreshRate() time.Duration
}

type Monitor

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

func New

func New(config ConfigInterface) *Monitor

func (*Monitor) GetFilteredProcesses

func (m *Monitor) GetFilteredProcesses() ([]*ProcessInfo, error)

func (*Monitor) GetResourceLevel

func (m *Monitor) GetResourceLevel(cpuPercent float64, memoryMB float64) ResourceLevel

func (*Monitor) GetSystemMetrics

func (m *Monitor) GetSystemMetrics() (*SystemMetrics, error)

func (*Monitor) ToggleExpanded

func (m *Monitor) ToggleExpanded(pid int32)

type ProcessInfo

type ProcessInfo struct {
	PID          int32
	PPID         int32
	Name         string
	CPUPercent   float64
	MemoryBytes  uint64
	MemoryMB     float64
	Children     []ChildInfo
	Expanded     bool
	LastUpdate   time.Time
	ParentCPU    float64 // Store original parent CPU for display
	ParentMemory uint64  // Store original parent memory for display
}

type ResourceLevel

type ResourceLevel int
const (
	Low ResourceLevel = iota
	Medium
	High
)

func (ResourceLevel) String

func (rl ResourceLevel) String() string

type SystemMetrics

type SystemMetrics struct {
	CPUPercent      float64
	CPUCores        int
	MemoryTotal     uint64
	MemoryUsed      uint64
	MemoryAvailable uint64
	MemoryCached    uint64
	MemoryBuffers   uint64
	MemoryPercent   float64
	SwapTotal       uint64
	SwapUsed        uint64
	SwapPercent     float64
}

Jump to

Keyboard shortcuts

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