Commit Graph

115 Commits (4a180b209f5f494e5923cfce81ea30ba23915877)

Author SHA1 Message Date
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
shirou 9a74b6fe2e [cpu]windows: fix retrun value. 7 years ago
sada 8dd42707e2 windows: fix WithContext functions
set timeout only if parent context doesn't set.
7 years ago
Jaime Fullaondo 178e5ce997 [host] fix race condition to ret 7 years ago
shirou 4c73494c78 Add WithContext functions. 7 years ago
Adam Medzinski 22f3299fd7
Add missing doc for cpu.TimesStat structure 7 years ago
leaf 65598d98cc To prevent hang if wmi.Query hangs, add a context-aware wrapper for it. 7 years ago
Steven Hartland 6450c60b61 Eliminate use of sysctl command on FreeBSD
In order to improve performance and help prevent crashes due to the outstanding fork crash bug:
https://github.com/golang/go/issues/15658

Replace string parsed values from the sysctl command with native reads of sysctl values using unix.SysctlRaw and unix.SysctlUint32.

This also merges OpenBSD and FreeBSD load implementations which are identical.
8 years ago
WAKAYAMA Shirou 4c9fd1f200 [cpu]linux: add testcode with testdata. 8 years ago
HeChuan c818f7b647 set win cpu total name to "cpu-total"
set the name of windows cpu total percent to "cpu-total"
keep the same with Linux, Freebsd system
8 years ago
Andrew Danforth 484470889f Only read /proc/stat once when cpu.Times(true) is called on Linux 8 years ago
shirou 3dd8bd46d9 Merge pull request #376 from ContinuumLLC/win_percpu_feature
Windows: Read processor performance metrics overall, per cpu and per core
8 years ago
Rajkumar Gupta b657e83fed Added comments for structs and functions 8 years ago
Rajkumar Gupta 2d2db4203f Change to adapt current cpu.Times API for per cpu and core time stats 8 years ago
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}` 8 years ago
Rajkumar Gupta ea683cd370 Read processor performance metrics per cpu and per core 8 years ago
WAKAYAMA shirou b6da2bd76e [freebsd] cpu: fix CPUInfo on 10.3R
Related: #307
8 years ago
WAKAYAMA Shirou dfbb3e40da fix build bugs. 8 years ago
Jakob Gillich facb241c12 clarify return value of cpu.Percent() 8 years ago
WAKAYAMA Shirou 3499dec5c0 [cpu]linux: handle hz values by tmm1 8 years ago
WAKAYAMA Shirou a63f1aeeec use Processor entry as model name fallback by @tmm1 8 years ago
WAKAYAMA Shirou 36b408780c cpu[linux]: ignore cpufreq/cpuinfo_max_freq error 8 years ago
WAKAYAMA Shirou bad1ce0748 fix typo 8 years ago
WAKAYAMA Shirou 30ebb9ca3a rename expected dir to testdata. 8 years ago
WAKAYAMA Shirou f8ef680a47 error strings change to lowercase 8 years ago
shirou d4c8874c19 Merge pull request #328 from jen20/solaris-cpu
cpu: Implement Solaris support for Info()
8 years ago
James Nugent 49ed700c0d cpu: Implement Solaris support for Info()
This commit adds Solaris(^1) support for the Info() function of package
cpu, with the exception of the L2 cache size which is not trivially
available(^2).

Support is implemented by parsing the output of `isainfo -b -v` (for the
instruction set flags), and `psr-info -p -v` for other information.
Example outputs from a range of different size VMs and Joyent containers
are included as part of the tests.

(^1): This has only been tested with Illumos in the form of SmartOS. I
believe it to be portable to other Illumos distributions but have not
tested on Oracle Solaris.

(^2): Enough support is added here to be usable for my port of
HashiCorp's Nomad to SmartOS.
8 years ago
Simarpreet Singh 5a4c90ad5f cpu: Expose CPU microcode information
This commit exposes the CPU microcode information.

Signed-off-by: Simarpreet Singh <simar@opendns.com>
8 years ago
Sam Kleinman 915d1e930e fix panic in starvation situations 8 years ago
shirou 77b5d0080a Merge pull request #311 from sparrc/cpu-times-panic
fix panic when /proc/stat is empty
8 years ago
Cameron Sparr 0c9a1d33cb
fix panic when /proc/stat is empty
don't really know why this would be the case, but I suppose there are
always edge-cases.

see https://github.com/influxdata/telegraf/issues/2356
8 years ago
Cameron Sparr a213bf5e6d
run go fmt ./... 8 years ago
WAKAYAMA shirou dc8102185d separate freebsd specific test code. 8 years ago
WAKAYAMA shirou a54f700f00 fix test other than freebsd. 8 years ago
WAKAYAMA shirou eb5bfca902 [cpu]freebsd: cpu.Info() now returns CPUInfos same number as CPU nums. 8 years ago
WAKAYAMA shirou 7783018b9d [cpu]freebsd: CPU.CPU now indicates CPU num instead of MHz. 8 years ago
Marco Pfatschbacher b4846b445b Add support for OpenBSD/amd64
This code is based on the FreeBSD version
and implements roughly the same feature set.
8 years ago
Shirou WAKAYAMA ae251eb6a2 cpu[darwin]: fix Go arrays panic in cgo #279 8 years ago
Breno Leitao 286927a039 Improve CPU identification for POWER processors
Currently gopsutils fails to indentify the POWER processors family,
returning an almost empty Info() structure.

This patch improves the POWER identification without changing what is
available for x86.
9 years ago
Andreas Henriksson 9d51bfe3bb Allow clock field in /proc/cpuinfo as cpu MHz fallback value
Needed on ppc64le debian porter boxes atleast.

See #230
9 years ago
Hilko Bengen 832dcb96c8 cpu.Percent (Windows): Use the same implementation as on Unix
WMI is way too slow.
9 years ago
K.C. Wong 3dc4e52844 Handle the case when the `cpufreq` sysfs does not exist
* on virtualized host, this may happen.
* but we may have a value from parsing `/proc/cpuinfo`
* in this case, we do not return the error if we fail to extra
  a value from `cpufreq/cpuinfo_max_freq`
9 years ago
K.C. Wong 10a1ae2123 Standardize `Mhz` to mean maximum CPU frequency on Linux platform
* resolve #249
* in `cpu_windows.go`, `Mhz` is the value of `MaxClockSpeed`
* on Linux platform, the `Mhz` value is extracted from `/proc/cpuinfo`
  which reflects the current clock speed; treat this as the fallback
  value instead
* read from `cpufreq/cpuinfo_max_freq` under sysfs to get the
  maximum clock speed for `Mhz`, just like for Windows platform
* also fix the path to `cpu.CoreID` value; the filename is `core_id`
9 years ago
shirou a8e24d70f9 Merge pull request #247 from lfittl/fallback-for-unsupported-architectures
Add fallback code for all unsupported operating systems
9 years ago
K.C. Wong 123a6c9b0d Addressing frequency unit discrepancies
* for Darwin, it is a minor tweak for readability: the value
  returned is in Hz, so using a variable named 'hz' makes more
  sense than 'mhz'
* for Linux, the unit is in kHz so we need to divide the value
  from `cpuinfo_max_freq` by 10^3 to get MHz (see
  cpu-freq/user-guide.txt of the kernel documentation)
9 years ago
Lukas Fittl da9fa1162b Add fallback code for all unsupported operating systems.
This enables using gopsutil in a codebase that gets built on other OSes
than the ones supported. Instead of a build failure as before, due to
the build tags, gopsutil will now throw an "not implemented" runtime
error.

Fixes #234.
9 years ago
Lukas Fittl 74541ba4a5 CPU: Fix linter warning on OSX. 9 years ago