1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-04 22:17:34 +08:00

143 Commits

Author SHA1 Message Date
Lomanic
738b966ed1 [host][darwin] Use unix.Sysctl to get kernel version and platform name 2018-12-29 14:59:17 +01:00
Lomanic
8294f67566 [host][openbsd] Remove external calls to uname in PlatformInformation() 2018-12-29 14:56:23 +01:00
Pierre Souchay
890eb80501 Better comments for fallback on /etc/machine-id 2018-11-07 00:09:22 +01:00
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
2018-11-06 18:06:40 +01:00
Lomanic
18b2744df2 [host][darwin] Fix #574, use 'uname -r' in KernelVersion() 2018-09-01 17:23:39 +02:00
Ozair Jr
0bab9611d2 Adding Slackware platform information 2018-07-25 10:17:08 -03:00
Lomanic
bb518e9c4e [host][windows] Remove exported wmi type from #550 2018-07-14 18:52:10 +02:00
pytimer
62fcd00c4d [host] Implement windows temperature use wmi 2018-07-09 15:21:26 +08:00
shirou
4923bd298a host: remove empty virtualzation check.
related to #547
There is an architecture which supports no virtualization.
2018-07-05 21:54:46 +09:00
Lomanic
6c4f577e6e
Merge branch 'master' into winapihost 2018-06-23 16:44:14 +02:00
Michal Rostecki
0225d9ddcc host: Check for error object 2018-06-21 16:58:40 +02:00
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
2018-06-18 23:03:56 +02:00
Lomanic
d8a6a50129 Revert "[host][windows] Refactor code to query registry via golang.org/x/sys/windows/registry"
This reverts commit c729bbd6a8e6fd243e2f43c24666c29feb3e6294.
2018-06-18 22:17:31 +02:00
Lomanic
c729bbd6a8 [host][windows] Refactor code to query registry via golang.org/x/sys/windows/registry 2018-06-17 23:48:45 +02:00
Lomanic
eb11fd6e2f [host][windows] Completely remove slow wmi calls to retrieve OS version, use registry and RtlGetVersion 2018-06-17 23:41:32 +02:00
Lomanic
df331c7615 [host][windows] Use win32 API to get host's uptime instead of (slow) wmi 2018-06-10 18:30:22 +02:00
shirou
c95755e4bc [host]darwin: remove GPL code 2018-04-27 10:21:16 +09:00
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
2018-04-08 09:21:08 +08:00
shirou
cd915bdc31
Merge pull request #508 from shirou/issue507
[host] Fix docker uptime parsing (fix #507)
2018-04-06 17:26:13 +09:00
Lomanic
1b47825dcb [host] Fix docker uptime parsing (fix #507) 2018-04-06 10:11:58 +02:00
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.
2018-03-31 22:05:15 +09:00
shirou
145dca90f7 change to use CommandContext. 2018-03-31 21:35:53 +09:00
shirou
b99342a9ce [host] fallback: implement PlatformInformation() 2018-03-24 15:57:29 +09:00
shirou
ebe614f6e1 [solaris] host: add PlatformInformation() which is missing. 2018-03-22 00:28:00 +09:00
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.
2018-03-21 14:08:39 +00:00
linuxhe
ee5d6a3d8f fix docker uptime 2018-03-13 14:46:16 +08:00
shirou
d76e8c18d8
Merge pull request #496 from shirou/add_docker_to_use_btime
[host] linux: use uptime even if docker guest.
2018-03-12 21:39:33 +09:00
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.
2018-03-11 23:08:04 +00:00
shirou
28f7cb0d63 [host] linux: use uptime even if docker guest. 2018-03-11 13:22:13 +09:00
sada
8dd42707e2 windows: fix WithContext functions
set timeout only if parent context doesn't set.
2018-02-12 13:26:17 -08:00
CHEVY S. HUNGERFORD
29f8dfa1ad fixing SensorKey output 2018-01-27 10:11:51 -06:00
CHEVY S. HUNGERFORD
1c4fa5628c giving temperature more verbose output 2018-01-26 20:40:34 -06:00
shirou
4ac6b5b4d3 Revert "Merge pull request #470 from improbable-io/bug-darwin-build-2"
This reverts commit bb09b4e7d97d450a7836ae174cf812bbdbfe5e9d, reversing
changes made to 6a368fb7cd1221fa6ea90facc9447c9a2234c255.
2018-01-27 00:58:16 +09:00
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)
2018-01-27 00:53:26 +09:00
Tatiana Borisova
945c2f41de Fix host_cgo file 2018-01-25 18:25:11 +00:00
Tatiana Borisova
a271cb7c1c Fix package name in host_cgo.go 2018-01-25 17:39:00 +00:00
shirou
a97abd3450
Merge branch 'master' into feature/add_context_support 2018-01-09 11:34:48 +09:00
shirou
d1fb05a30b Skip some test if CircleCI. 2018-01-09 11:30:38 +09:00
shirou
cd61c36c4f
Merge branch 'master' into feature/add_context_support 2018-01-09 11:18:25 +09:00
shirou
8b2468f1e7 Merge branch 'master' of github.com:shirou/gopsutil into feature/lxd_boot_time 2018-01-09 11:16:18 +09:00
shirou
4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
Lomanic
e3ae39aa5b Fix #442, trim sensor names and properly handle CentOS in host.SensorsTemperatures() 2017-12-19 23:02:10 +01:00
Tatiana Borisova
1be443f398 Fix build attempt 3 (add stub for host_cgo.go) 2017-12-14 17:27:08 +00:00
leaf
65598d98cc To prevent hang if wmi.Query hangs, add a context-aware wrapper for it. 2017-11-20 10:13:27 -08:00
shawnps
befc2c3d92 call Fatal if length of Users() is 0 2017-11-08 13:29:49 +09:00
shirou
dc3a09c1d0 [host] linux: change file if in a lxc container. 2017-10-22 16:39:36 +09:00
Daniel Nelson
df2f1a8dd1
Add HOST_VAR envvar and use to locate utmp on Linux. 2017-10-16 14:53:14 -07:00
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.
2017-10-05 08:45:56 +01:00
Yoshio HANAWA
a889bcce1a Add type definitions for mips and mipsle 2017-08-27 02:36:33 +09:00
WAKAYAMA Shirou
114c78c777 [host]: add not implemented methods. 2017-08-03 11:08:35 +09:00