From fda6d7f8f9debe4c9b2a3eb135fbece011844fca Mon Sep 17 00:00:00 2001 From: helen Date: Wed, 8 Feb 2023 15:08:55 +0800 Subject: [PATCH] crictl stats add name row Signed-off-by: helen --- cmd/crictl/container_stats.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/crictl/container_stats.go b/cmd/crictl/container_stats.go index 58f2db206f..81f93fd7b0 100644 --- a/cmd/crictl/container_stats.go +++ b/cmd/crictl/container_stats.go @@ -217,12 +217,13 @@ func displayStats(ctx context.Context, client internalapi.RuntimeService, reques return err } - display.AddRow([]string{columnContainer, columnCPU, columnMemory, columnDisk, columnInodes}) + display.AddRow([]string{columnContainer, columnName, columnCPU, columnMemory, columnDisk, columnInodes}) for _, s := range r.GetStats() { if ctx.Err() != nil { return ctx.Err() } id := getTruncatedID(s.Attributes.Id, "") + name := s.GetAttributes().GetMetadata().GetName() cpu := s.GetCpu().GetUsageCoreNanoSeconds().GetValue() mem := s.GetMemory().GetWorkingSetBytes().GetValue() disk := s.GetWritableLayer().GetUsedBytes().GetValue() @@ -245,7 +246,7 @@ func displayStats(ctx context.Context, client internalapi.RuntimeService, reques } cpuPerc = float64(cpu-old.GetCpu().GetUsageCoreNanoSeconds().GetValue()) / float64(duration) * 100 } - display.AddRow([]string{id, fmt.Sprintf("%.2f", cpuPerc), units.HumanSize(float64(mem)), + display.AddRow([]string{id, name, fmt.Sprintf("%.2f", cpuPerc), units.HumanSize(float64(mem)), units.HumanSize(float64(disk)), fmt.Sprintf("%d", inodes)}) }