shirou / gopsutil

psutil for golang
Other
10.56k stars 1.58k forks source link

PPC64 support? #301

Open derekhsu opened 7 years ago

derekhsu commented 7 years ago

I am trying making gopsutil on PPC64 linux, but I got these error message:

GOOS=linux go test ./... | grep -v "exec format error"
?       github.com/shirou/gopsutil      [no test files]
# github.com/shirou/gopsutil/host
host/host_linux.go:116: undefined: sizeOfUtmp
host/host_linux.go:121: undefined: sizeOfUtmp
host/host_linux.go:123: undefined: utmp
# github.com/shirou/gopsutil/host
host/host_linux.go:116: undefined: sizeOfUtmp
host/host_linux.go:121: undefined: sizeOfUtmp
host/host_linux.go:123: undefined: utmp
--- FAIL: TestCpuInfo (0.00s)
        cpu_test.go:60: could not get CPU Info: {"cpu":0,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":1,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":2,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":3,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":4,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":5,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":6,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":7,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":8,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":9,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":10,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":11,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":12,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":13,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":14,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":15,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":16,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":17,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":18,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":19,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":20,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":21,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":22,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
        cpu_test.go:60: could not get CPU Info: {"cpu":23,"vendorId":"","family":"","model":"IBM,8246-L1T","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"","mhz":0,"cacheSize":0,"flags":null}
FAIL
FAIL    github.com/shirou/gopsutil/cpu  0.867s
ok      github.com/shirou/gopsutil/disk 0.058s
ok      github.com/shirou/gopsutil/docker       0.009s
FAIL    github.com/shirou/gopsutil/host [build failed]
ok      github.com/shirou/gopsutil/internal/common      0.004s
ok      github.com/shirou/gopsutil/load 0.004s
ok      github.com/shirou/gopsutil/mem  0.007s
ok      github.com/shirou/gopsutil/net  0.195s
FAIL    github.com/shirou/gopsutil/process [build failed]
GOOS=freebsd go test ./... | grep -v "exec format error"
cmd/go: unsupported GOOS/GOARCH pair freebsd/ppc64
make: *** [build_test] Error 1

I am not sure do you want support PPC64 arch.

shirou commented 7 years ago

230 is related.

  1. How about if you copy host/host_linux_ppc64le.go to host/host_linux_ppc64.go and change // +build ppc64le to // +build ppc64 ?
  2. Could you paste your /proc/cpuinfo ?
derekhsu commented 7 years ago

Hi @shirou ,

Yes I tried but I met a same problem in #230

# github.com/shirou/gopsutil/process
../../shirou/gopsutil/process/process_linux.go:559: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:560: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:581: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:582: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:583: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:584: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:585: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:586: undefined: PageSize
../../shirou/gopsutil/process/process_linux.go:723: undefined: ClockTicks
../../shirou/gopsutil/process/process_linux.go:724: undefined: ClockTicks
../../shirou/gopsutil/process/process_linux.go:724: too many errors

CPU info is listed below:

processor       : 0
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 1
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 2
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 3
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 4
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 5
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 6
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 7
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 8
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 9
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 10
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 11
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 12
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 13
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 14
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 15
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 16
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 17
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 18
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 19
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 20
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 21
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 22
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

processor       : 23
cpu             : POWER7 (architected), altivec supported
clock           : 4228.000000MHz
revision        : 2.1 (pvr 004a 0201)

timebase        : 512000000
platform        : pSeries
model           : IBM,8246-L1T
machine         : CHRP IBM,8246-L1T

Thank you.

shirou commented 7 years ago
  1. pull feature/ppc64 branch
  2. copy your /proc/stat to $GOPATH/src/github.com/shirou/gopsutil/cpu/expected/linux_ppc64/proc/stat
  3. cd $GOPATH/src/github.com/shirou/gopsutil/cpu
  4. HOST_PROC=expected/linux_ppc64/proc go test -run TestCpuInfo

Could you tell me what happend, or paste your /proc/stat ?

thechristschn commented 6 years ago

I just had the same problem with undefined: sizeOfUtmp while building telegraf on ppc64. I got it fixed by copying host/host_linux_ppc64.go into the master branch.

Is there a chance to get the branch merged into master? Do you still need some information?

shirou commented 6 years ago

@thechristschn I can not confirm the PR works. If you can, please report on that PR branch, not just a coping. After that, I will merge it. thank you.