data

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ThresholdCount     = 4 // CPU, Memory, Disk, Temp
	DisplayCount       = 6 // ChartType, ViewType, SortBy, HistoryLen, ProcessCPU, SortDir
	TabCount           = 9 // all available tabs
	AppearanceCount    = 5 // Theme, RefreshRate, BorderType, BorderStyle, Background
	TotalSettingsCount = ThresholdCount + DisplayCount + TabCount + AppearanceCount
)

Settings overlay index boundaries. Thresholds (0..ThresholdCount-1), Display (ThresholdCount..+DisplayCount), Tabs (+TabCount), Appearance (+AppearanceCount).

View Source
const (
	MaxHealthScore = 100

	// Thresholds for resource usage (Percentage)
	HealthThresholdHealthy  = 90.0 // Below this is fine, above starts penalty
	HealthThresholdWarning  = 70.0 // Warning level
	HealthThresholdCritical = 95.0 // Critical level

	// Penalties deducted from health score
	HealthDeductionCPUCritical    = 30
	HealthDeductionCPUHigh        = 10
	HealthDeductionMemoryCritical = 30
	HealthDeductionMemoryHigh     = 10
	HealthDeductionDiskCritical   = 20
	HealthDeductionTempCritical   = 30
	HealthDeductionTempHigh       = 10

	// Process Tracking
	TopProcessesTrackCount = 5

	// Kill Dialog
	KillDialogDefaultWidth     = 50
	KillDialogButtonTotalWidth = 16
	KillDialogButtonYOffset    = 4

	// Settings Overlay
	SettingsDefaultWidth  = 120
	SettingsDefaultHeight = 22

	// Context Menu
	ContextMenuDefaultWidth = 30

	// Open Files Overlay
	OpenFilesDefaultWidth  = 80
	OpenFilesDefaultHeight = 20

	SamLabDefaultWidth  = 50
	SamLabDefaultHeight = 14
)

Health Scoring Constants

View Source
const (
	ToastInfo    = "info"
	ToastError   = "error"
	ToastWarn    = "warn"
	ToastSuccess = "success"
)
View Source
const ReservedContentRows = 19

Layout: reserved rows for header, footer, borders, and chrome. Used to calculate available content rows: UI.Height - ReservedContentRows.

Variables

View Source
var AllAvailableTabs = []string{
	"Metrics", "Processes", "Disks", "Network",
	"System", "Services", "Connections", "Logs", "Remote",
}

AllAvailableTabs is the canonical list of every tab the settings UI can toggle/reorder.

Functions

This section is empty.

Types

type Accessor

type Accessor interface {
	Len() int
	Get(i int) float64
	Max() float64
}

type Alert

type Alert struct {
	Timestamp time.Time
	Message   string
	Type      config.MetricType
	Value     float64
	Threshold float64
}

type AlertManager

type AlertManager struct {
	ActiveAlerts map[config.MetricType]Alert
	// contains filtered or unexported fields
}

func NewAlertManager

func NewAlertManager() *AlertManager

func (*AlertManager) CheckAlerts

func (am *AlertManager) CheckAlerts(s *AppState)

func (*AlertManager) GetAlerts

func (am *AlertManager) GetAlerts() []Alert

func (*AlertManager) HasAlerts

func (am *AlertManager) HasAlerts() bool

type AppState

type AppState struct {
	Metrics MetricsState
	Process ProcessState
	UI      UIState
	Config  ConfigState
	Remote  RemoteState

	LastErrorTime time.Time
	// contains filtered or unexported fields
}

func (*AppState) ClearProcessMaps

func (s *AppState) ClearProcessMaps()

func (*AppState) GetFilteredProcesses

func (s *AppState) GetFilteredProcesses() []ProcessInfo

func (*AppState) GetHistory

func (s *AppState) GetHistory(pid int32) (*RingBuffer, bool)

func (*AppState) GetOrCreateHistory

func (s *AppState) GetOrCreateHistory(pid int32) *RingBuffer

func (*AppState) GetProcessByPid added in v0.5.0

func (s *AppState) GetProcessByPid(pid int32) (ProcessInfo, bool)

func (*AppState) GetVisibleProcesses

func (s *AppState) GetVisibleProcesses() ([]ProcessInfo, map[int32]int)

func (*AppState) InvalidateProcessCache

func (s *AppState) InvalidateProcessCache()

func (*AppState) IsBookmarked

func (s *AppState) IsBookmarked(pid int32) bool

func (*AppState) IsCollapsed

func (s *AppState) IsCollapsed(pid int32) bool

func (*AppState) IsSuspended

func (s *AppState) IsSuspended(pid int32) bool

func (*AppState) PruneDeadProcessHistory

func (s *AppState) PruneDeadProcessHistory(alivePids map[int32]bool)

func (*AppState) PruneDeadProcessMaps

func (s *AppState) PruneDeadProcessMaps(alivePids map[int32]bool)

func (*AppState) SetSuspended

func (s *AppState) SetSuspended(pid int32, suspended bool)

func (*AppState) SyncProcessesMap added in v0.5.0

func (s *AppState) SyncProcessesMap()

func (*AppState) ToggleBookmark

func (s *AppState) ToggleBookmark(pid int32)

func (*AppState) ToggleCollapsed

func (s *AppState) ToggleCollapsed(pid int32)

type ConfigState added in v0.5.0

type ConfigState struct {
	// Display configuration
	Theme                string
	RefreshRate          int
	BorderType           string
	BorderStyle          string
	BackgroundOpaque     bool
	ProcessCpuNormalized bool

	// Sorting
	SortBy        string
	SortDirection string

	// History
	HistoryLength int

	// Full config
	Config config.AppConfig

	// Timestamps
	StartTime         time.Time
	LastConfigModTime time.Time
}

ConfigState holds all configuration-related state.

type ConnectionInfo

type ConnectionInfo struct {
	LocalAddr  string
	RemoteAddr string
	State      string
	Protocol   string
	Pid        int32
}

type ContainerInfo added in v0.5.0

type ContainerInfo struct {
	Name       string
	ID         string
	Status     string
	State      string
	Image      string
	Created    string
	CPUPercent float64
	MemUsage   uint64
	MemLimit   uint64
	MemPct     float64
	NetRx      uint64
	NetTx      uint64
	Type       string // "docker" or "kubernetes"
}

ContainerInfo represents container metrics

type DiskPartition

type DiskPartition struct {
	Mountpoint string
	Device     string
	Fstype     string
	Total      uint64
	Used       uint64
	UsedPct    float64
}

type GpuInfo

type GpuInfo struct {
	Name        string
	Driver      string
	MemoryTotal string
	MemoryUsed  string
	Slot        string
	Type        string
	Vendor      string
	Temperature string
	FanSpeed    string
	PowerUsage  string
	Utilization string
	ClockSpeed  string
	ErrorMsg    string
}

type HardwareCapabilities added in v0.5.0

type HardwareCapabilities struct {
	HasNvidiaGPU         bool
	HasAmdGPU            bool
	HasIntelGPU          bool
	HasBattery           bool
	HasNetworkInterfaces bool
	HasDiskIO            bool
	HasServices          bool
	HasTempSensors       bool
	HasDocker            bool
	HasKubernetes        bool
}

type K8sPodInfo added in v0.5.0

type K8sPodInfo struct {
	Name       string
	Namespace  string
	Status     string
	Ready      string
	Restarts   int
	CPUReq     string
	MemReq     string
	CPULim     string
	MemLim     string
	CPUPercent float64
	MemPct     float64
	Node       string
	Age        string
}

K8sPodInfo represents Kubernetes pod metrics

type MetricsState added in v0.5.0

type MetricsState struct {
	// History buffers
	CpuHistory  *RingBuffer
	MemHistory  *RingBuffer
	NetHistory  *RingBuffer
	SwapHistory *RingBuffer
	HistoryTemp *RingBuffer

	// Current metrics
	HostInfo      *host.InfoStat
	LoadAvg       *load.AvgStat
	MemInfo       *mem.VirtualMemoryStat
	SwapInfo      *mem.SwapMemoryStat
	CpuInfoStatic []cpu.InfoStat
	Battery       []*battery.Battery

	// Disk I/O history and current
	DiskHORead  *RingBuffer
	DiskHOWrite *RingBuffer
	DiskIO      map[string]disk.IOCountersStat
	LastDiskIO  map[string]disk.IOCountersStat

	// Hardware detection flags
	HasNvidiaGPU         bool
	HasAmdGPU            bool
	HasIntelGPU          bool
	HasBattery           bool
	HasNetworkInterfaces bool
	HasDiskIO            bool
	HasServices          bool
	HasTempSensors       bool

	// Current values
	Cpu           float64
	Memory        float64
	Disk          float64
	Swap          float64
	DiskReadRate  float64
	DiskWriteRate float64
	CpuTemp       float64
	CpuPerCore    []float64

	// Disk and network info
	DiskPartitions        []DiskPartition
	Sensors               []host.TemperatureStat
	NetworkInterfaces     []net.IOCountersStat
	LastNetworkInterfaces map[string]net.IOCountersStat
	LastNetSent           uint64
	LastNetRecv           uint64
	NetSentRate           float64
	NetRecvRate           float64

	// GPU info
	GpuInfo []GpuInfo

	// Alerts
	AlertManager *AlertManager

	// Process history for graphs
	ProcessHistory map[int32]*RingBuffer

	// Health
	HealthScore int
}

MetricsState holds all system metrics and history data.

type ProcessInfo

type ProcessInfo struct {
	NameLower     string
	UsernameLower string
	CmdlineLower  string
	Name          string
	Status        string
	Username      string
	Cmdline       string
	Pid           int32
	CreateTime    int64
	MemoryBytes   uint64
	Cpu           float64
	Memory        float64
	Nice          int32 // Priority
	Ppid          int32 // Parent PID
}

type ProcessSnapshot

type ProcessSnapshot struct {
	Timestamp time.Time
	Cpu       float64
	Memory    float64
}

type ProcessState added in v0.5.0

type ProcessState struct {
	// Process lists
	Processes          []ProcessInfo
	ProcessesByPid     map[int32]ProcessInfo
	CachedVisibleProcs []ProcessInfo
	CachedTreeIndents  map[int32]int

	// Tree view state
	TreeView       bool
	CollapsedPids  map[int32]bool
	BookmarkedPids map[int32]bool

	// Filtering and sorting
	ProcessFilter      string
	ProcessFilterLower string
	SortBy             string
	SortDirection      string
	FilterMode         bool

	// Selection and scroll
	SelectedProcess     int
	ProcessCount        int
	ProcessScrollOffset int

	// Kill dialog
	KillTargetName string
	KillTargetPid  int32

	// Loading state
	ProcessesLoaded bool

	// Suspended processes
	SuspendedState map[int32]bool

	// Open files
	OpenFilesView SimpleViewport
	OpenFilesList []process.OpenFilesStat
	ShowOpenFiles bool
	OpenFilesPid  int32

	// Lazy-loaded data
	ProcessCmdlines  map[int32]string
	ProcessUsernames map[int32]string

	// Context menu
	ShowProcessMenu bool
	ProcessMenuIdx  int
	ProcessMenuX    int
	ProcessMenuY    int

	// Services and connections
	Services                []ServiceInfo
	Connections             []ConnectionInfo
	ServicesScrollOffset    int
	ConnectionsScrollOffset int
	SystemLogs              []string
	LogsScrollOffset        int

	// Dirty flag
	ProcessCacheDirty bool

	// Open files scroll
	OpenFilesScrollOffset int
}

ProcessState holds all process management data.

type RemoteHostMetrics added in v0.5.0

type RemoteHostMetrics struct {
	Uptime      string
	Cpu         float64
	CpuCount    int
	MemoryTotal uint64
	MemoryUsed  uint64
	MemoryPct   float64
	SwapTotal   uint64
	SwapUsed    uint64
	SwapPct     float64
	DiskTotal   uint64
	DiskUsed    uint64
	DiskPct     float64
	NetSent     uint64
	NetRecv     uint64
	Processes   []RemoteProcessInfo
	LoadAvg1    float64
	LoadAvg5    float64
	LoadAvg15   float64
	Error       string
	Online      bool
}

type RemoteProcessInfo added in v0.5.0

type RemoteProcessInfo struct {
	Pid    int32
	Name   string
	Cpu    float64
	Memory float64
	Status string
}

type RemoteState added in v0.5.0

type RemoteState struct {
	Metrics map[string]RemoteHostMetrics
}

RemoteState holds all remote monitoring state.

type RingBuffer

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

func NewRingBuffer

func NewRingBuffer(size int) *RingBuffer

func (*RingBuffer) Avg

func (r *RingBuffer) Avg() float64

func (*RingBuffer) Get

func (r *RingBuffer) Get(i int) float64

func (*RingBuffer) Len

func (r *RingBuffer) Len() int

func (*RingBuffer) Max

func (r *RingBuffer) Max() float64

func (*RingBuffer) Push

func (r *RingBuffer) Push(val float64)

func (*RingBuffer) Resize added in v0.6.0

func (r *RingBuffer) Resize(newSize int)

Resize creates a new buffer with the given size, preserving as much existing data as possible (newest data is kept).

type ServiceInfo

type ServiceInfo struct {
	Description string
	Name        string
	Status      string
}

type SimpleViewport

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

SimpleViewport wraps Bubbles viewport.Model to provide the same API

func NewSimpleViewport

func NewSimpleViewport(width, height int) SimpleViewport

func (*SimpleViewport) GotoBottom

func (v *SimpleViewport) GotoBottom()

func (*SimpleViewport) GotoTop

func (v *SimpleViewport) GotoTop()

func (*SimpleViewport) HalfViewDown

func (v *SimpleViewport) HalfViewDown()

func (*SimpleViewport) HalfViewUp

func (v *SimpleViewport) HalfViewUp()

func (*SimpleViewport) LineDown

func (v *SimpleViewport) LineDown(n int)

func (*SimpleViewport) LineUp

func (v *SimpleViewport) LineUp(n int)

func (*SimpleViewport) SetContent

func (v *SimpleViewport) SetContent(s string)

func (*SimpleViewport) SetHeight added in v0.5.0

func (v *SimpleViewport) SetHeight(h int)

func (*SimpleViewport) SetWidth added in v0.5.0

func (v *SimpleViewport) SetWidth(w int)

func (*SimpleViewport) View

func (v *SimpleViewport) View() string

type Toast

type Toast struct {
	StartTime time.Time
	Message   string
	Level     string
	Duration  time.Duration
	ID        int64
}

type UIState added in v0.5.0

type UIState struct {
	// Window dimensions
	Width  int
	Height int

	// Tab state
	SelectedTab   int
	ActiveTabs    []string
	HistoryLength int

	// Interactive flags
	Paused       bool
	ShowHelp     bool
	ShowSettings bool
	ShowSamLab   bool

	// Settings dialog
	SettingsEdit bool
	SettingsSel  config.MetricType
	SettingsIdx  int

	// Kill dialog
	ShowKillDialog bool
	KillDialogSel  int

	// Toasts
	Toasts      []Toast
	NextToastID int64

	// Error handling
	LastError     string
	LastErrorTime time.Time
	TickCount     uint64

	// Chart display
	ChartType string

	// Scroll offsets for blocks
	CpuCoreScrollOffset      int
	SystemBlockScrollOffsets map[int]int
	ActiveScrollBlock        int
	SystemBlockCount         int
	SystemBlockScrollable    map[int]bool
	SystemBlockMaxScroll     map[int]int

	// Mouse position
	MouseX int
	MouseY int

	// Input zones
	Zones       []input.Zone
	ZoneManager interface{} // *input.ZoneManager - stored as interface to avoid circular import

	// Content rendering
	ContentBuilder strings.Builder

	// Config timestamps
	StartTime         time.Time
	LastConfigModTime time.Time
}

UIState holds all UI and display-related state.

type VmInfo added in v0.5.0

type VmInfo struct {
	Hypervisor     string
	Type           string
	HostName       string
	VirtMemory     uint64
	VirtMemoryUsed uint64
	VirtCPU        int
	VirtCPUUsed    int
}

VmInfo represents VM/hypervisor information

Jump to

Keyboard shortcuts

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