mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 10:11:03 +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)
22 lines
474 B
Go
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])
|
|
}
|