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

279 Commits

Author SHA1 Message Date
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()`.
2023-01-04 10:42:00 -05:00
Don Bowman
d7f1f76519
[host] linux/ppc: ppc64 definition from ppc64le
Same as commit fc04d2d, but for ppc64 from ppc64le definition.
2023-01-03 20:56:48 -05:00
Tobias Klauser
f9a5834e0e
host: use unix.ByteSliceToString
Use ByteSliceToString provided in golang.org/x/sys/unix to convert
\0-terminated byte slices to strings.
2022-12-07 13:14:45 +01:00
shirou
5473fd114d [disk][host]: change to use type alias. 2022-11-30 23:23:31 +00:00
shirou
4ac7e99c6a [disk][host]: move back Warnings from internal to disk and host.
fix #1377
2022-11-19 11:37:38 +00:00
shirou
68452e2602 feat(host, windows): add UBR (Update Build Revision) to kernel version 2022-11-05 20:59:15 +09:00
Antoine Toulme
dbc0f20fe3 code review 2022-10-03 13:55:14 -07:00
N1neSun
add9158d4e fix some kylin linux bug 2022-09-23 16:23:47 +08:00
shirou
ed37dc27a2
Merge pull request #1335 from tklauser/drop-darwin-386
host, process: delete darwin/386 code
2022-07-30 11:24:12 +09:00
Stuart Caie
e0400cc94f Use 0 as default mach port 2022-07-30 00:44:15 +00:00
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.
2022-07-28 13:01:59 +02:00
Stuart Caie
55411f1178 Replace IOMainPort/IOMasterPort() and kIOMainPortDefault/kIOMasterPortDefault with NULL 2022-07-25 12:19:31 +00:00
shirou
5610fbc5d5 fix(host,linux): Check if path exists and is nonempty before reading host files 2022-07-15 12:25:44 +00:00
yueyt
15354cbdee add neokylin host info on linux 2022-07-05 17:19:18 +08:00
Martin Reindl
1d89235f34 host: add support for OpenBSD/armv7 2022-04-15 21:11:36 +02:00
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.
2022-03-04 18:56:33 +02:00
Ville Skyttä
7a8feb155b [host][solaris] implement SensorsTemperaturesWithContext 2022-02-05 23:20:11 +02:00
Lammert Hellinga
001699bed7 Let almalinux be part of the rhel family 2022-01-19 22:37:51 +01:00
Matthieu MOREL
4671e649aa
enable revive linter 2021-12-22 23:49:50 +01:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
mmorel-35
eb5f6203d8 gofmt 2021-12-22 21:46:33 +00:00
shirou
b1186a68ed
Merge pull request #1191 from shirou/feature/update_mac_cgo
[disk][host][mac] fix deprecated code in macOS Monterey
2021-12-22 21:54:48 +09:00
Matthieu MOREL
b673968d5d
enable errorlint linter 2021-12-04 22:29:38 +01:00
shirou
4c3edcfe56 [mac] fix deprecated code in macOS Monterey 2021-12-04 03:37:03 +00:00
shirou
d2e27c1712 fix dependabot v2 deletion. 2021-12-01 00:12:55 +00:00
shirou
0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
shirou
0fdf65fa3e Change to use yusufpapurcu/wmi from StackExchange/wmi. 2021-11-20 11:36:30 +00:00
shirou
e032a1c81d
Merge pull request #1059 from d1ss0nanz/issue1058
use ioreg to read IOPlatformUUID as HostID
2021-10-30 17:43:32 +09:00
Lars Meyer
a7d936d0a4 [host][windows] Fix Windows 11 reporting
While ProductName remains "Windows 10", versions with Build no. >= 22000
are Windows 11.
2021-10-08 09:36:28 +02:00
odinje
a3e22baec0 Ensure rhel platform family for Rocky Linux 2021-07-21 23:04:09 +02:00
shirou
2782a109dc
Merge pull request #1010 from gdbinit/openbsd-wrong-users-number-patch
Fix wrong OpenBSD user count
2021-05-29 13:39:08 +09:00
Daniel Stutz
9916462c47 use ioreg to read IOPlatformUUID as HostID 2021-04-13 10:31:23 +02:00
Guillaume Ballet
992d17af94 add support for OpenBSD arm64 2021-03-23 15:29:27 +01:00
Mykola Terelia
84e8e51bf9 Added missing distributions to the suse platform family 2021-03-16 18:16:30 +02:00
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.
2020-12-13 00:34:27 +00:00
shirou
f377a07e5a fix test and openbsd errors. 2020-10-25 19:06:59 +09:00
Ryan Fitzpatrick
8046134504
Fix VirtualizationWithContext() race in linux 2020-10-06 17:03:49 +00:00
shirou
6c9f3bdcae [host][linux] Change to use unix.SysInfo_t to get Uptime in Linux 2020-09-19 11:12:05 +09:00
Sergey Vinogradov
5209442b3c Refactor "host" package 2020-09-11 18:54:53 +03:00
Lomanic
8a625ec054 [host][process][darwin] Go-fmt code from mktypes.sh from #917 2020-09-07 21:12:17 +02:00
Lomanic
2e4fcbb8c4
Merge pull request #917 from amdprophet/darwin-arm64
Add support for Darwin/ARM64
2020-09-07 21:10:27 +02:00
Lomanic
4cfc60d68b
Merge pull request #928 from Lomanic/skip-tests-when-not-implemented 2020-09-06 13:33:31 +02:00
Lomanic
e1925b853e
Merge pull request #935 from Lomanic/issue900
[linux] Fix #900, skip or fix failing tests in docker
2020-09-02 10:35:27 +02:00
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
2020-09-02 01:06:17 +02:00
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.
2020-09-01 02:02:21 +02:00
Lomanic
8110480793 [host] Skip tests on non-implemented platforms #446 2020-08-29 18:39:44 +02:00
Justin Kolberg
53ffb0cece Add support for Darwin/ARM64
Signed-off-by: Justin Kolberg <amd.prophet@gmail.com>
2020-08-10 21:26:24 -07:00
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>
2020-07-23 13:23:20 +02:00
Tobias Klauser
1e61ed79fa host: add support for linux/riscv64 2020-06-30 11:34:17 +02:00
Lomanic
42c6875555 [host][darwin][cgo] Fix #832 work around once-again broken go modules not including C files
Supersedes #885 by @afontaine
2020-05-31 20:40:36 +02:00