summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorJake Correnti <jcorrenti13@gmail.com>2022-06-13 13:33:19 -0400
committerMatthew Heon <mheon@redhat.com>2022-06-14 16:12:11 -0400
commit96ccd6934b8f23d5af51514b136ed802647dc47a (patch)
tree3a1828a8d1d814def00cddd56484eb979723e81b /cmd/podman
parentef3197885e92a4604823a739cbdc732b41b4ab31 (diff)
downloadpodman-96ccd6934b8f23d5af51514b136ed802647dc47a.tar.gz
podman-96ccd6934b8f23d5af51514b136ed802647dc47a.tar.bz2
podman-96ccd6934b8f23d5af51514b136ed802647dc47a.zip
Non-running containers now report statistics via the `podman stats`
command Previously, if a container was not running, and the user ran the `podman stats` command, an error would be reported: `Error: container state improper`. Podman now reports stats as the fields' default values for their respective type if the container is not running: ``` $ podman stats --no-stream demo ID NAME CPU % MEM USAGE / LIMIT MEM % NET IO BLOCK IO PIDS CPU TIME AVG CPU % 4b4bf8ce84ed demo 0.00% 0B / 0B 0.00% 0B / 0B 0B / 0B 0 0s 0.00% ``` Closes: #14498 Signed-off-by: Jake Correnti <jcorrenti13@gmail.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/stats.go12
1 files changed, 1 insertions, 11 deletions
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go
index 500671d31..02f8c6970 100644
--- a/cmd/podman/containers/stats.go
+++ b/cmd/podman/containers/stats.go
@@ -214,10 +214,6 @@ func (s *containerStats) BlockIO() string {
}
func (s *containerStats) PIDS() string {
- if s.PIDs == 0 {
- // If things go bazinga, return a safe value
- return "--"
- }
return fmt.Sprintf("%d", s.PIDs)
}
@@ -231,7 +227,7 @@ func (s *containerStats) MemUsageBytes() string {
func floatToPercentString(f float64) string {
strippedFloat, err := utils.RemoveScientificNotationFromFloat(f)
- if err != nil || strippedFloat == 0 {
+ if err != nil {
// If things go bazinga, return a safe value
return "--"
}
@@ -239,16 +235,10 @@ func floatToPercentString(f float64) string {
}
func combineHumanValues(a, b uint64) string {
- if a == 0 && b == 0 {
- return "-- / --"
- }
return fmt.Sprintf("%s / %s", units.HumanSize(float64(a)), units.HumanSize(float64(b)))
}
func combineBytesValues(a, b uint64) string {
- if a == 0 && b == 0 {
- return "-- / --"
- }
return fmt.Sprintf("%s / %s", units.BytesSize(float64(a)), units.BytesSize(float64(b)))
}