Skip to content

Commit

Permalink
crictl stats add name row
Browse files Browse the repository at this point in the history
Signed-off-by: helen <haitao.zhang@daocloud.io>
  • Loading branch information
helen committed Feb 8, 2023
1 parent 57039ef commit fda6d7f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/crictl/container_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)})

}
Expand Down

0 comments on commit fda6d7f

Please sign in to comment.