From 53dc99fa609b5a18458e27b99df546df9095b5d0 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 9 Sep 2021 16:56:33 +0200 Subject: 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 --- libpod/stats.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libpod') 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) -- cgit v1.2.3-54-g00ecf