Documentation
¶
Overview ¶
Package system provides method to collect metrics of machines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BandwidthStat ¶
type Collector ¶
type Collector struct {
// CollectInterval represents the interval in-between each set of stats output.
// Defaults to 10 seconds.
CollectInterval time.Duration
// Done, when closed, is used to signal Collector that is should stop collecting
// statistics and the Run function should return.
Done <-chan struct{}
// contains filtered or unexported fields
}
Collector implements the periodic grabbing of informational data of go runtime to a SystemStatsHandler.
func New ¶
func New(statsHandler SystemStatsHandler) *Collector
New creates a new Collector that will periodically output statistics to statsHandler. It will also set the values of the exported stats to the described defaults. The values of the exported defaults can be changed at any point before Run is called.
func (*Collector) Once ¶
func (c *Collector) Once() SystemStats
Once returns a map containing all statistics. It is safe for use from multiple go routines。
type SystemStats ¶
type SystemStats struct {
CPUStat struct {
User float64
System float64
Idle float64
Iowait float64
}
LoadStat struct {
Load1 float64
Load5 float64
Load15 float64
}
MemStat struct {
Total uint64
Available uint64
Used uint64
}
SwapMemStat struct {
Total uint64
Free uint64
Used uint64
}
DiskStat map[string]DiskStat
BandwidthStat map[string]BandwidthStat
}
func (*SystemStats) Values ¶
func (ss *SystemStats) Values() map[string]interface{}
Values returns metrics which you can write into TSDB.
type SystemStatsHandler ¶
type SystemStatsHandler func(SystemStats)
SystemStatsHandler represents a handler to handle stats after successfully gathering statistics