Use SysctlRaw instead of Sysctl.
The latter assumes NUL terminated strings
which returns the lenght off by one.
Therefore, only n-1 disks where reported.
The presence of the -mmacosx-version-min flag in disk_darwin_cgo.go
makes it impossible to build the other cgo components on modern Mac OS X
(10.12), since the object files with which they must link are not built
with that flag. Errors present from Go Tip (1.9, effectively) in the
form:
ld: warning: object file (whatever.o) was built for newer OSX version
(10.12) than being linked (10.10)
This commit removes the minimum version flag, instead targeting the
version of OS X on which a binary is compiled as the minimum. Without
this, I believe (though have not verified it actually works) that the
only way to build without without warnings/undefined behaviour if the OS
X 10.10 headers and objects are installed and configured correctly.
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).
FreeBSD apparently changed the magic sysctl mib values for devstats.
--- FAIL: TestDisk_io_counters (0.00s)
disk_test.go:39: error no such file or directory
disk_test.go:42: ret is empty, map[]
This code uses an undocumented, but exported, go stdlib method to fetch
the sysctl by string instead of mib.
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
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.