Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions libpod/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
85 changes: 36 additions & 49 deletions vendor/github.com/containerd/cgroups/blkio.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions vendor/github.com/containerd/cgroups/cpu.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading