Skip to content

Commit

Permalink
node-status outputs volumename instead of 0B utilization with non-phy…
Browse files Browse the repository at this point in the history
…sical volume
  • Loading branch information
nak3 committed Aug 8, 2016
1 parent 044e067 commit 5cbe16b
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,22 +480,36 @@ func getHostResources(hostStats *api.HostStats, node *api.Node) ([]string, error
// calculate disk usage
storageDevice := node.Attributes["unique.storage.volume"]
var diskUsed, diskSize uint64
var physical bool
for _, disk := range hostStats.DiskStats {
if disk.Device == storageDevice {
diskUsed = disk.Used
diskSize = disk.Size
physical = true
}
}

resources = make([]string, 2)
resources[0] = "CPU|Memory|Disk"
resources[1] = fmt.Sprintf("%v/%v MHz|%v/%v|%v/%v",
math.Floor(hostStats.CPUTicksConsumed),
node.Resources.CPU,
humanize.IBytes(hostStats.Memory.Used),
humanize.IBytes(hostStats.Memory.Total),
humanize.IBytes(diskUsed),
humanize.IBytes(diskSize),
)
if physical {
resources[1] = fmt.Sprintf("%v/%v MHz|%v/%v|%v/%v",
math.Floor(hostStats.CPUTicksConsumed),
node.Resources.CPU,
humanize.IBytes(hostStats.Memory.Used),
humanize.IBytes(hostStats.Memory.Total),
humanize.IBytes(diskUsed),
humanize.IBytes(diskSize),
)
} else {
// If non-physical device are used, output device name only,
// since nomad doesn't collect the stats data.
resources[1] = fmt.Sprintf("%v/%v MHz|%v/%v|(%s)",
math.Floor(hostStats.CPUTicksConsumed),
node.Resources.CPU,
humanize.IBytes(hostStats.Memory.Used),
humanize.IBytes(hostStats.Memory.Total),
storageDevice,
)
}
return resources, nil
}

0 comments on commit 5cbe16b

Please sign in to comment.