Add host memory and CPU usage metrics

This commit is contained in:
Tom Wilkie
2015-12-01 09:44:13 +00:00
parent 3262fa7a5e
commit 4a475466f6
52 changed files with 3910 additions and 27 deletions

View File

@@ -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"},