Commit Graph

222 Commits (c7c548d6bdb46b39cd36ae0815926de70ab1b8ca)

Author SHA1 Message Date
shirou f78f9a6bb8
Merge pull request #1414 from jeffweiss/bugfix/get_tests_working_on_s390x
get tests passing on s390x
2 years ago
shirou 852f455217 fix lint 2 years ago
Jeff Weiss f850a69ba1 get tests passing on s390x 2 years ago
Guoqi Chen b055174e9e cpu: Add the matching rule "Model Name" when parsing cpuinfo
This is to fix the error of running TestCpuInfo on Linux/long64. In loong64
/proc/cpuinfo, the model name is capitalize the first letter

Reference:
  https://github.com/torvalds/linux/blob/master/arch/loongarch/kernel/proc.c

Signed-off-by: Guoqi Chen <chenguoqi@loongson.cn>
2 years ago
Eng Zer Jun 37894e9b28
test: use `T.Setenv` to set env vars in tests
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2 years ago
shirou 835767a611
Merge pull request #1389 from sgthammer/feature/fix-arm-modelname
fill modelName for all cores in arm64 devices
2 years ago
Tobias Klauser f2bf9a480a
cpu: use windows.GetActiveProcessorCount
Use GetActiveProcessorCount and the ALL_PROCESSOR_GROUPS const provided
in golang.org/x/sys/windows. The function is available on Windows 7 and
later. Go requires Windows 7, see https://go.dev/doc/go1.11#ports
2 years ago
sgthammer 83256398be fill modelName for all cores in arm64 devices 2 years ago
Yalcin Ozbek 8bf7f37fca
the code has been moved before append
Signed-off-by: Yalcin Ozbek <yalcinozbekceng@gmail.com>
2 years ago
Yalcin Ozbek 4314a0567b
the code has been moved outside the loop.
Signed-off-by: Yalcin Ozbek <yalcinozbekceng@gmail.com>
2 years ago
Yalcin Ozbek 13f00fde46
code review fix
Signed-off-by: Yalcin Ozbek <yalcinozbekceng@gmail.com>
2 years ago
Yalcin Ozbek 102439862e
feat: Setting the model name for arm based CPUs
- Added arm model and model name as map.
- The modelName is set again according to the model value when the model name is empty.
- Based on lscpu source code.. https://github.com/util-linux/util-linux/blob/master/sys-utils/lscpu-arm.c

---

Signed-off-by: Yalcin Ozbek <yalcinozbekceng@gmail.com>
2 years ago
shirou d1cc7d2125 fix(cpu): fix cpu total and busy calc 3 years ago
xca1075 3d643b9b73 parse cpu values as float 3 years ago
xca1075 b3ab1561bc more aix nocgo implementations 3 years ago
xca1075 d4f012c565 fix aix nocgo compile 3 years ago
xca1075 d177019851 fix go build flags for aix/cpu 3 years ago
xca1075 e24e72062b aix: split code, that uses perfstat, to _cgo and _nocgo files 3 years ago
Martin Reindl 1d89235f34 host: add support for OpenBSD/armv7 3 years ago
martin 414ada919c Fix telegraf 1.22.0 build on OpenBSD/arm64:
../../../go/pkg/mod/github.com/shirou/gopsutil/v3@v3.22.2/cpu/cpu_openbsd.go:63:14: undefined: cpuTimes
3 years ago
Ville Skyttä f7e1f36418 refactor: remove unnecessary exec.LookPath calls
Executing the command does the lookup if needed and returns the same
error when not found, no need to do it separately.
3 years ago
shirou d33b2dfda5
Merge pull request #1244 from omar-polo/master
fix cpu_openbsd.go once and for all
3 years ago
Omar Polo 73f9c8dfd5 avoid cgo for cpu_openbsd
Even thought OpenBSD often breaks the ABI compatibility and doesn't make
*any* promise of "stability", this project aims to be "pure go" so avoid
doing inter-op at the cost of artificially reducing the number of
supported architectures down to amd64 and i386.

To add support for another architecture (e.g. arm), add another file
cpu_openbsd_${arch}.go like done for 386 and amd64.  The fields are
declared as `long' in C, so pick the appropriate size when declaring the
struct.
3 years ago
Omar Polo 3c3c017f23 avoid copying kernCPUStats 3 years ago
Omar Polo 57d5711d44 refactor TimesWithContext
don't make assumptions on which CPUs are online and wich aren't based
on hw.smt and hw.ncpuonline.  Rather, use KERN_CPUSTATS to get the CPU
statistics, which includes a flag field that can tell us if that CPU
is online or not.
3 years ago
Omar Polo 16cc7d7d73 improve sysctl parsing: use native byte order
We can't use unix.Sysctl* for some sysctls, so we're on our own with
converting data from C arrays.

Don't assume that the byte order is little endian but do the right
thing.  Moreover, there's a little distinction in the sizes reported
by KERN_CPTIME (long[cpustates]) and KERN_CPTIME2
(u_int64_t[cpustates]) so account for that too.
3 years ago
Omar Polo 73db061652 some typos + rename smt to smtEnabled for readability 3 years ago
Omar Polo 9203029aae drop compatibilty with OpenBSD < 6.4
6.3 was EOL'd more than three years ago!
3 years ago
Matthieu MOREL 8ba220d241 enable contextcheck linter 3 years ago
mmorel-35 1e6b445a8a gofumpt 3 years ago
mmorel-35 eb5f6203d8 gofmt 3 years ago
Matthieu MOREL c8fd8c7b1f
enable unparam linter 3 years ago
shirou 69ea4bfdae
Merge pull request #1194 from mmorel-35/master
Enable errorlint and gci linters
3 years ago
Matthieu MOREL b673968d5d
enable errorlint linter 3 years ago
shirou bde422a2ff [cpu][mac] doesn't return error when cpu.frequency 3 years ago
shirou d2e27c1712 fix dependabot v2 deletion. 3 years ago
shirou 0969c9436b delete v2 directory, move v3 to top #1078 3 years ago
shirou 0fdf65fa3e Change to use yusufpapurcu/wmi from StackExchange/wmi. 3 years ago
Huan Wang 6a572952f0 fix slow cpuinfo on multisocket config
updated win32_Processor struct to exclude loadpercentage field.
The loadpercentage takes linearly more time as the # of sockets
increases. By default vSphere maps 1 vCPU to 1 socket, resulting in very
poor performance when getting CPU info against, saying, 40 vCPU VM
(basically 40 sockets as seen by the VM).
4 years ago
Ville Skyttä 47f2f0eee5 [cpu][linux] add more ARM hw implementers 4 years ago
Ville Skyttä b8ac60acc1 [cpu][linux] more info for ARM processors
https://developer.arm.com/documentation/ddi0337/h/system-control/register-descriptions/cpuid-base-register--cpuid
4 years ago
Ville Skyttä 2278747969 [v2][cpu][solaris] psrinfo parsing fixes 4 years ago
Lomanic d447f9f7ed
Merge pull request #1039 from Lomanic/issue1037
[cpu][linux] Fix #1037 only count logical cores where 2nd field is a number
4 years ago
Ivan Babrou 19ac85b504 Add missing TargetConditionals.h include, closes #976 4 years ago
Lomanic 6589c5c274 [cpu][linux] Fix #1037 only count logical cores where 2nd field is a number 4 years ago
Tobias Klauser ee12f66e4d cpu, v3/cpu: use sysconf package instead of exec'ing getconf
Currently, ClocksPerSec is determined by exec'ing getconf in func init,
i.e. on startup of every program importing the package. getconf might
not be present on some systems or is not executable by the current user.
To avoid this hard to control dependency, use the
github.com/tklauser/go-sysconf package which implements sysconf(3)
entirely in Go without cgo. The package is supported on all platforms
currently supported by the cpu and v3/cpu package of gopsutil.
4 years ago
Lomanic 976679ee00 [cpu][linux] Get logical cores in Counts() with non-deprecated kernel API first
Implementing https://github.com/giampaolo/psutil/pull/1727#issuecomment-707624964
and bfae1fc4a3
4 years ago
shirou f377a07e5a fix test and openbsd errors. 4 years ago
Lomanic bb6f6e4968 [cpu][linux] Test Counts against lscpu results 5 years ago
Lomanic 7700262175 [cpu][linux] Fix #849 implement giampaolo/psutil#1727 in Counts() for physical cores 5 years ago