Files
weave-scope/probe/system_darwin.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

22 lines
474 B
Go

package main
import (
"fmt"
"os/exec"
"regexp"
)
var loadRe = regexp.MustCompile(`load average\: ([0-9\.]+), ([0-9\.]+), ([0-9\.]+)`)
func getLoad() string {
out, err := exec.Command("w").CombinedOutput()
if err != nil {
return "unknown"
}
matches := loadRe.FindAllStringSubmatch(string(out), -1)
if matches == nil || len(matches) < 1 || len(matches[0]) < 4 {
return "unknown"
}
return fmt.Sprintf("%s %s %s", matches[0][1], matches[0][2], matches[0][3])
}