Revert "fix possible cpus"

This reverts commit 68e1fc1a99.
pull/380/head
Tony 5 years ago
parent 68e1fc1a99
commit 9313c5bd95
  1. 1
      go.mod
  2. 5
      pkg/stat/sys/cpu/cgroup.go
  3. 19
      pkg/stat/sys/cpu/cgroupCPU.go

@ -23,7 +23,6 @@ require (
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/leodido/go-urn v1.1.0 // indirect github.com/leodido/go-urn v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect github.com/mattn/go-colorable v0.1.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/montanaflynn/stats v0.5.0 github.com/montanaflynn/stats v0.5.0
github.com/openzipkin/zipkin-go v0.2.1 github.com/openzipkin/zipkin-go v0.2.1
github.com/otokaze/mock v0.0.0-20190125081256-8282b7a7c7c3 github.com/otokaze/mock v0.0.0-20190125081256-8282b7a7c7c3

@ -56,10 +56,7 @@ func (c *cgroup) CPUAcctUsagePerCPU() ([]uint64, error) {
if u, err = parseUint(v); err != nil { if u, err = parseUint(v); err != nil {
return nil, err return nil, err
} }
// fix possible_cpu:https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.lgdd/lgdd_r_posscpusparm.html usage = append(usage, u)
if u != 0 {
usage = append(usage, u)
}
} }
return usage, nil return usage, nil
} }

@ -8,7 +8,6 @@ import (
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
pscpu "github.com/shirou/gopsutil/cpu"
) )
type cgroupCPU struct { type cgroupCPU struct {
@ -22,17 +21,12 @@ type cgroupCPU struct {
} }
func newCgroupCPU() (cpu *cgroupCPU, err error) { func newCgroupCPU() (cpu *cgroupCPU, err error) {
var cores int cpus, err := perCPUUsage()
cores, err = pscpu.Counts(true) if err != nil {
if err != nil || cores == 0 { err = errors.Errorf("perCPUUsage() failed!err:=%v", err)
var cpus []uint64 return
cpus, err = perCPUUsage()
if err != nil {
err = errors.Errorf("perCPUUsage() failed!err:=%v", err)
return
}
cores = len(cpus)
} }
cores := uint64(len(cpus))
sets, err := cpuSets() sets, err := cpuSets()
if err != nil { if err != nil {
@ -67,11 +61,10 @@ func newCgroupCPU() (cpu *cgroupCPU, err error) {
cpu = &cgroupCPU{ cpu = &cgroupCPU{
frequency: maxFreq, frequency: maxFreq,
quota: quota, quota: quota,
cores: uint64(cores), cores: cores,
preSystem: preSystem, preSystem: preSystem,
preTotal: preTotal, preTotal: preTotal,
} }
fmt.Printf("get cpu info:%+v \n", cpu)
return return
} }

Loading…
Cancel
Save