1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

79 Commits

Author SHA1 Message Date
shirou
a81cf97fce
Merge pull request #861 from Lomanic/issue391
[host][linux] Fix #391 retrieve sensors temps on OSes lacking hwmon
2020-05-01 22:02:23 +09:00
Tim Gross
c69ef749eb fix host.Info() panic if /etc/debian_version is empty
The ReadLines helper function doesn't guarantee that the length of
lines is non-zero or that the lines have contents. Most callers
include a check for length but this was missing for version
fingerprinting on Debian if `/etc/debian_version` was empty, leading
to a panic.
2020-01-17 14:23:27 -05:00
Lomanic
c58a1e8ec7 [host][linux] Fix #391 retrieve sensors temps on OSes lacking hwmon 2019-08-18 20:48:31 +02:00
Aman Gupta
62a406ec1b
Trim null bytes from kernel version 2019-08-12 13:30:54 -07:00
shirou
8a5bcfdb53
Merge pull request #739 from Lomanic/issue738
[host][linux] Fix #738 use uname syscall to get version in KernelVersion()
2019-08-11 21:57:14 +09:00
Lomanic
4bf185067d [host] Fix #737 add KernelArch field in InfoStat struct returning 'uname -m' result 2019-08-08 23:11:41 +02:00
Lomanic
8c28c3ba17 [host][linux] Fix #738 use uname syscall to get version in KernelVersion() 2019-08-03 18:36:36 +02:00
Lomanic
9219f16f03 [host][linux] Fix #340 return Solus OS as from the "solus" PlatformFamily in Info() 2019-07-11 22:18:40 +02:00
shirou
7c2ac48f84
Merge branch 'master' into td-remove-cycle 2019-06-01 11:26:59 +09:00
shirou
3d9d5e60ef
Merge pull request #688 from asnowfox/master
use /proc/buc/pci/devices to identify a VM is a guest
2019-06-01 11:18:40 +09:00
shirou
d8686bcd5c
Merge pull request #675 from marcv81/fix_665_v2
Fix for #665
2019-06-01 10:28:14 +09:00
Lomanic
3af6e1ffe7 [host][linux] Properly handle double quotes in /etc/os-release in PlatformInformation 2019-05-31 18:04:45 +02:00
Arturo Reuschenbach Puncernau
2a0b67d19c added sles to the suse platform family 2019-05-24 11:33:07 +02:00
Tyler Dixon
a02925055c Remove cycle between process and host packages
gopsutil is a transitive dependency of another project that I am integrating
into an internal build system. We target multiple platforms and as a part
of the build system for the large internal repo, we calculate the build
graph used to determine what targets have changed and need to be build /
tested as a single DAG for all platforms.

gopsutil currently does not form a DAG if linux and any other platform are
considered at the same time. linux is the only platform where the process
package imports the host package.

To remove this cycle, the relevant methods have been moved to internal/common
with the linux build tag and are consumed the host and process packages.
2019-05-22 17:45:50 -07:00
litong
6dfd8d56bb Merge branch 'master' of https://github.com/asnowfox/gopsutil 2019-05-22 11:02:14 +08:00
litong
119f26c1df use bus/pci/devices to identify a vm guest 2019-05-22 11:01:09 +08:00
Snow Fox
0cad0faa11
Merge pull request #1 from shirou/master
merge master
2019-05-22 10:46:50 +08:00
litong
12005ab922 use /proc/bus/pci/devices to idenetify a kvm guest 2019-05-06 07:18:49 +08:00
Segflow
86c7289ccc Fix: use filename in exec.LookPath instead of full path
exec.LookPath searches for the file in the $PATH, which mean giving it an absolute path is against it's own purposes.
2019-05-05 20:45:07 +01:00
Marc
174b31f146 Fix for #665
Remains backward compatible.

When encountering non-fatal errors SensorsTemperatures() returns the
temperatures for all the sensor we could read successfully. In that
case the custom error contains a list of all the non-fatal errors
encountered.

Example usage:

	_, err := SensorsTemperatures()
	if err != nil {
		warns, ok := err.(*Warnings)
		if ok {
			fmt.Printf("%v\n", err)
			for i, w := range warns.List {
				fmt.Printf("Warning %v: %v\n", i+1, w)
			}
		} else {
			t.Errorf("%v", err)
		}
	}
2019-04-26 23:15:23 +08:00
mingrammer
017c9f9cbc Fix typos 2019-03-18 02:52:26 +09:00
Lomanic
27ec6a0789 [host][linux] Remove call to sysctl binary in host/host_linux.go #639 2019-03-02 23:22:53 +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
Ozair Jr
0bab9611d2 Adding Slackware platform information 2018-07-25 10:17:08 -03:00
Lomanic
1b47825dcb [host] Fix docker uptime parsing (fix #507) 2018-04-06 10:11:58 +02:00
linuxhe
ee5d6a3d8f fix docker uptime 2018-03-13 14:46:16 +08:00
shirou
28f7cb0d63 [host] linux: use uptime even if docker guest. 2018-03-11 13:22:13 +09: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
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
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
Frank Schroeder
a9e803ef6a
Fix data race in host.BootTime 2017-06-01 18:11:14 +02:00
Shirou WAKAYAMA
cdcb9bb2ed [linux] host: fix typo 2017-04-22 17:06:35 +09:00
WAKAYAMA Shirou
25d50d5bc3 [linux]host: change to use filepath.Join 2017-04-22 17:02:33 +09:00
Shirou WAKAYAMA
fee973abda [linux]host: fix HostTempreture func 2017-04-10 22:06:37 +09:00
shirou
8e36fe6d8f Merge pull request #334 from dotpy3/macos-linux-temperatures
Added temperatures sensors for macOS and Linux
2017-04-10 21:54:07 +09:00
itnihao
490dbd4ea4 Add hostinfo Virtualization vmware 2017-03-25 00:19:22 +08:00
Eric Gourlaouen
22aefb460a Replaced sys by HostSys
Added TemperatureStat string test
2017-03-20 19:01:28 +01:00
Eric Gourlaouen
8b08ca5fdc added temperatures 2017-03-19 02:08:19 +01:00
tycho garen
22c56d292e close open files 2017-02-22 08:46:23 -05:00
Sean Chittenden
36f5033d97
Unconditionally lowercase the HostID from all supported platforms. 2017-02-06 16:10:46 -08:00
Conor Branagan
5afd6f21c9 Cache the boot time after first query.
When fetching stats on all processes at once there's a non-trivial amount of
time spent in the `BootTime` call. But since this value should never change
during a live process, we can use a cached version for all subsequent calls.
2016-10-13 11:24:29 -04:00
Lukas Fittl
13aedadcde Add separate kernelVersion field to host information.
This is mostly intended for Linux, where we are returning the OS version
in the PlatformVersion field, which seems reasonable. Often it is still
useful to know which Linux kernel is running.

For FreeBSD and Darwin the kernel version matches the platform version,
since they previously used the kernel version for the platform version.

For Windows the kernel version is empty, since there is no clear way
to determine it.
2016-08-22 14:15:30 -07:00
Sean Chittenden
d490d634ca
On Linux, attempt to read from /sys/class/dmi/id/product_uuid first
before falling back to kernel.random.boot_id.

`/sys/class/dmi/id/product_uuid` is still managed by permissions, so
for root-run processes where `/sys/class/dmi/id/product_uuid` is
available, the host's UUID will be used instead, otherwise the UUID
from kernel.random.boot_id will be used instead.
2016-08-11 01:29:46 -07:00
Sean Chittenden
59094cd5b7
Add HostID to the Host InfoStat struct returned from host.Info().
On supported hosts the value returned is a UUID (case preserving
from the value of the underlying OS).

For Linux this is generated once, randomly per boot.  For FreeBSD and
Darwin this is a more durable value that should persist across reboots.
2016-08-11 00:51:07 -07:00