summaryrefslogtreecommitdiff
path: root/libpod/stats.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-09-09 16:56:33 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2021-09-10 09:03:08 +0200
commit53dc99fa609b5a18458e27b99df546df9095b5d0 (patch)
tree41a6e3d56fef274a5b36f8a0612c4d9d0f59c2f5 /libpod/stats.go
parent63f6656f8fa79d7f6e01379d7ba0aa4ab3c03b37 (diff)
downloadpodman-53dc99fa609b5a18458e27b99df546df9095b5d0.tar.gz
podman-53dc99fa609b5a18458e27b99df546df9095b5d0.tar.bz2
podman-53dc99fa609b5a18458e27b99df546df9095b5d0.zip
stats: allow to read stats for paused containers
paused containers still a cgroup we can use to grab the stats. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/stats.go')
-rw-r--r--libpod/stats.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/libpod/stats.go b/libpod/stats.go
index 6f0360ef1..2532b35c2 100644
--- a/libpod/stats.go
+++ b/libpod/stats.go
@@ -30,7 +30,7 @@ func (c *Container) GetContainerStats(previousStats *define.ContainerStats) (*de
}
}
- if c.state.State != define.ContainerStateRunning {
+ if c.state.State != define.ContainerStateRunning && c.state.State != define.ContainerStatePaused {
return stats, define.ErrCtrStateInvalid
}
@@ -65,7 +65,7 @@ func (c *Container) GetContainerStats(previousStats *define.ContainerStats) (*de
stats.MemLimit = getMemLimit(cgroupStats.Memory.Usage.Limit)
stats.MemPerc = (float64(stats.MemUsage) / float64(stats.MemLimit)) * 100
stats.PIDs = 0
- if conState == define.ContainerStateRunning {
+ if conState == define.ContainerStateRunning || conState == define.ContainerStatePaused {
stats.PIDs = cgroupStats.Pids.Current
}
stats.BlockInput, stats.BlockOutput = calculateBlockIO(cgroupStats)