mirror of
https://github.com/containers/podman.git
synced 2025-07-01 08:07:03 +08:00
api: fix the CPU stats reported
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -66,7 +66,9 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container
|
|||||||
}
|
}
|
||||||
stats.BlockInput, stats.BlockOutput = calculateBlockIO(cgroupStats)
|
stats.BlockInput, stats.BlockOutput = calculateBlockIO(cgroupStats)
|
||||||
stats.CPUNano = cgroupStats.CPU.Usage.Total
|
stats.CPUNano = cgroupStats.CPU.Usage.Total
|
||||||
|
stats.CPUSystemNano = cgroupStats.CPU.Usage.Kernel
|
||||||
stats.SystemNano = now
|
stats.SystemNano = now
|
||||||
|
stats.PerCPU = cgroupStats.CPU.Usage.PerCPU
|
||||||
// Handle case where the container is not in a network namespace
|
// Handle case where the container is not in a network namespace
|
||||||
if netStats != nil {
|
if netStats != nil {
|
||||||
stats.NetInput = netStats.TxBytes
|
stats.NetInput = netStats.TxBytes
|
||||||
|
@ -2,17 +2,19 @@ package libpod
|
|||||||
|
|
||||||
// ContainerStats contains the statistics information for a running container
|
// ContainerStats contains the statistics information for a running container
|
||||||
type ContainerStats struct {
|
type ContainerStats struct {
|
||||||
ContainerID string
|
ContainerID string
|
||||||
Name string
|
Name string
|
||||||
CPU float64
|
PerCPU []uint64
|
||||||
CPUNano uint64
|
CPU float64
|
||||||
SystemNano uint64
|
CPUNano uint64
|
||||||
MemUsage uint64
|
CPUSystemNano uint64
|
||||||
MemLimit uint64
|
SystemNano uint64
|
||||||
MemPerc float64
|
MemUsage uint64
|
||||||
NetInput uint64
|
MemLimit uint64
|
||||||
NetOutput uint64
|
MemPerc float64
|
||||||
BlockInput uint64
|
NetInput uint64
|
||||||
BlockOutput uint64
|
NetOutput uint64
|
||||||
PIDs uint64
|
BlockInput uint64
|
||||||
|
BlockOutput uint64
|
||||||
|
PIDs uint64
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,9 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
preCPUStats = docker.CPUStats{
|
preCPUStats = docker.CPUStats{
|
||||||
CPUUsage: docker.CPUUsage{
|
CPUUsage: docker.CPUUsage{
|
||||||
TotalUsage: stats.CPUNano,
|
TotalUsage: stats.CPUNano,
|
||||||
PercpuUsage: []uint64{uint64(stats.CPU)},
|
PercpuUsage: stats.PerCPU,
|
||||||
UsageInKernelmode: 0,
|
UsageInKernelmode: stats.CPUSystemNano,
|
||||||
UsageInUsermode: 0,
|
UsageInUsermode: stats.CPUNano - stats.CPUSystemNano,
|
||||||
},
|
},
|
||||||
SystemUsage: 0,
|
SystemUsage: 0,
|
||||||
OnlineCPUs: 0,
|
OnlineCPUs: 0,
|
||||||
@ -146,7 +146,7 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
CPUStats: docker.CPUStats{
|
CPUStats: docker.CPUStats{
|
||||||
CPUUsage: docker.CPUUsage{
|
CPUUsage: docker.CPUUsage{
|
||||||
TotalUsage: cgroupStat.CPU.Usage.Total,
|
TotalUsage: cgroupStat.CPU.Usage.Total,
|
||||||
PercpuUsage: []uint64{uint64(stats.CPU)},
|
PercpuUsage: cgroupStat.CPU.Usage.PerCPU,
|
||||||
UsageInKernelmode: cgroupStat.CPU.Usage.Kernel,
|
UsageInKernelmode: cgroupStat.CPU.Usage.Kernel,
|
||||||
UsageInUsermode: cgroupStat.CPU.Usage.Total - cgroupStat.CPU.Usage.Kernel,
|
UsageInUsermode: cgroupStat.CPU.Usage.Total - cgroupStat.CPU.Usage.Kernel,
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user