package lib import ( "fmt" "log" "time" "github.com/shirou/gopsutil/load" ) // UpdateLaStats вытаскивает показание LA за последнюю минуту. func (c *MyConfig) UpdateLaStats() { var ( InitialDelay = 100 * time.Millisecond LoopIterationDelay = 3 * time.Second Delay = InitialDelay ticker = time.NewTicker(Delay) ) for range ticker.C { if Delay == InitialDelay { Delay = LoopIterationDelay ticker.Reset(Delay) } l, err := load.Avg() if err != nil { log.Printf("Unable to get LA stats: %s", err) continue } lav := fmt.Sprintf("%.2f", l.Load1) if c.Values.La != lav { c.Values.La = lav c.Channels.UpdateReady <- true } } } /* vim: set ft=go noet ai ts=4 sw=4 sts=4: */