Commit Graph

280 Commits (8e62971eb00075ea39feffab28e40cdb2dd550ae)

Author SHA1 Message Date
Guoqi Chen b793d83f72 host: add support for linux/loong64
Updates #1338.

Signed-off-by: Guoqi Chen <chenguoqi@loongson.cn>
Co-authored-by: Jiantao Shan <shanjiantao@loongson.cn>
2 years ago
Jeff Erbrecht a5ecb9bca5 [host] windows: use millisecond precision for BootTime()
Previously, system uptime is truncated to seconds, and then the
subtraction from `time.Now()` is performed. Because uptime does not roll
over to the next second at the same instant as `time.Now()`, then
`BootTime()` ends up not being precise, and often varies by 1 second.

This commit does the subtraction before truncating to seconds, which
results in a significantly lower chance of variance in `BootTime()`.
2 years ago
Don Bowman d7f1f76519
[host] linux/ppc: ppc64 definition from ppc64le
Same as commit fc04d2d, but for ppc64 from ppc64le definition.
2 years ago
Tobias Klauser f9a5834e0e
host: use unix.ByteSliceToString
Use ByteSliceToString provided in golang.org/x/sys/unix to convert
\0-terminated byte slices to strings.
2 years ago
shirou 5473fd114d [disk][host]: change to use type alias. 2 years ago
shirou 4ac7e99c6a [disk][host]: move back Warnings from internal to disk and host.
fix #1377
2 years ago
shirou 68452e2602 feat(host, windows): add UBR (Update Build Revision) to kernel version 2 years ago
Antoine Toulme dbc0f20fe3 code review 2 years ago
N1neSun add9158d4e fix some kylin linux bug 3 years ago
shirou ed37dc27a2
Merge pull request #1335 from tklauser/drop-darwin-386
host, process: delete darwin/386 code
3 years ago
Stuart Caie e0400cc94f Use 0 as default mach port 3 years ago
Tobias Klauser c76712b8da
host, process: delete darwin/386 code
The darwin/386 port was dropped in Go 1.15 and the imported version of
golang.org/x/sys also no longer supports the port. This module requires
at least Go 1.15 per go.mod, so it no longer builds on darwin/386
anyway.
3 years ago
Stuart Caie 55411f1178 Replace IOMainPort/IOMasterPort() and kIOMainPortDefault/kIOMasterPortDefault with NULL 3 years ago
shirou 5610fbc5d5 fix(host,linux): Check if path exists and is nonempty before reading host files 3 years ago
yueyt 15354cbdee add neokylin host info on linux 3 years ago
Martin Reindl 1d89235f34 host: add support for OpenBSD/armv7 3 years ago
Ville Skyttä f7e1f36418 refactor: remove unnecessary exec.LookPath calls
Executing the command does the lookup if needed and returns the same
error when not found, no need to do it separately.
3 years ago
Ville Skyttä 7a8feb155b [host][solaris] implement SensorsTemperaturesWithContext 3 years ago
Lammert Hellinga 001699bed7 Let almalinux be part of the rhel family 3 years ago
Matthieu MOREL 4671e649aa
enable revive linter 3 years ago
mmorel-35 1e6b445a8a gofumpt 3 years ago
mmorel-35 eb5f6203d8 gofmt 3 years ago
shirou b1186a68ed
Merge pull request #1191 from shirou/feature/update_mac_cgo
[disk][host][mac] fix deprecated code in macOS Monterey
3 years ago
Matthieu MOREL b673968d5d
enable errorlint linter 3 years ago
shirou 4c3edcfe56 [mac] fix deprecated code in macOS Monterey 3 years ago
shirou d2e27c1712 fix dependabot v2 deletion. 3 years ago
shirou 0969c9436b delete v2 directory, move v3 to top #1078 3 years ago
shirou 0fdf65fa3e Change to use yusufpapurcu/wmi from StackExchange/wmi. 3 years ago
shirou e032a1c81d
Merge pull request #1059 from d1ss0nanz/issue1058
use ioreg to read IOPlatformUUID as HostID
3 years ago
Lars Meyer a7d936d0a4 [host][windows] Fix Windows 11 reporting
While ProductName remains "Windows 10", versions with Build no. >= 22000
are Windows 11.
3 years ago
odinje a3e22baec0 Ensure rhel platform family for Rocky Linux 4 years ago
shirou 2782a109dc
Merge pull request #1010 from gdbinit/openbsd-wrong-users-number-patch
Fix wrong OpenBSD user count
4 years ago
Daniel Stutz 9916462c47 use ioreg to read IOPlatformUUID as HostID 4 years ago
Guillaume Ballet 992d17af94 add support for OpenBSD arm64 4 years ago
Mykola Terelia 84e8e51bf9 Added missing distributions to the suse platform family 4 years ago
fG! ab33d5ec89
Fix wrong user count
There are empty entries in OpenBSD's utmp that have a line and time entry but no user logged in (the entry is "cleared" after user logs out but not totally as expected in the code here). Current checks are insufficient so check if Name field is empty and skip in that case.
4 years ago
shirou f377a07e5a fix test and openbsd errors. 4 years ago
Ryan Fitzpatrick 8046134504
Fix VirtualizationWithContext() race in linux 5 years ago
shirou 6c9f3bdcae [host][linux] Change to use unix.SysInfo_t to get Uptime in Linux 5 years ago
Sergey Vinogradov 5209442b3c Refactor "host" package 5 years ago
Lomanic 8a625ec054 [host][process][darwin] Go-fmt code from mktypes.sh from #917 5 years ago
Lomanic 2e4fcbb8c4
Merge pull request #917 from amdprophet/darwin-arm64
Add support for Darwin/ARM64
5 years ago
Lomanic 4cfc60d68b
Merge pull request #928 from Lomanic/skip-tests-when-not-implemented 5 years ago
Lomanic e1925b853e
Merge pull request #935 from Lomanic/issue900
[linux] Fix #900, skip or fix failing tests in docker
5 years ago
Lomanic 1b3e0c6643 [linux] Fix #900, skip or fix failing tests in docker
TestGetProcInodesAll: create a server so there are some opened inodes
TestUsers: skip if Users is empty, because of an empty /var/run/utmp
Test_Process_Groups: skip if Groups is empty
TestConnectionsMax: skip on CI, not only CircleCI
5 years ago
Lomanic 84afaae670 [host][mem][process][openbsd] Add 386 const and types definitions
Continuation of #721, this type using mktypes.sh that I didn't know at the time.
Weirdly, `go tool cgo -godefs` doesn't produce propery go-fmt-ed code, had to do run go-fmt manually afterwards.
5 years ago
Lomanic 8110480793 [host] Skip tests on non-implemented platforms #446 5 years ago
Justin Kolberg 53ffb0cece Add support for Darwin/ARM64
Signed-off-by: Justin Kolberg <amd.prophet@gmail.com>
5 years ago
Tobias Klauser 28890b0482 Use common implementation for BootTime/Uptime on all BSDs
All BSDs use the same implementation to get BootTime{,WithContext} and
Uptime{,WithContext} based on the kern.boottime sysctl. Move this
implementation to a separate host/host_bsd.go file shared by darwin,
freebsd and openbsd. Also use SysctlTimeval to get
the boot time directly as a type Timeval instead of manually
extracting it using package unsafe. It will also allow for easier reuse
to support package host on e.g. Dragonfly BSD or NetBSD.

This requires updating the golang.org/x/sys/unix dependency to the
latest revision.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years ago
Tobias Klauser 1e61ed79fa host: add support for linux/riscv64 5 years ago
Lomanic 42c6875555 [host][darwin][cgo] Fix #832 work around once-again broken go modules not including C files
Supersedes #885 by @afontaine
5 years ago
shirou a81cf97fce
Merge pull request #861 from Lomanic/issue391
[host][linux] Fix #391 retrieve sensors temps on OSes lacking hwmon
5 years ago
Tobias Klauser 7bee6a934d host: fix TestHostInfoStat_String
TestHostInfoStat_String has been broken since kernelArch has been
introduced. Fix it.

Also adjust the error message to show the wanted string, aligned with
the gotten string so it's easier to spot differences.
5 years ago
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.
5 years ago
shirou f4fc0580b8
Merge pull request #802 from dmgk/master
Add support for freebsd/arm64
5 years ago
Dmitri Goutnik 270f6afc22
Add support for freebsd/arm64 5 years ago
Alessandro De Angelis b7ac341eac fix compilation warnings 5 years ago
Alessandro De Angelis 65a2e0e9bb Restored temperature info for macOS 5 years ago
Lomanic c58a1e8ec7 [host][linux] Fix #391 retrieve sensors temps on OSes lacking hwmon 6 years ago
Aman Gupta 25be4d08fe
Trim null bytes from kernel arch 6 years ago
Aman Gupta 62a406ec1b
Trim null bytes from kernel version 6 years ago
shirou 8a5bcfdb53
Merge pull request #739 from Lomanic/issue738
[host][linux] Fix #738 use uname syscall to get version in KernelVersion()
6 years ago
Lomanic 4bf185067d [host] Fix #737 add KernelArch field in InfoStat struct returning 'uname -m' result 6 years ago
Lomanic 98c779765f [host] go-fmt and propagate context on Windows in Info() 6 years ago
Lomanic 8c28c3ba17 [host][linux] Fix #738 use uname syscall to get version in KernelVersion() 6 years ago
Lomanic 9219f16f03 [host][linux] Fix #340 return Solus OS as from the "solus" PlatformFamily in Info() 6 years ago
WAKAYAMA shirou 669b2710bf [freebsd]host: change freebsd struct for 386 and arm. 6 years ago
WAKAYAMA shirou 2fd3f03f84 [freebsd][host]: fix Users() return start secs. 6 years ago
shirou a83baef6e4
Merge pull request #698 from picatz/fix-platformFamily-on-macOS
Update host_darwin.go
6 years ago
shirou 7c2ac48f84
Merge branch 'master' into td-remove-cycle 6 years ago
shirou 3d9d5e60ef
Merge pull request #688 from asnowfox/master
use /proc/buc/pci/devices to identify a VM is a guest
6 years ago
shirou d8686bcd5c
Merge pull request #675 from marcv81/fix_665_v2
Fix for #665
6 years ago
Kent 'picat' Gruber e507f44421 Update host_darwin.go
Copy+pasta got me again! 🍝

No new variable on the left of `:=` 😂
6 years ago
Kent 'picat' Gruber d13ba02ef0 Update host_darwin.go
The /System/Library/CoreServices/ServerVersion.plist exists on macOS servers , but not on a workstation such as my laptop. The actual terminoly is mostly borrowed from the windows equivalent as @Lomanic suggested. In theory, this should make interpreting the results from the two platforms a bit more consistent.

Note: The macOS server application can be installed on almost any macOS workstation to make it a server that can manage other apple devices.
6 years ago
Lomanic 3af6e1ffe7 [host][linux] Properly handle double quotes in /etc/os-release in PlatformInformation 6 years ago
Arturo Reuschenbach Puncernau 2a0b67d19c added sles to the suse platform family 6 years ago
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.
6 years ago
litong 6dfd8d56bb Merge branch 'master' of https://github.com/asnowfox/gopsutil 6 years ago
litong 119f26c1df use bus/pci/devices to identify a vm guest 6 years ago
Snow Fox 0cad0faa11
Merge pull request #1 from shirou/master
merge master
6 years ago
litong 12005ab922 use /proc/bus/pci/devices to idenetify a kvm guest 6 years ago
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.
6 years ago
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)
		}
	}
6 years ago
mingrammer 017c9f9cbc Fix typos 6 years ago
Lomanic 27ec6a0789 [host][linux] Remove call to sysctl binary in host/host_linux.go #639 6 years ago
Lomanic 7e9e36b568 [host][openbsd] Remove calls to sysctl binary in host/host_openbsd.go #639 6 years ago
Lomanic d110536e10 [host][darwin] Remove calls to sysctl binary in host/host_darwin.go #639 6 years ago
Lomanic 738b966ed1 [host][darwin] Use unix.Sysctl to get kernel version and platform name 6 years ago
Lomanic 8294f67566 [host][openbsd] Remove external calls to uname in PlatformInformation() 6 years ago
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