Skip to content

Commit

Permalink
Merge pull request #1674 from kannon92/add-swap-summary
Browse files Browse the repository at this point in the history
add swap column to crictl stats
  • Loading branch information
k8s-ci-robot authored Nov 20, 2024
2 parents 4ffcbb1 + 7528c02 commit b0fe9c5
Show file tree
Hide file tree
Showing 2 changed files with 4 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 @@ -182,7 +182,7 @@ func (d containerStatsDisplayer) displayStats(ctx context.Context, client intern
return err
}

d.display.AddRow([]string{columnContainer, columnName, columnCPU, columnMemory, columnDisk, columnInodes})
d.display.AddRow([]string{columnContainer, columnName, columnCPU, columnMemory, columnDisk, columnInodes, columnSwap})
for _, s := range r.GetStats() {
if ctx.Err() != nil {
return ctx.Err()
Expand All @@ -193,6 +193,7 @@ func (d containerStatsDisplayer) displayStats(ctx context.Context, client intern
mem := s.GetMemory().GetWorkingSetBytes().GetValue()
disk := s.GetWritableLayer().GetUsedBytes().GetValue()
inodes := s.GetWritableLayer().GetInodesUsed().GetValue()
swap := s.GetSwap().GetSwapUsageBytes().GetValue()
if !d.opts.all && cpu == 0 && mem == 0 {
// Skip non-running container
continue
Expand All @@ -213,7 +214,7 @@ func (d containerStatsDisplayer) displayStats(ctx context.Context, client intern
}
d.display.AddRow([]string{
id, name, fmt.Sprintf("%.2f", cpuPerc), units.HumanSize(float64(mem)),
units.HumanSize(float64(disk)), strconv.FormatUint(inodes, 10),
units.HumanSize(float64(disk)), strconv.FormatUint(inodes, 10), units.HumanSize(float64(swap)),
})
}
d.display.ClearScreen()
Expand Down
1 change: 1 addition & 0 deletions cmd/crictl/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
columnDigest = "DIGEST"
columnMemory = "MEM"
columnInodes = "INODES"
columnSwap = "SWAP"
columnDisk = "DISK"
columnCPU = "CPU %"
columnKey = "KEY"
Expand Down

0 comments on commit b0fe9c5

Please sign in to comment.