diff --git a/command/alloc_status.go b/command/alloc_status.go index 9920867b1..0c4d76af6 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -288,19 +288,19 @@ func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task str // Display the rolled up stats. If possible prefer the live stastics cpuUsage := strconv.Itoa(resource.CPU) - memUsage := strconv.Itoa(resource.MemoryMB) + memUsage := humanize.IBytes(uint64(resource.MemoryMB * bytesPerMegabyte)) if ru, ok := stats.Tasks[task]; ok && ru != nil && ru.ResourceUsage != nil { if cs := ru.ResourceUsage.CpuStats; cs != nil { cpuUsage = fmt.Sprintf("%v/%v", math.Floor(cs.TotalTicks), resource.CPU) } if ms := ru.ResourceUsage.MemoryStats; ms != nil { - memUsage = fmt.Sprintf("%v/%v", humanize.Bytes(ms.RSS), resource.MemoryMB) + memUsage = fmt.Sprintf("%v/%v", humanize.IBytes(ms.RSS), memUsage) } } - resourcesOutput = append(resourcesOutput, fmt.Sprintf("%v|%v MB|%v MB|%v|%v", + resourcesOutput = append(resourcesOutput, fmt.Sprintf("%v|%v|%v|%v|%v", cpuUsage, memUsage, - resource.DiskMB, + humanize.IBytes(uint64(resource.DiskMB*bytesPerMegabyte)), resource.IOPS, firstAddr)) for i := 1; i < len(addr); i++ { @@ -329,17 +329,17 @@ func (c *AllocStatusCommand) outputVerboseResourceUsage(task string, resourceUsa for _, measured := range memoryStats.Measured { switch measured { case "RSS": - measuredStats = append(measuredStats, humanize.Bytes(memoryStats.RSS)) + measuredStats = append(measuredStats, humanize.IBytes(memoryStats.RSS)) case "Cache": - measuredStats = append(measuredStats, humanize.Bytes(memoryStats.Cache)) + measuredStats = append(measuredStats, humanize.IBytes(memoryStats.Cache)) case "Swap": - measuredStats = append(measuredStats, humanize.Bytes(memoryStats.Swap)) + measuredStats = append(measuredStats, humanize.IBytes(memoryStats.Swap)) case "Max Usage": - measuredStats = append(measuredStats, humanize.Bytes(memoryStats.MaxUsage)) + measuredStats = append(measuredStats, humanize.IBytes(memoryStats.MaxUsage)) case "Kernel Usage": - measuredStats = append(measuredStats, humanize.Bytes(memoryStats.KernelUsage)) + measuredStats = append(measuredStats, humanize.IBytes(memoryStats.KernelUsage)) case "Kernel Max Usage": - measuredStats = append(measuredStats, humanize.Bytes(memoryStats.KernelMaxUsage)) + measuredStats = append(measuredStats, humanize.IBytes(memoryStats.KernelMaxUsage)) } } diff --git a/command/fs.go b/command/fs.go index 9d73e7310..0af8cdbdd 100644 --- a/command/fs.go +++ b/command/fs.go @@ -173,7 +173,7 @@ nomad alloc-status %s`, allocID, allocID) if machine { size = fmt.Sprintf("%d", file.Size) } else { - size = humanize.Bytes(uint64(file.Size)) + size = humanize.IBytes(uint64(file.Size)) } out[1] = fmt.Sprintf("%s|%s|%s|%s", file.FileMode, size, formatTime(file.ModTime), fn) @@ -202,7 +202,7 @@ nomad alloc-status %s`, allocID, allocID) if machine { size = fmt.Sprintf("%d", file.Size) } else { - size = humanize.Bytes(uint64(file.Size)) + size = humanize.IBytes(uint64(file.Size)) } out[i+1] = fmt.Sprintf("%s|%s|%s|%s", file.FileMode, diff --git a/command/node_status.go b/command/node_status.go index 203fe20c6..464ba42e5 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -330,10 +330,10 @@ func (c *NodeStatusCommand) printCpuStats(hostStats *api.HostStats) { func (c *NodeStatusCommand) printMemoryStats(hostStats *api.HostStats) { memoryStat := hostStats.Memory memStatsAttr := make([]string, 4) - memStatsAttr[0] = fmt.Sprintf("Total|%v", humanize.Bytes(memoryStat.Total)) - memStatsAttr[1] = fmt.Sprintf("Available|%v", humanize.Bytes(memoryStat.Available)) - memStatsAttr[2] = fmt.Sprintf("Used|%v", humanize.Bytes(memoryStat.Used)) - memStatsAttr[3] = fmt.Sprintf("Free|%v", humanize.Bytes(memoryStat.Free)) + memStatsAttr[0] = fmt.Sprintf("Total|%v", humanize.IBytes(memoryStat.Total)) + memStatsAttr[1] = fmt.Sprintf("Available|%v", humanize.IBytes(memoryStat.Available)) + memStatsAttr[2] = fmt.Sprintf("Used|%v", humanize.IBytes(memoryStat.Used)) + memStatsAttr[3] = fmt.Sprintf("Free|%v", humanize.IBytes(memoryStat.Free)) c.Ui.Output(formatKV(memStatsAttr)) } @@ -343,9 +343,9 @@ func (c *NodeStatusCommand) printDiskStats(hostStats *api.HostStats) { diskStatsAttr := make([]string, 7) diskStatsAttr[0] = fmt.Sprintf("Device|%s", diskStat.Device) diskStatsAttr[1] = fmt.Sprintf("MountPoint|%s", diskStat.Mountpoint) - diskStatsAttr[2] = fmt.Sprintf("Size|%s", humanize.Bytes(diskStat.Size)) - diskStatsAttr[3] = fmt.Sprintf("Used|%s", humanize.Bytes(diskStat.Used)) - diskStatsAttr[4] = fmt.Sprintf("Available|%s", humanize.Bytes(diskStat.Available)) + diskStatsAttr[2] = fmt.Sprintf("Size|%s", humanize.IBytes(diskStat.Size)) + diskStatsAttr[3] = fmt.Sprintf("Used|%s", humanize.IBytes(diskStat.Used)) + diskStatsAttr[4] = fmt.Sprintf("Available|%s", humanize.IBytes(diskStat.Available)) diskStatsAttr[5] = fmt.Sprintf("Used Percent|%v%%", humanize.FormatFloat(floatFormat, diskStat.UsedPercent)) diskStatsAttr[6] = fmt.Sprintf("Inodes Percent|%v%%", humanize.FormatFloat(floatFormat, diskStat.InodesUsedPercent)) c.Ui.Output(formatKV(diskStatsAttr)) @@ -409,10 +409,10 @@ func getAllocatedResources(client *api.Client, runningAllocs []*api.Allocation, resources[1] = fmt.Sprintf("%v/%v|%v/%v|%v/%v|%v/%v", cpu, total.CPU, - humanize.Bytes(uint64(mem*bytesPerMegabyte)), - humanize.Bytes(uint64(total.MemoryMB*bytesPerMegabyte)), - humanize.Bytes(uint64(disk*bytesPerMegabyte)), - humanize.Bytes(uint64(total.DiskMB*bytesPerMegabyte)), + humanize.IBytes(uint64(mem*bytesPerMegabyte)), + humanize.IBytes(uint64(total.MemoryMB*bytesPerMegabyte)), + humanize.IBytes(uint64(disk*bytesPerMegabyte)), + humanize.IBytes(uint64(total.DiskMB*bytesPerMegabyte)), iops, total.IOPS) @@ -460,8 +460,8 @@ func getActualResources(client *api.Client, runningAllocs []*api.Allocation, nod resources[1] = fmt.Sprintf("%v/%v|%v/%v", math.Floor(cpu), total.CPU, - humanize.Bytes(mem), - humanize.Bytes(uint64(total.MemoryMB*bytesPerMegabyte))) + humanize.IBytes(mem), + humanize.IBytes(uint64(total.MemoryMB*bytesPerMegabyte))) return resources, nil } @@ -488,10 +488,10 @@ func getHostResources(hostStats *api.HostStats, node *api.Node) ([]string, error resources[1] = fmt.Sprintf("%v/%v|%v/%v|%v/%v", math.Floor(hostStats.CPUTicksConsumed), node.Resources.CPU, - humanize.Bytes(hostStats.Memory.Used), - humanize.Bytes(hostStats.Memory.Total), - humanize.Bytes(diskUsed), - humanize.Bytes(diskSize), + humanize.IBytes(hostStats.Memory.Used), + humanize.IBytes(hostStats.Memory.Total), + humanize.IBytes(diskUsed), + humanize.IBytes(diskSize), ) return resources, nil }