Commit Graph

204 Commits

Author SHA1 Message Date
Martin Reindl 1d89235f34 host: add support for OpenBSD/armv7 2022-04-15 21:11:36 +02:00
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
2022-03-24 17:55:48 +01:00
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.
2022-03-04 18:56:33 +02:00
shirou d33b2dfda5
Merge pull request #1244 from omar-polo/master
fix cpu_openbsd.go once and for all
2022-02-25 23:25:27 +09:00
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.
2022-02-24 15:05:18 +01:00
Omar Polo 3c3c017f23 avoid copying kernCPUStats 2022-02-08 11:41:54 +00:00
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.
2022-02-06 23:47:17 +00:00
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.
2022-02-06 23:47:17 +00:00
Omar Polo 73db061652 some typos + rename smt to smtEnabled for readability 2022-02-06 23:47:17 +00:00
Omar Polo 9203029aae drop compatibilty with OpenBSD < 6.4
6.3 was EOL'd more than three years ago!
2022-02-06 23:47:16 +00:00
Matthieu MOREL 8ba220d241 enable contextcheck linter 2022-01-24 09:26:50 +01:00
mmorel-35 1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
mmorel-35 eb5f6203d8 gofmt 2021-12-22 21:46:33 +00:00
Matthieu MOREL c8fd8c7b1f
enable unparam linter 2021-12-22 19:53:14 +01:00
shirou 69ea4bfdae
Merge pull request #1194 from mmorel-35/master
Enable errorlint and gci linters
2021-12-22 21:43:03 +09:00
Matthieu MOREL b673968d5d
enable errorlint linter 2021-12-04 22:29:38 +01:00
shirou bde422a2ff [cpu][mac] doesn't return error when cpu.frequency 2021-12-04 04:23:33 +00:00
shirou d2e27c1712 fix dependabot v2 deletion. 2021-12-01 00:12:55 +00:00
shirou 0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
shirou 0fdf65fa3e Change to use yusufpapurcu/wmi from StackExchange/wmi. 2021-11-20 11:36:30 +00:00
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).
2021-06-14 22:00:22 -06:00
Ville Skyttä 47f2f0eee5 [cpu][linux] add more ARM hw implementers 2021-05-30 15:39:19 +03:00
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
2021-05-20 19:35:01 +03:00
Ville Skyttä 2278747969 [v2][cpu][solaris] psrinfo parsing fixes 2021-05-08 16:41:03 +03:00
Lomanic d447f9f7ed
Merge pull request #1039 from Lomanic/issue1037
[cpu][linux] Fix #1037 only count logical cores where 2nd field is a number
2021-04-14 00:58:15 +02:00
Ivan Babrou 19ac85b504 Add missing TargetConditionals.h include, closes #976 2021-03-01 09:41:31 -08:00
Lomanic 6589c5c274 [cpu][linux] Fix #1037 only count logical cores where 2nd field is a number 2021-02-22 00:28:56 +01:00
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.
2021-02-19 12:20:10 +01:00
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
2020-11-07 00:48:53 +01:00
shirou f377a07e5a fix test and openbsd errors. 2020-10-25 19:06:59 +09:00
Lomanic bb6f6e4968 [cpu][linux] Test Counts against lscpu results 2020-09-15 21:39:25 +02:00
Lomanic 7700262175 [cpu][linux] Fix #849 implement giampaolo/psutil#1727 in Counts() for physical cores 2020-09-15 21:38:47 +02:00
Lomanic 4cfc60d68b
Merge pull request #928 from Lomanic/skip-tests-when-not-implemented 2020-09-06 13:33:31 +02:00
ninedraft 34df4904f6 use cancelable sleep in cpu.PercentWithContext and process.Process.PercentWithContext 2020-09-03 23:01:53 +03:00
Tobias Klauser 548c500117 Use unix.SysctlUin32("hw.ncpuonline") on OpenBSD
Use SysctlUvmexp from golang.org/x/sys/unix to avoid having to simplify
the implementation of cpu.InfoWithContext

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2020-09-01 11:22:28 +02:00
Lomanic 38f6ed0e0c [cpu] Skip tests on non-implemented platforms #446 2020-08-29 18:29:04 +02:00
Guillaume Ballet baec973ff6 Fix stepping extraction 2020-06-22 13:03:18 +02:00
Guillaume Ballet 877e0a6603 more typo fixes 2020-06-22 11:59:22 +02:00
Guillaume Ballet 8968457048 fix typo 2020-06-22 11:56:02 +02:00
Guillaume Ballet 771601b292 use sysctl instead of parsing dmesg output 2020-06-22 11:54:44 +02:00
Guillaume Ballet 9390667f0f
Update cpu/cpu_dragonfly.go
Co-authored-by: shirou <shirou.faw@gmail.com>
2020-06-21 12:21:18 +02:00
Guillaume Ballet 56d9e0b7be cpu: support for DragonflyBSD 2020-06-18 10:17:23 +02:00
Lomanic 663af789c0
Merge pull request #872 from renaynay/update-docs-cputimes
Update docs for TimesStat with correct time unit
2020-05-31 17:11:28 +02:00
Lomanic a901d160ca
Merge pull request #870 from renaynay/naming-consistency
Renamed variables storing `CLK_TCK` value for consistency across OSs
2020-05-31 17:01:13 +02:00
renaynay 5e1b882e37
updated docs for TimesStat with correct time unit 2020-05-13 11:21:01 +02:00
renaynay 0e9462eed2
renamed CLK_TCK variables for consistency across OSs 2020-05-12 15:36:18 +02:00
renaynay d4985c9690
added check for CLK_TCK 2020-05-12 13:59:26 +02:00
Dmitri Goutnik 270f6afc22
Add support for freebsd/arm64 2019-12-17 03:12:29 -05:00
shirou b0025409e9 [cpu][linux]: add cpuinfo parse check. 2019-11-14 21:47:42 +09:00
alialaee b8f51de8f6 Fix #777 cpu.Total should not add Guest and GuestNice 2019-10-15 19:19:12 +03:30