You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gopsutil/host
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
7 years ago
..
host.go Use static initialisation for invoke instances, instead of init funcs 7 years ago
host_darwin.go [host][darwin] Fix #574, use 'uname -r' in KernelVersion() 7 years ago
host_darwin_386.go Add Go-native structs for Darwin/386 and FreeBSD/arm 9 years ago
host_darwin_amd64.go [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters 9 years ago
host_fallback.go [host] fallback: implement PlatformInformation() 7 years ago
host_freebsd.go Eliminate call to uname on FreeBSD 7 years ago
host_freebsd_386.go [host]freebsd: add freebsd_386. 9 years ago
host_freebsd_amd64.go [host]freebsd: update freebsd_amd64 9 years ago
host_freebsd_arm.go Add Go-native structs for Darwin/386 and FreeBSD/arm 9 years ago
host_linux.go Have a real fixed HostID on Linux 7 years ago
host_linux_386.go [host]linux: forgot to add sizeOfUtmp. 9 years ago
host_linux_amd64.go [host]linux: fix i386 and gofmt. 9 years ago
host_linux_arm.go [host]linux: fix i386 and gofmt. 9 years ago
host_linux_arm64.go Add type definitions for arm64 and ppc64le 9 years ago
host_linux_mips.go Add type definitions for mips and mipsle 8 years ago
host_linux_mips64.go [host]linux/mips: copy mips64 definition from mips. 7 years ago
host_linux_mips64le.go [host] linux/mips: mips64le definition from mipsle 7 years ago
host_linux_mipsle.go Add type definitions for mips and mipsle 8 years ago
host_linux_ppc64le.go [host]Windows: BootTime and Uptime are reversed on Windows. 9 years ago
host_linux_s390x.go add platform compatibility 9 years ago
host_linux_test.go change package name. 11 years ago
host_openbsd.go change to use CommandContext. 7 years ago
host_openbsd_amd64.go run go fmt ./... 9 years ago
host_solaris.go change to use CommandContext. 7 years ago
host_test.go host: remove empty virtualzation check. 7 years ago
host_windows.go [host][windows] Remove exported wmi type from #550 7 years ago
types_darwin.go host: Users() on darwin works. but Started is not correct. 11 years ago
types_freebsd.go [host]freebsd: update freebsd_amd64 9 years ago
types_linux.go [host]linux-arm: update type_liux.go. Test will fail. 9 years ago
types_openbsd.go run go fmt ./... 9 years ago