Files
weave-scope/probe/system_linux.go
Peter Bourgon d438261742 HostMetadata becomes Host Topology
- 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)
2015-06-09 15:38:08 +02:00

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)
}