stats

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

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

Collector manages the collection and storage of statistical data

func InitStatsCollector

func InitStatsCollector() *Collector

func (*Collector) Collect

func (sc *Collector) Collect(interval time.Duration)

Collect starts collecting statistical data

func (*Collector) GetStats

func (sc *Collector) GetStats() []Stats

GetStats returns all the collected statistical data

type NetStats

type NetStats struct {
	LastSent uint64
	LastRecv uint64
	LastTime time.Time
}

type Stats

type Stats struct {
	Timestamp    time.Time  `json:"timestamp"`
	SvrCPUUsage  float64    `json:"svrCPUUsage"`  // Overall CPU usage rate
	SvrMemoryPct float64    `json:"svrMemoryPct"` // Total memory
	LoadAverage  [2]float64 `json:"loadAverage"`  // 1, 5 minutes average load

	CPUUsage       float64 `json:"CPUUsage"`            // Current process's CPU usage rate
	MemoryUsage    float64 `json:"memoryUsage"`         // Current process's memory usage
	MemoryUsagePct float64 `json.json:"memoryUsagePct"` // Current process's memory usage percentage
	ThreadCount    int     `json:"threadCount"`         // Current process's thread count
	Goroutines     int     `json:"goroutines"`          // Number of Go coroutines
	HeapAlloc      float64 `json:"heapAlloc"`           // Memory allocated in the heap currently
	HeapSys        float64 `json:"heapSys"`             // Total heap memory obtained from the system
	HeapInuse      float64 `json:"heapInuse"`           // Heap memory in use
	HeapPct        float64 `json:"heapPct"`             // Percentage of heap memory obtained from the system

	LoginCount  int `json:"loginCount"`      // Online users
	GuestCount  int `json.json:"guestCount"` // Visitors
	Connections int `json:"connections"`     // Current process's network connections

	SentRate float64 `json:"sentRate"` // Sending rate KB/s
	RecvRate float64 `json:"recvRate"` // Receiving rate KB/s

	MaxMemoryUsage float64 `json:"maxMemoryUsage"` // Maximum memory
	MaxGoroutines  int     `json:"maxGoroutines"`  // Maximum coroutines
}

Stats contains statistical data on CPU and memory usage

Jump to

Keyboard shortcuts

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