From 842a8163852611bc2b840bad25d1deddb68df34d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 24 Jan 2023 20:44:25 +0530 Subject: [PATCH] use humanize.IBytes instead of humanize.Bytes (#4455) --- cmd/admin-heal.go | 6 +++--- cmd/admin-rebalance-status.go | 2 +- pkg/probe/probe.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/admin-heal.go b/cmd/admin-heal.go index 7aa7a164..1e09785d 100644 --- a/cmd/admin-heal.go +++ b/cmd/admin-heal.go @@ -572,17 +572,17 @@ func (s shortBackgroundHealStatusMessage) String() string { healPrettyMsg += fmt.Sprintf("Objects Healed: %s/%s (%s), %s/%s (%s)\n", humanize.Comma(int64(itemsHealed)), humanize.Comma(int64(totalItems)), humanize.CommafWithDigits(itemsPct, 1)+"%%", - humanize.Bytes(bytesHealed), humanize.Bytes(totalBytes), humanize.CommafWithDigits(bytesPct, 1)+"%%") + humanize.IBytes(bytesHealed), humanize.IBytes(totalBytes), humanize.CommafWithDigits(bytesPct, 1)+"%%") if itemsFailed > 0 { itemsPct := math.Min(100, 100*float64(itemsFailed)/float64(totalItems)) bytesPct := math.Min(100, 100*float64(bytesFailed)/float64(totalBytes)) healPrettyMsg += fmt.Sprintf("Objects Failed: %s/%s (%s), %s/%s (%s)\n", humanize.Comma(int64(itemsFailed)), humanize.Comma(int64(totalItems)), humanize.CommafWithDigits(itemsPct, 1)+"%%", - humanize.Bytes(bytesFailed), humanize.Bytes(totalBytes), humanize.CommafWithDigits(bytesPct, 1)+"%%") + humanize.IBytes(bytesFailed), humanize.IBytes(totalBytes), humanize.CommafWithDigits(bytesPct, 1)+"%%") } } else { - healPrettyMsg += fmt.Sprintf("Objects Healed: %s, %s\n", humanize.Comma(int64(itemsHealed)), humanize.Bytes(bytesHealed)) + healPrettyMsg += fmt.Sprintf("Objects Healed: %s, %s\n", humanize.Comma(int64(itemsHealed)), humanize.IBytes(bytesHealed)) } if accumulatedElapsedTime > 0 { diff --git a/cmd/admin-rebalance-status.go b/cmd/admin-rebalance-status.go index 0f245da9..338ceac2 100644 --- a/cmd/admin-rebalance-status.go +++ b/cmd/admin-rebalance-status.go @@ -119,7 +119,7 @@ func mainAdminRebalanceStatus(ctx *cli.Context) error { var b strings.Builder fmt.Fprintf(&b, "Summary: \n") - fmt.Fprintf(&b, "Data: %s (%d objects, %d versions) \n", humanize.Bytes(totalBytes), totalObjects, totalVersions) + fmt.Fprintf(&b, "Data: %s (%d objects, %d versions) \n", humanize.IBytes(totalBytes), totalObjects, totalVersions) fmt.Fprintf(&b, "Time: %s (%s to completion)", maxElapsed, maxETA) console.Println(b.String()) return nil diff --git a/pkg/probe/probe.go b/pkg/probe/probe.go index e7dcf4d1..6e605ab6 100644 --- a/pkg/probe/probe.go +++ b/pkg/probe/probe.go @@ -73,10 +73,10 @@ func GetSysInfo() map[string]string { "host.arch": runtime.GOARCH, "host.lang": runtime.Version(), "host.cpus": strconv.Itoa(runtime.NumCPU()), - "mem.used": humanize.Bytes(memstats.Alloc), - "mem.total": humanize.Bytes(memstats.Sys), - "mem.heap.used": humanize.Bytes(memstats.HeapAlloc), - "mem.heap.total": humanize.Bytes(memstats.HeapSys), + "mem.used": humanize.IBytes(memstats.Alloc), + "mem.total": humanize.IBytes(memstats.Sys), + "mem.heap.used": humanize.IBytes(memstats.HeapAlloc), + "mem.heap.total": humanize.IBytes(memstats.HeapSys), } }