Commit Graph

261 Commits (master)

Author SHA1 Message Date
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
Lomanic 4cfc60d68b
Merge pull request #928 from Lomanic/skip-tests-when-not-implemented 5 years ago
ninedraft 34df4904f6 use cancelable sleep in cpu.PercentWithContext and process.Process.PercentWithContext 5 years ago
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>
5 years ago
Lomanic 38f6ed0e0c [cpu] Skip tests on non-implemented platforms #446 5 years ago
Guillaume Ballet baec973ff6 Fix stepping extraction 5 years ago
Guillaume Ballet 877e0a6603 more typo fixes 5 years ago
Guillaume Ballet 8968457048 fix typo 5 years ago
Guillaume Ballet 771601b292 use sysctl instead of parsing dmesg output 5 years ago
Guillaume Ballet 9390667f0f
Update cpu/cpu_dragonfly.go
Co-authored-by: shirou <shirou.faw@gmail.com>
5 years ago
Guillaume Ballet 56d9e0b7be cpu: support for DragonflyBSD 5 years ago
Lomanic 663af789c0
Merge pull request #872 from renaynay/update-docs-cputimes
Update docs for TimesStat with correct time unit
5 years ago
Lomanic a901d160ca
Merge pull request #870 from renaynay/naming-consistency
Renamed variables storing `CLK_TCK` value for consistency across OSs
5 years ago
renaynay 5e1b882e37
updated docs for TimesStat with correct time unit 5 years ago
renaynay 0e9462eed2
renamed CLK_TCK variables for consistency across OSs 5 years ago
renaynay d4985c9690
added check for CLK_TCK 5 years ago
Dmitri Goutnik 270f6afc22
Add support for freebsd/arm64 5 years ago
shirou b0025409e9 [cpu][linux]: add cpuinfo parse check. 5 years ago
alialaee b8f51de8f6 Fix #777 cpu.Total should not add Guest and GuestNice 5 years ago
shirou e4d2c2f87a
Merge pull request #749 from Lomanic/issue628windows
[cpu][windows] Add support for logical arg in Counts #640 #628
6 years ago
Lomanic 71adb75383 [cpu][windows] Add support for logical arg in Counts #640 #628 6 years ago
Lomanic e6aa38bec2 [cpu][windows] WIP Add support for logical arg in Counts #640 #628 6 years ago
shirou 86fdae99e1 [cpu]: return 100 instead 1 if t1 are bigger than t2 6 years ago
Lomanic 946c9ce6ea [cpu] Fix #599 cap percent values returned by Percent() between 0 and 100
See https://github.com/shirou/gopsutil/issues/599#issuecomment-491942842 for a repoduction case
6 years ago
Lomanic 35f21af98a
Merge pull request #699 from harpchad/solaris_cpu
Add support fo Solaris cpu times (idle, sys, user, iowait) in cpu_solaris
6 years ago
Chad Harp 8c6072d111 Cast bytes to string 6 years ago
Chad Harp 16b37cc9c2 Modify cpu_solaris to support Sorlais 10 6 years ago
Chad Harp 354718bdd8 Add support for Solaris CPU times 6 years ago
shirou 4b629897d2
Merge pull request #647 from omar-polo/master
[OpenBSD][CPU] fix per-cpu
6 years ago
shirou e146c2e08a
Merge pull request #677 from shirou/feature/remove_stolen_from_cpu
[cpu]: remove unused field Stolen
6 years ago
Segflow 86c7289ccc Fix: use filename in exec.LookPath instead of full path
exec.LookPath searches for the file in the $PATH, which mean giving it an absolute path is against it's own purposes.
6 years ago
Omar Polo 3cbb0873de
int32 is enough -- don't waste space 6 years ago
shirou cae8efcffa [cpu]: remove unused field Stolen
see #676
6 years ago
Minje Park caebe5dbe4 returning 0 and error if SysctlUint32 raises an error 6 years ago
Omar Polo 53ce014b14
handle EOPNOTSUPP when checking for hw.smt
if hw.smt is not applicable for the current platform (e.g. i386),
pretend it's enabled
6 years ago
Omar Polo c28fe78291
forget to take addr 6 years ago
Minje Park ca1fcad2aa retrieve a cpu count depends on an boolean argument 6 years ago
Omar Polo 932f2f6049
Fix cpu stats when hw.smt is enabled
When hw.smt is enabled, and it's enabled by default from 6.4, the
number of cpus given by `runtime.NumCPU()` is half of the total: only
the cpuN with N = 0,2,4,... are used by the system. We need to detect
that and ask for the correct stats.
6 years ago
Omar Polo 12d92847cf
Get hw.ncpuonline without unix.SysctlUint32
unix.Sysctl always return an error when asking for hw.ncpuonline, so
revert to a direct unix.Syscall6 to get the cpu count.
6 years ago
Omar Polo c2c7893509
fix logic error + little refactor
Fix: get cptime of n-th cpu when `percpu` instead of the average.

While there, rearrange the last if statement to make the code a bit
more homogeneous.
6 years ago
Lomanic 200e5fbeab [cpu][linux] Remove regexp in Counts
Also remove some remaining debug print and unnecessary strings.Split
6 years ago
Lomanic c0ca431bf1 [cpu][linux] Add support for logical arg in Counts #640 #628 6 years ago
Lomanic 2ec35609d2 [cpu][darwin] Remove calls to sysctl binary in cpu/cpu_darwin.go #639
Empirical benchmark (calling to cpu.Info):

Lomanics-iMac:~ lomanic$ time ./cpu_info
info 0: {"cpu":0,"vendorId":"GenuineIntel","family":"6","model":"30","stepping":5,"physicalId":"","coreId":"","cores":2,"modelName":"Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz","mhz":2590,"cacheSize":256,"flags":["syscall","xd","em64t","lahf","lzcnt","prefetchw","rdtscp","tsci","fpu","vme","de","pse","tsc","msr","pae","mce","cx8","apic","sep","mtrr","pge","mca","cmov","pat","pse36","clfsh","mmx","fxsr","sse","sse2","htt","sse3","ssse3","cx16","sse4.1","sse4.2","popcnt","vmm"],"microcode":""}

real    0m0.049s
user    0m0.023s
sys     0m0.041s
Lomanics-iMac:~ lomanic$ time ./cpu_info.fixed
info 0: {"cpu":0,"vendorId":"GenuineIntel","family":"6","model":"30","stepping":5,"physicalId":"","coreId":"","cores":2,"modelName":"Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz","mhz":2590,"cacheSize":256,"flags":["fpu","vme","de","pse","tsc","msr","pae","mce","cx8","apic","sep","mtrr","pge","mca","cmov","pat","pse36","clfsh","mmx","fxsr","sse","sse2","htt","sse3","ssse3","cx16","sse4.1","sse4.2","popcnt","vmm","syscall","xd","em64t","lahf","lzcnt","prefetchw","rdtscp","tsci"],"microcode":""}

real    0m0.010s
user    0m0.004s
sys     0m0.006s
6 years ago
nikita-vanyasin 59b002e5c2 Fix function naming 6 years ago
nikita-vanyasin 4ef0ddafc7 Eliminate WMI queries when calling cpu.Times with percpu=True
based on e89f2c5fad/internal/monitors/cpu/cpu_windows.go
6 years ago
shirou 64d607539e add FreeBSD ARM support. copied from i386 6 years ago
Antoine Jacoutot 67297c8791 cpu: prefer cpuonline on OpenBSD
This gives us the value of actual online CPUs (as opposed to the
found ones which may not be able active).
6 years ago
Antoine Jacoutot 7276e963eb cpu: implement Mhz and Cores
Adapted from the FreeBSD code.
Successfully tested with Nomad.
6 years ago
Lomanic 5f8353c741 [cpu][openbsd] Fix #621, define CPU states according to OpenBSD version 6 years ago
marcospedreiro f0ebb60b86 handle pr comments: use assert.InEpsilon 6 years ago
marcospedreiro d47801b68b revert imports 6 years ago
marcospedreiro 3cc34ebf18 windows cpu time (true) should return cpu time not percentages 6 years ago
marcospedreiro 45aeaebda5 test windows cpu.Time(true) returning time instead of percentages 6 years ago
Lomanic 4254ce2081
Merge pull request #601 from Lomanic/issue551
Fix #551 Filter out '_Total' results from PerfInfoWithContext and unexport this function.

Also propagate context in perCPUTimes (renamed to perCPUTimesWithContext) and unexport Win32_PerfFormattedData_Counters_ProcessorInformation type.
6 years ago
Lomanic 79f8a73e23 Fix #551 Filter out '_Total' results from PerfInfoWithContext and unexport this function
Also propagate context in perCPUTimes (renamed to perCPUTimesWithContext)
and unexport Win32_PerfFormattedData_Counters_ProcessorInformation.
6 years ago
shirou a11c78ba2c
Merge pull request #581 from CMGS/master
get docker container cpu usage from cpuacct.usage
7 years ago
Iskander Sharipov f3d4342c30 cpu,process: remove commented-out code
Found using https://go-critic.github.io/overview#commentedOutCode-ref
7 years ago
CMGS d93c01e54d get docker container cpu usage from cpuacct.usage 7 years ago
Michal Rostecki 7c7dec96c6 cpu: Check for error object 7 years ago
shirou 145dca90f7 change to use CommandContext. 7 years ago
Laurie Clark-Michalek 413cb32b6c Use static initialisation for invoke instances, instead of init funcs
The order of init function execution is dependant on the order that the
source files are passed to the compiler. This causes issues when
building under other build systems, such as bazel or buck, as they are
not guarenteed to maintain the same file order as the default go tool.
7 years ago
shirou 32a44bdc39
Merge pull request #488 from sadag/master
windows: fix WithContext functions
7 years ago