summaryrefslogtreecommitdiff
path: root/libpod/stats.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-01 13:30:55 -0500
committerMatthew Heon <matthew.heon@gmail.com>2018-02-01 13:30:55 -0500
commita417e6e0cc46593eb10d2ce3d5102df39d44b8dd (patch)
tree813108671a7f0930d2bd8cad2a4168fbb4b3f58a /libpod/stats.go
parentae89dc28d07e1c6142201c282a76d3f237821710 (diff)
downloadpodman-a417e6e0cc46593eb10d2ce3d5102df39d44b8dd.tar.gz
podman-a417e6e0cc46593eb10d2ce3d5102df39d44b8dd.tar.bz2
podman-a417e6e0cc46593eb10d2ce3d5102df39d44b8dd.zip
Update stats code to reflect changes to containerd stats API
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/stats.go')
-rw-r--r--libpod/stats.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/libpod/stats.go b/libpod/stats.go
index 47fb16194..faccc2366 100644
--- a/libpod/stats.go
+++ b/libpod/stats.go
@@ -66,8 +66,8 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container
stats.PIDs = cgroupStats.Pids.Current - 1
}
stats.BlockInput, stats.BlockOutput = calculateBlockIO(cgroupStats)
- stats.CPUNano = cgroupStats.Cpu.Usage.Total
- stats.SystemNano = cgroupStats.Cpu.Usage.Kernel
+ stats.CPUNano = cgroupStats.CPU.Usage.Total
+ stats.SystemNano = cgroupStats.CPU.Usage.Kernel
// TODO Figure out where to get the Netout stuff.
//stats.NetInput, stats.NetOutput = getContainerNetIO(cgroupStats)
return stats, nil
@@ -99,21 +99,21 @@ func getContainerNetIO(stats *libcontainer.Stats) (received uint64, transmitted
return
}
-func calculateCPUPercent(stats *cgroups.Stats, previousCPU, previousSystem uint64) float64 {
+func calculateCPUPercent(stats *cgroups.Metrics, previousCPU, previousSystem uint64) float64 {
var (
cpuPercent = 0.0
- cpuDelta = float64(stats.Cpu.Usage.Total - previousCPU)
+ cpuDelta = float64(stats.CPU.Usage.Total - previousCPU)
systemDelta = float64(uint64(time.Now().UnixNano()) - previousSystem)
)
if systemDelta > 0.0 && cpuDelta > 0.0 {
// gets a ratio of container cpu usage total, multiplies it by the number of cores (4 cores running
// at 100% utilization should be 400% utilization), and multiplies that by 100 to get a percentage
- cpuPercent = (cpuDelta / systemDelta) * float64(len(stats.Cpu.Usage.PerCpu)) * 100
+ cpuPercent = (cpuDelta / systemDelta) * float64(len(stats.CPU.Usage.PerCPU)) * 100
}
return cpuPercent
}
-func calculateBlockIO(stats *cgroups.Stats) (read uint64, write uint64) {
+func calculateBlockIO(stats *cgroups.Metrics) (read uint64, write uint64) {
for _, blkIOEntry := range stats.Blkio.IoServiceBytesRecursive {
switch strings.ToLower(blkIOEntry.Op) {
case "read":