Commit Graph

77 Commits (d28b00341164c7fc3530f86ea7ed600109b10bfb)

Author SHA1 Message Date
WAKAYAMA shirou 7783018b9d [cpu]freebsd: CPU.CPU now indicates CPU num instead of MHz.
Marco Pfatschbacher b4846b445b Add support for OpenBSD/amd64
This code is based on the FreeBSD version
and implements roughly the same feature set.
Shirou WAKAYAMA ae251eb6a2 cpu[darwin]: fix Go arrays panic in cgo #279
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.
Andreas Henriksson 9d51bfe3bb Allow clock field in /proc/cpuinfo as cpu MHz fallback value
Needed on ppc64le debian porter boxes atleast.

See #230
Hilko Bengen 832dcb96c8 cpu.Percent (Windows): Use the same implementation as on Unix
WMI is way too slow.
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`
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`
shirou a8e24d70f9 Merge pull request #247 from lfittl/fallback-for-unsupported-architectures
Add fallback code for all unsupported operating systems
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)
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.
Lukas Fittl 74541ba4a5 CPU: Fix linter warning on OSX.
shirou 5c1bfed855 Merge pull request #219 from sean-/freebsd-cpu-info
Improve FreeBSD's CPU InfoStat collection
Sean Chittenden 14b2ce8b81
Don't be lossy re: CPU model number.
Sean Chittenden 606680edc5
Improve the accuracy of CPU detection on FreeBSD.
Ben Aldrich 9dbebcf46e rename ALL to all
Ben Aldrich a76195e088 fixed imports and spelling error
Ben Aldrich c36f7ac8b0 rename var
Ben Aldrich fcc1747d9f Merge branch 'master' of https://github.com/shirou/gopsutil into calc_cpu_percent
Conflicts:
	cpu/cpu.go
Ben Aldrich c389989453 calculate cpu percentage compared to last call if 0 interval is given
Sean Chittenden d2ca7e8d2c
Remove redundant build tag
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201
Aaron Zinman 4041e7d31e Fix compile errors for iOS/arm64
- Added conditional preprocessor guard on cpu_darwin_cgo.go

- Duplicated disk_darwin_amd64 for arm64 (after confirming
that sys/mount.h are the same between the two platforms, hence the
constants should be valid).
Shirou WAKAYAMA 5daf090513 [cpu]linux: vendorId in cpuinfo is sometimes vendor_id.
Shirou WAKAYAMA bce9212def fix build bugs.
Shirou WAKAYAMA d21ed2b40d search path via exec.LookPath before actual invoke.
Shirou WAKAYAMA 613a8a90e1 fixed by golint.
Shirou WAKAYAMA 4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase.
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters
Shirou WAKAYAMA 7f22150707 CPU num is different on the CircleCI environemnt, so we skip it.
Johan Walles ebaa641e63 Make a public function for computing total CPU time
This function used to be a private part of process.go.

Since I needed that functionality however I think it's better to make it public
than for me to copy it into my own code.

As a side effect of this change, I also fixed a bug in the function where Stolen
was not part of the sum. Having the function close to the CPUTimesStat
declaration will make problems like this less likely to re-occur in the future.
Ryan J. O'Neil 4d7275adf7 Rebrandoning back.
Ryan J. O'Neil 2434a327b9 Removing race condition in CPUPercent calculation.
Ryan J. O'Neil 1b9883dc76 Rebrandoning so we can patch this library and have it work in our Godeps.
Daniel Theophanes fa7f8ba4e8 cpu: CPUInfo returns one item per physical thread. Fix "Cores" to 1 on Linux.
Fixes #104
Daniel Theophanes bc6481f7e0 Merge branch 'master' of https://github.com/shirou/gopsutil into cpu_test
Shirou WAKAYAMA 7288e9a5af common[all]: add internal
Daniel Theophanes 726e7c6406 cpu: fix cpu test on small ARM device where CPU can be at 100%+rounding.
Fixes #99
Daniel Theophanes 0af895258e common: rename package common to internal/common. Add ENV helper funcs.
Package common wasn't used for public functions. Place it in an
internal directory to prevent other packages from using.

Remove the distributed references to "HOST_PROC" and "HOST_SYS"
consts and combine into a common function. This also helps so that
if a env var is defined with a trailing slash all will continue to
work as expected.

Fixes #100
Daniel Theophanes 69221741e8 cpu: allow override of /sys dir. Fix CPUInfo /proc + cpuinfo combine.
Daniel Theophanes ab2cba55ee Merge branch 'master' of https://github.com/shirou/gopsutil into cpu_arm
Daniel Theophanes 9f2e6a74cc cpu: support ARM CPUs.
ARM CPUs don't include the same fields as  x86 and amd64 CPUs in
the /proc/cpuinfo list. Pull information from the /sys/...
device tree as well as updating when a CPU is done in cpuinfo.

Fixes #88
Jonathan Chauncey 0461c50666 chore(*): Fixes #94
Added the ability to fetch an alternative location for /proc via an
environment variable. If the env var is not set it will return /proc as
the default value.
Shirou WAKAYAMA a95dde9672 cpu[darwin]: separetes cpu_darwin to cgo and nocgo to get CPUTimes.
Ben Aldrich a4ec4177a6 Fix cpu percent on windows
Tested on windows 7:

When divided by 100 you get cpu percentage of  %0.14 when task manager shows %14. Once this is removed they match.
WAKAYAMA Shirou 4696985e84 cpu[windows]: skip if could not get cpu.LoadPercentage.
Shirou WAKAYAMA 47f6760cf3 cpu[darwin]: use CGO to get CPUTimes. This is breaking. see #66.
shirou 3c958a8ee6 Merge pull request #60 from mayowa/master
Bug fix and HostStatInfo.Platform* windows implementation
mayowa 6fa0704dbf fixed: ProcessorId doesnt return a value
Shirou WAKAYAMA 0d7ff2eb40 cpu[darwin]: convert cpu frequency to Mhz.