Documentation
¶
Index ¶
- func FormatBytes(bytes uint64) string
- func FormatPercent(percent float64) string
- type CPUStats
- type Collector
- func (c *Collector) CheckAlerts() []ResourceAlert
- func (c *Collector) ClearHistory()
- func (c *Collector) GetAverages(duration time.Duration) *SystemStats
- func (c *Collector) GetCurrent() (*SystemStats, error)
- func (c *Collector) GetHistory() []SystemStats
- func (c *Collector) GetHistorySince(since time.Time) []SystemStats
- func (c *Collector) SetInterval(interval time.Duration)
- func (c *Collector) Start()
- func (c *Collector) Stop()
- type ContainerStats
- type DiskStats
- type LoadStats
- type MemoryStats
- type Monitor
- type NetworkStats
- type ProcessInfo
- type ProcessStats
- type ResourceAlert
- type SystemStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
FormatBytes formats bytes into human-readable string
func FormatPercent ¶
FormatPercent formats a percentage value
Types ¶
type CPUStats ¶
type CPUStats struct {
UsagePercent float64 `json:"usage_percent"`
Cores int `json:"cores"`
UserPercent float64 `json:"user_percent"`
SystemPercent float64 `json:"system_percent"`
IdlePercent float64 `json:"idle_percent"`
}
CPUStats represents CPU usage information
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector manages resource collection and history
func NewCollector ¶
NewCollector creates a new resource collector
func (*Collector) CheckAlerts ¶
func (c *Collector) CheckAlerts() []ResourceAlert
CheckAlerts checks for resource usage alerts
func (*Collector) ClearHistory ¶
func (c *Collector) ClearHistory()
ClearHistory clears the collected statistics history
func (*Collector) GetAverages ¶
func (c *Collector) GetAverages(duration time.Duration) *SystemStats
GetAverages calculates average statistics over a time period
func (*Collector) GetCurrent ¶
func (c *Collector) GetCurrent() (*SystemStats, error)
GetCurrent returns the most recent system statistics
func (*Collector) GetHistory ¶
func (c *Collector) GetHistory() []SystemStats
GetHistory returns the collected statistics history
func (*Collector) GetHistorySince ¶
func (c *Collector) GetHistorySince(since time.Time) []SystemStats
GetHistorySince returns statistics collected since the given time
func (*Collector) SetInterval ¶
SetInterval updates the collection interval
type ContainerStats ¶
type ContainerStats struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
CPUPercent float64 `json:"cpu_percent"`
MemUsage uint64 `json:"mem_usage"`
MemLimit uint64 `json:"mem_limit"`
MemPercent float64 `json:"mem_percent"`
NetIO string `json:"net_io"`
BlockIO string `json:"block_io"`
}
ContainerStats represents Docker container statistics
type DiskStats ¶
type DiskStats struct {
Total uint64 `json:"total"`
Used uint64 `json:"used"`
Free uint64 `json:"free"`
UsedPercent float64 `json:"used_percent"`
Mountpoint string `json:"mountpoint"`
}
DiskStats represents disk usage information
type LoadStats ¶
type LoadStats struct {
Load1 float64 `json:"load_1"`
Load5 float64 `json:"load_5"`
Load15 float64 `json:"load_15"`
}
LoadStats represents system load averages
type MemoryStats ¶
type MemoryStats struct {
Total uint64 `json:"total"`
Used uint64 `json:"used"`
Free uint64 `json:"free"`
Available uint64 `json:"available"`
UsedPercent float64 `json:"used_percent"`
Cached uint64 `json:"cached"`
Buffers uint64 `json:"buffers"`
SwapTotal uint64 `json:"swap_total"`
SwapUsed uint64 `json:"swap_used"`
SwapFree uint64 `json:"swap_free"`
}
MemoryStats represents memory usage information
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor provides system monitoring capabilities
func NewMonitor ¶
NewMonitor creates a new system monitor
func (*Monitor) GetSystemStats ¶
func (m *Monitor) GetSystemStats() (*SystemStats, error)
GetSystemStats retrieves current system statistics
func (*Monitor) GetTopProcesses ¶
func (m *Monitor) GetTopProcesses(count int, sortBy string) ([]ProcessInfo, error)
GetTopProcesses returns the top N processes by CPU or memory usage
func (*Monitor) StreamStats ¶
StreamStats continuously monitors and sends system statistics
type NetworkStats ¶
type NetworkStats struct {
BytesRecv uint64 `json:"bytes_recv"`
BytesSent uint64 `json:"bytes_sent"`
PacketsRecv uint64 `json:"packets_recv"`
PacketsSent uint64 `json:"packets_sent"`
}
NetworkStats represents network statistics
type ProcessInfo ¶
type ProcessInfo struct {
PID int `json:"pid"`
Name string `json:"name"`
User string `json:"user"`
CPUPercent float64 `json:"cpu_percent"`
MemoryKB uint64 `json:"memory_kb"`
State string `json:"state"`
Command string `json:"command"`
}
ProcessInfo represents information about a single process
type ProcessStats ¶
type ProcessStats struct {
Total int `json:"total"`
Running int `json:"running"`
Sleeping int `json:"sleeping"`
Stopped int `json:"stopped"`
Zombie int `json:"zombie"`
}
ProcessStats represents process information
type ResourceAlert ¶
type ResourceAlert struct {
Type string `json:"type"`
Severity string `json:"severity"`
Message string `json:"message"`
Value float64 `json:"value"`
Threshold float64 `json:"threshold"`
Timestamp time.Time `json:"timestamp"`
}
ResourceAlert represents a resource usage alert
type SystemStats ¶
type SystemStats struct {
Timestamp time.Time `json:"timestamp"`
CPU CPUStats `json:"cpu"`
Memory MemoryStats `json:"memory"`
Disk DiskStats `json:"disk"`
LoadAverage LoadStats `json:"load_average"`
Processes ProcessStats `json:"processes"`
Network NetworkStats `json:"network"`
Containers []ContainerStats `json:"containers,omitempty"`
}
SystemStats represents system resource usage