mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
- All HostMetadata information becomes NodeMetadata
- Significant change to mechanics, but same net effect
- LocalNets becomes "local_networks", space-separated list of CIDRs
- Load becomes simple single string
- Use MakeHostNodeID for indexing into Host topology
- (That changes the app /origin/{id} handler; will be removed later)
33 lines
573 B
Go
33 lines
573 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func getLoad() string {
|
|
buf, err := ioutil.ReadFile("/proc/loadavg")
|
|
if err != nil {
|
|
return "unknown"
|
|
}
|
|
toks := strings.Fields(string(buf))
|
|
if len(toks) < 3 {
|
|
return "unknown"
|
|
}
|
|
one, err := strconv.ParseFloat(toks[0], 64)
|
|
if err != nil {
|
|
return "unknown"
|
|
}
|
|
five, err := strconv.ParseFloat(toks[1], 64)
|
|
if err != nil {
|
|
return "unknown"
|
|
}
|
|
fifteen, err := strconv.ParseFloat(toks[2], 64)
|
|
if err != nil {
|
|
return "unknown"
|
|
}
|
|
return fmt.Sprintf("%.2f %.2f %.2f", one, five, fifteen)
|
|
}
|