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)
This commit is contained in:
Peter Bourgon
2015-06-09 15:38:08 +02:00
parent 1e0b83eb6d
commit d438261742
20 changed files with 180 additions and 365 deletions
+8 -7
View File
@@ -1,31 +1,32 @@
package main
import (
"fmt"
"io/ioutil"
"strconv"
"strings"
)
func getLoads() (float64, float64, float64) {
func getLoad() string {
buf, err := ioutil.ReadFile("/proc/loadavg")
if err != nil {
return -1, -1, -1
return "unknown"
}
toks := strings.Fields(string(buf))
if len(toks) < 3 {
return -1, -1, -1
return "unknown"
}
one, err := strconv.ParseFloat(toks[0], 64)
if err != nil {
return -1, -1, -1
return "unknown"
}
five, err := strconv.ParseFloat(toks[1], 64)
if err != nil {
return -1, -1, -1
return "unknown"
}
fifteen, err := strconv.ParseFloat(toks[2], 64)
if err != nil {
return -1, -1, -1
return "unknown"
}
return one, five, fifteen
return fmt.Sprintf("%.2f %.2f %.2f", one, five, fifteen)
}