Documentation
¶
Overview ¶
Package proc provides utilities for reading process statistics from /proc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetProcessStartTime ¶
GetProcessStartTime returns when a process started based on /proc/[pid]/stat.
func ReadAllStats ¶
func ReadAllStats(pids []int, tracker *CPUTracker) (map[int]*Stats, error)
ReadAllStats reads statistics for multiple PIDs.
Types ¶
type CPUTracker ¶
type CPUTracker struct {
// contains filtered or unexported fields
}
CPUTracker tracks CPU usage across multiple samples.
func NewCPUTracker ¶
func NewCPUTracker() *CPUTracker
NewCPUTracker creates a new CPU usage tracker.
func (*CPUTracker) CleanupStale ¶
func (t *CPUTracker) CleanupStale(activePIDs []int)
CleanupStale removes snapshots for PIDs no longer in the provided list.
type Stats ¶
type Stats struct {
PID int `json:"pid"`
CPUPercent float64 `json:"cpu_percent"` // CPU usage as percentage (0-100+)
MemoryMB int64 `json:"memory_mb"` // Resident memory in megabytes
MemoryRSS int64 `json:"memory_rss"` // Resident set size in bytes
VirtualMB int64 `json:"virtual_mb"` // Virtual memory in megabytes
State string `json:"state"` // Process state (R, S, D, Z, T, etc.)
Threads int `json:"threads"` // Number of threads
StartTime int64 `json:"start_time"` // Process start time in jiffies since boot
}
Stats contains process statistics read from /proc.
Click to show internal directories.
Click to hide internal directories.