summaryrefslogtreecommitdiff
path: root/libpod/stats.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/stats.go')
-rw-r--r--libpod/stats.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/libpod/stats.go b/libpod/stats.go
index 7830919ba..61e85ed5e 100644
--- a/libpod/stats.go
+++ b/libpod/stats.go
@@ -66,8 +66,14 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container
stats.BlockInput, stats.BlockOutput = calculateBlockIO(cgroupStats)
stats.CPUNano = cgroupStats.CPU.Usage.Total
stats.SystemNano = cgroupStats.CPU.Usage.Kernel
- stats.NetInput = netStats.TxBytes
- stats.NetOutput = netStats.RxBytes
+ // Handle case where the container is not in a network namespace
+ if netStats != nil {
+ stats.NetInput = netStats.TxBytes
+ stats.NetOutput = netStats.RxBytes
+ } else {
+ stats.NetInput = 0
+ stats.NetOutput = 0
+ }
return stats, nil
}