blob: 0de7cf9ab8439160e854c479857af462d6f2d0bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package linuxstatus
import (
"fmt"
"time"
"errors"
"go.wit.com/log"
)
func (ls *LinuxStatus) Update() {
if ! ls.Ready() {
log.Warn("can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet"))
return
}
log.Log(INFO, "Update() START")
duration := timeFunction(func () {
linuxLoop()
})
ls.SetSpeed(duration)
log.Info("linuxStatus() Update() END")
}
func (ls *LinuxStatus) SetSpeed(duration time.Duration) {
s := fmt.Sprint(duration)
if ls.speedActual == nil {
log.Warn("can't actually warn")
return
}
ls.speedActual.Set(s)
if (duration > 500 * time.Millisecond ) {
ls.speed.Set("SLOW")
} else if (duration > 100 * time.Millisecond ) {
ls.speed.Set("OK")
} else {
ls.speed.Set("FAST")
}
}
|