mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Add host memory and CPU usage metrics
This commit is contained in:
@@ -346,7 +346,9 @@ func processOriginTable(nmd report.Node, addHostTag bool, addContainerTag bool)
|
||||
}, len(rows) > 0 || commFound || pidFound
|
||||
}
|
||||
|
||||
func sparklineRow(human string, metric report.Metric, format func(report.Metric) (report.Metric, string)) Row {
|
||||
type formatter func(report.Metric) (report.Metric, string)
|
||||
|
||||
func sparklineRow(human string, metric report.Metric, format formatter) Row {
|
||||
if format == nil {
|
||||
format = formatDefault
|
||||
}
|
||||
@@ -520,6 +522,17 @@ func hostOriginTable(nmd report.Node) (Table, bool) {
|
||||
rows = append(rows, sparklineRow(tuple.human, val, nil))
|
||||
}
|
||||
}
|
||||
for _, tuple := range []struct {
|
||||
key, human string
|
||||
fmt formatter
|
||||
}{
|
||||
{host.CPUUsage, "CPU Usage", formatPercent},
|
||||
{host.MemUsage, "Memory Usage", formatPercent},
|
||||
} {
|
||||
if val, ok := nmd.Metrics[tuple.key]; ok {
|
||||
rows = append(rows, sparklineRow(tuple.human, val, tuple.fmt))
|
||||
}
|
||||
}
|
||||
for _, tuple := range []struct{ key, human string }{
|
||||
{host.OS, "Operating system"},
|
||||
{host.KernelVersion, "Kernel version"},
|
||||
|
||||
Reference in New Issue
Block a user