Documentation
¶
Overview ¶
Package hoststats turns raw host readings into a stats.Sample.
Index ¶
Constants ¶
const Item = "host"
Item is the stats item id of the host.
Variables ¶
This section is empty.
Functions ¶
func DirForDBPath ¶ added in v0.4.90
DirForDBPath returns the host-stats store directory under dbPath.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector keeps the previous Reading to compute rates. Not safe for concurrent use.
type Config ¶
type Config struct {
Dir string // /var/lib/casaos/stats/core
Source Source
Clock stats.Clock
Publish func(name string, properties map[string]string) // the bus; errors logged by the caller
Hub func(name string, properties map[string]string) // alerts.Default.Handle
Name func() string // the machine's display name, "" -> "Machine"
Boot func() time.Time // boot time, zero = unknown
}
type DiskCounters ¶
type DiskCounters struct{ ReadBytes, WriteBytes, ReadOps, WriteOps uint64 }
type NetCounters ¶
type NetCounters struct{ RxBytes, TxBytes, Dropped uint64 }
type Service ¶
type Service struct {
Store *stats.Store
Eval *stats.Evaluator
// contains filtered or unexported fields
}
Service samples the host every 5 s into Store; Eval judges its minutes.
var Default *Service
Default is the running service, nil until it started.
func New ¶
New opens the store and the evaluator in cfg.Dir, wires the evaluator to the store's minutes and rebuilds the host's alert counts from its history.
func (*Service) Close ¶
Close waits for a tick in flight, closes the store, then publishes what is queued (at most about 5 s); later calls return nil.
type SystemSource ¶
type SystemSource struct {
Now func() time.Time // nil: time.Now
Interfaces func() []string // the same filter as /v1/sys/utilization
Volumes func(ctx context.Context) ([]Volume, error) // nil: none
IsPhysical func(name string) bool // /sys/block/<name>/device exists; nil: every block device
ListEvery time.Duration
// contains filtered or unexported fields
}
SystemSource reads this machine. The interface list comes from a shell script, the whole-disk list from /sys and the volumes from LocalStorage: all three are kept ListEvery (1 min when zero), never read per tick, and never awaited longer than refreshWait. Read is called by one goroutine at a time.