Commit Graph

141 Commits (ccc1c1016bc5d10e803189ee43417c50cdde7f1b)

Author SHA1 Message Date
Pierre Souchay 890eb80501 Better comments for fallback on /etc/machine-id 6 years ago
Pierre Souchay be2b25a7c6 Have a real fixed HostID on Linux
On Linux, most golang programs do not run as root (or at least, they should not),
by default, the kernels uses strict permissions, so most userland programs cannot
read `/sys/class/dmi/id/product_uuid`. However, programs such as Consul are relying
on it to get fixed IDs, instead they have a different ID on each boot.

We propose to use `/etc/machine-id` as fallback https://www.freedesktop.org/software/systemd/man/machine-id.html

In order to fix this, this patch does the following:
 - if `/sys/class/dmi/id/product_uuid` can be read, use it for HostID
 - else if `/etc/machine-id` exists and has 32 chars, use it and add '-' to have the same format as product_uuid
 - finally, if notthing works, use the `kernel.random.boot_id`

This will greatly increase the number of programs having correct behaviour when
those rely on having a fixed HostID.

This will fix the following issues:
 - https://github.com/shirou/gopsutil/issues/350
 - https://github.com/hashicorp/consul/issues/4741
6 years ago
Lomanic 18b2744df2 [host][darwin] Fix #574, use 'uname -r' in KernelVersion() 7 years ago
Ozair Jr 0bab9611d2 Adding Slackware platform information 7 years ago
Lomanic bb518e9c4e [host][windows] Remove exported wmi type from #550 7 years ago
pytimer 62fcd00c4d [host] Implement windows temperature use wmi 7 years ago
shirou 4923bd298a host: remove empty virtualzation check.
related to #547
There is an architecture which supports no virtualization.
7 years ago
Lomanic 6c4f577e6e
Merge branch 'master' into winapihost 7 years ago
Michal Rostecki 0225d9ddcc host: Check for error object 7 years ago
Lomanic 61e2d92d95 [host][windows] Query registry via golang.org/x/sys/windows instead of golang.org/x/sys/windows/registry
See https://github.com/shirou/gopsutil/pull/312#issuecomment-277422612
7 years ago
Lomanic d8a6a50129 Revert "[host][windows] Refactor code to query registry via golang.org/x/sys/windows/registry"
This reverts commit c729bbd6a8.
7 years ago
Lomanic c729bbd6a8 [host][windows] Refactor code to query registry via golang.org/x/sys/windows/registry 7 years ago
Lomanic eb11fd6e2f [host][windows] Completely remove slow wmi calls to retrieve OS version, use registry and RtlGetVersion 7 years ago
Lomanic df331c7615 [host][windows] Use win32 API to get host's uptime instead of (slow) wmi 7 years ago
shirou c95755e4bc [host]darwin: remove GPL code 7 years ago
Maddie Zhan 8c8eeb32d3 [host] linux/mips: mips64le definition from mipsle
Same as commit fc04d2d, but for mips64le from mipsle definition.
It would be nice if anyone can check with the correctness, since the
qemu environment for mips64/mips64le can't run Go properly due to this
issue: https://github.com/golang/go/issues/15416
7 years ago
shirou cd915bdc31
Merge pull request #508 from shirou/issue507
[host] Fix docker uptime parsing (fix #507)
7 years ago
Lomanic 1b47825dcb [host] Fix docker uptime parsing (fix #507) 7 years ago
shirou fc04d2dd9a [host]linux/mips: copy mips64 definition from mips.
It just copy from mips, so it may be corrupt, but I can not check it.
If something wrong, please open an issue.
7 years ago
shirou 145dca90f7 change to use CommandContext. 7 years ago
shirou b99342a9ce [host] fallback: implement PlatformInformation() 7 years ago
shirou ebe614f6e1 [solaris] host: add PlatformInformation() which is missing. 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
linuxhe ee5d6a3d8f fix docker uptime 7 years ago
shirou d76e8c18d8
Merge pull request #496 from shirou/add_docker_to_use_btime
[host] linux: use uptime even if docker guest.
7 years ago
Steven Hartland f846eda923 Eliminate call to uname on FreeBSD
Improve performance by eliminating the fork out to uname on FreeBSD which also helps prevent crashes / hangs due to the outstanding fork crash bug:
golang/go#15658

Also added a test for PlatformInformation.
7 years ago
shirou 28f7cb0d63 [host] linux: use uptime even if docker guest. 7 years ago
sada 8dd42707e2 windows: fix WithContext functions
set timeout only if parent context doesn't set.
7 years ago
CHEVY S. HUNGERFORD 29f8dfa1ad fixing SensorKey output 7 years ago
CHEVY S. HUNGERFORD 1c4fa5628c giving temperature more verbose output 7 years ago
shirou 4ac6b5b4d3 Revert "Merge pull request #470 from improbable-io/bug-darwin-build-2"
This reverts commit bb09b4e7d9, reversing
changes made to 6a368fb7cd.
7 years ago
shirou bb09b4e7d9
Merge pull request #470 from improbable-io/bug-darwin-build-2
Fix build with bazel on OSX attempt 2 (add stub for host_cgo.go)
7 years ago
Tatiana Borisova 945c2f41de Fix host_cgo file 7 years ago
Tatiana Borisova a271cb7c1c Fix package name in host_cgo.go 7 years ago
shirou a97abd3450
Merge branch 'master' into feature/add_context_support 7 years ago
shirou d1fb05a30b Skip some test if CircleCI. 7 years ago
shirou cd61c36c4f
Merge branch 'master' into feature/add_context_support 7 years ago
shirou 8b2468f1e7 Merge branch 'master' of github.com:shirou/gopsutil into feature/lxd_boot_time 7 years ago
shirou 4c73494c78 Add WithContext functions. 7 years ago
Lomanic e3ae39aa5b Fix #442, trim sensor names and properly handle CentOS in host.SensorsTemperatures() 7 years ago
Tatiana Borisova 1be443f398 Fix build attempt 3 (add stub for host_cgo.go) 7 years ago
leaf 65598d98cc To prevent hang if wmi.Query hangs, add a context-aware wrapper for it. 7 years ago
shawnps befc2c3d92 call Fatal if length of Users() is 0 7 years ago
shirou dc3a09c1d0 [host] linux: change file if in a lxc container. 8 years ago
Daniel Nelson df2f1a8dd1
Add HOST_VAR envvar and use to locate utmp on Linux. 8 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
Yoshio HANAWA a889bcce1a Add type definitions for mips and mipsle 8 years ago
WAKAYAMA Shirou 114c78c777 [host]: add not implemented methods. 8 years ago
WAKAYAMA Shirou 9c5b318e0d [host] windows: define Virtualization() 8 years ago
Sean Chittenden 42a72cbfae
Add HostID support to the `solaris` build target. 8 years ago