* 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`
* 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`
* 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)
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.
- 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).
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.
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
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
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.