93e8fc53f9
Sample output with a mock device: ``` Host Resource Utilization CPU Memory Disk 2651/26400 MHz 9.6 GiB/16 GiB 98 GiB/234 GiB Device Resource Utilization nomad/file/mock[README.md] 511 bytes nomad/file/mock[e2e.go] 239 bytes nomad/file/mock[e2e_test.go] 128 bytes Allocations No allocations placed ```
31 lines
545 B
Go
31 lines
545 B
Go
package command
|
|
|
|
import (
|
|
"github.com/hashicorp/nomad/api"
|
|
)
|
|
|
|
func deviceQualifiedID(vendor, typ, name, id string) string {
|
|
p := vendor
|
|
if typ != "" {
|
|
p += "/" + typ
|
|
}
|
|
if name != "" {
|
|
p += "/" + name
|
|
}
|
|
|
|
return p + "[" + id + "]"
|
|
}
|
|
|
|
func buildDeviceStatsSummaryMap(host *api.HostStats) map[string]*api.StatValue {
|
|
r := map[string]*api.StatValue{}
|
|
|
|
for _, dg := range host.DeviceStats {
|
|
for id, stats := range dg.InstanceStats {
|
|
k := deviceQualifiedID(dg.Vendor, dg.Type, dg.Name, id)
|
|
r[k] = stats.Summary
|
|
}
|
|
}
|
|
|
|
return r
|
|
}
|