gopsutil icon indicating copy to clipboard operation
gopsutil copied to clipboard

host.Users() cannot get information on ppc64le

Open jdmaloney opened this issue 3 years ago • 2 comments

Describe the bug Same/Similar issue as #1129 that same call does not work on the ppc64le architecture as well. The host.Users() function is what Telegraf uses to get this statistic. A related issue I filed there before narrowing the issue to gopsutil can be found here: https://github.com/influxdata/telegraf/issues/10003

To Reproduce

import "github.com/shirou/gopsutil/v3/host"
host.Users()   // get: []

Expected behavior Return of the number of users on the system

Environment (please complete the following information):

# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.4 (Ootpa)

# uname -a
Linux redacted.hostname.com 4.18.0-305.7.1.el8_4.ppc64le #1 SMP Mon Jun 14 17:09:47 EDT 2021 ppc64le ppc64le ppc64le GNU/Linux

Additional context Have done testing on a number of our ppc64le machines, with a varying number of user sessions on each; same issue.

Also, since I'm guessing most folks may not have access to a machine with this architecture, I can do my test to run things to help debug/test. My GO skills are very small, but I'll do all I can to help.

jdmaloney avatar Oct 26 '21 22:10 jdmaloney

Could you run go tool cgo -godefs types_linux.go in host directory on your ppc64le, and paste the outputted utmp struct ? "gcc" is required.

shirou avatar Oct 28 '21 13:10 shirou

@shirou Apologies for the very long delay here (somehow missed the email notification on your response). Output of that command is below:

[root@ppcle64-host host]# go tool cgo -godefs types_linux.go
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
// cgo -godefs /root/go/pkg/mod/github.com/shirou/gopsutil/[email protected]/host/types_linux.go

package host

const (
	sizeofPtr	= 0x8
	sizeofShort	= 0x2
	sizeofInt	= 0x4
	sizeofLong	= 0x8
	sizeofLongLong	= 0x8
	sizeOfUtmp	= 0x180
)

type (
	_C_short	int16
	_C_int		int32
	_C_long		int64
	_C_long_long	int64
)

type utmp struct {
	Type			int16
	Pid			int32
	Line			[32]uint8
	Id			[4]uint8
	User			[32]uint8
	Host			[256]uint8
	Exit			exit_status
	Session			int32
	Tv			_Ctype_struct___0
	Addr_v6			[4]int32
	X__glibc_reserved	[20]uint8
}
type exit_status struct {
	Termination	int16
	Exit		int16
}
type timeval struct {
	Sec	int64
	Usec	int64
}

jdmaloney avatar Jun 08 '22 12:06 jdmaloney