Skip to content

Commit fda6d7f

Browse files
author
helen
committed
crictl stats add name row
Signed-off-by: helen <[email protected]>
1 parent 57039ef commit fda6d7f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: cmd/crictl/container_stats.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,13 @@ func displayStats(ctx context.Context, client internalapi.RuntimeService, reques
217217
return err
218218
}
219219

220-
display.AddRow([]string{columnContainer, columnCPU, columnMemory, columnDisk, columnInodes})
220+
display.AddRow([]string{columnContainer, columnName, columnCPU, columnMemory, columnDisk, columnInodes})
221221
for _, s := range r.GetStats() {
222222
if ctx.Err() != nil {
223223
return ctx.Err()
224224
}
225225
id := getTruncatedID(s.Attributes.Id, "")
226+
name := s.GetAttributes().GetMetadata().GetName()
226227
cpu := s.GetCpu().GetUsageCoreNanoSeconds().GetValue()
227228
mem := s.GetMemory().GetWorkingSetBytes().GetValue()
228229
disk := s.GetWritableLayer().GetUsedBytes().GetValue()
@@ -245,7 +246,7 @@ func displayStats(ctx context.Context, client internalapi.RuntimeService, reques
245246
}
246247
cpuPerc = float64(cpu-old.GetCpu().GetUsageCoreNanoSeconds().GetValue()) / float64(duration) * 100
247248
}
248-
display.AddRow([]string{id, fmt.Sprintf("%.2f", cpuPerc), units.HumanSize(float64(mem)),
249+
display.AddRow([]string{id, name, fmt.Sprintf("%.2f", cpuPerc), units.HumanSize(float64(mem)),
249250
units.HumanSize(float64(disk)), fmt.Sprintf("%d", inodes)})
250251

251252
}

0 commit comments

Comments
 (0)