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

137 Commits

Author SHA1 Message Date
shirou
37f531010d fix golangcilint errors, ignore gosec G115 2024-08-23 08:22:42 +00:00
shirou
1221983189 [windows][mem]: change to use Performance Counter on SwapMemory. 2024-07-21 16:21:06 +09:00
Niv Govrin
97351d2736 fix: remove tab in empty line 2024-06-06 09:36:24 +00:00
Niv Govrin
b6c524eda4
Merge branch 'shirou:master' into patch-1 2024-06-06 11:48:35 +03:00
shirou
bc060cc227 add SPDX License, remove old build tag, and replace import 2024-05-28 22:27:17 +09:00
Niv Govrin
aa0b73dc6d
fix: return boot time from stat file
add missing return statement for boot time value retrieved from stat file. Also move current time fetch to be closer to where the "time since boot file" is read
2024-05-26 11:48:29 +03:00
camcui
3ec3f55280 chore: fix some typos in comments
Signed-off-by: camcui <cuishua@sina.cn>
2024-04-12 15:00:55 +08:00
shirou
9de1a429b9
Merge pull request #1585 from DataDog/bryce.kahle/os-release-version-id
use VERSION_ID from os-release
2024-01-21 11:14:24 +09:00
Bryce Kahle
d753f78612
use VERSION_ID from os-release
`VERSION_ID` is more appropriate for scripts and other usages, since `VERSION` can contain spaces and codenames

from `os-release` manpage:
```
VERSION=
           A string identifying the operating system version, excluding
           any OS name information, possibly including a release code
           name, and suitable for presentation to the user. This field
           is optional.

           Examples: "VERSION=17", "VERSION="17 (Beefy Miracle)"".

 VERSION_ID=
           A lower-case string (mostly numeric, no spaces or other
           characters outside of 0–9, a–z, ".", "_" and "-") identifying
           the operating system version, excluding any OS name
           information or release code name, and suitable for processing
           by scripts or usage in generated filenames. This field is
           optional.

           Examples: "VERSION_ID=17", "VERSION_ID=11.04".
```
2024-01-18 10:34:34 -08:00
Bryce Kahle
b0d976c49b
ensure host platform are files and have contents
In a containerized deployment, it is common to mount several files from /etc. Within the container, those files will be created regardless if they exist on the host or not. In those instances, the existing code would erroneously return empty platform information.
2024-01-18 10:21:42 -08:00
shirou
b10acd4894 [host]: add EnableBootTimeCache function 2024-01-11 00:49:11 +09:00
Justin Yang
7ffb24dbe3
Merge branch 'shirou:master' into feature/netbsd-arm64-port 2023-09-23 16:02:34 +08:00
Justin Yang
4a46201e00 cpu && host: fix compile time errors 2023-09-16 17:44:58 +08:00
shirou
0665cafa1b chore: replace deprecated ioutil package to os and io 2023-09-08 17:05:14 +00:00
Antoine Toulme
4ed0f1436a
return err if not EOF 2023-08-25 14:39:29 -07:00
Antoine Toulme
ca71a6db3c
lint 2023-08-25 14:38:11 -07:00
Antoine Toulme
4bc9e37b0f
faster file read 2023-08-25 13:54:26 -07:00
Antoine Toulme
842e4da755 apply code review 2023-06-02 01:31:05 -07:00
Antoine Toulme
177e1b1982 remove deprecation comments 2023-06-02 01:31:05 -07:00
Antoine Toulme
0cbdf257ab change to use a typed map per code review 2023-06-02 01:31:05 -07:00
Antoine Toulme
5b9212e240 move the Env key out of internal packages 2023-06-02 01:31:05 -07:00
Antoine Toulme
38b94668ea allow to pass context values to override environment variables 2023-06-02 01:31:05 -07:00
shirou
3e789a459a [common]: fix potential leak on Sleep. 2023-05-28 12:32:10 +00:00
shirou
852f455217 fix lint 2023-02-12 09:24:52 +00:00
Ville Skyttä
70a8f589c6 Detect Docker also using /.dockerenv 2022-12-28 23:12:58 +02:00
Eng Zer Jun
37894e9b28
test: use T.Setenv to set env vars in tests
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-12-20 13:13:01 +08:00
Aman Gupta Karmani
34cc43d282
[android][host] fix Info() failure due to forbidden /proc/stat and /proc/uptime (#1361)
* [android][host] fallback to sysinfo() syscall for uptime

with Android O, /proc/{stat,uptime} both return permission denied
2022-11-19 04:17:18 +01:00
shirou
769daafb9e
Merge pull request #1347 from atoulme/windows_errors
Return all Windows partitions
2022-10-09 12:55:42 +09:00
Antoine Toulme
dbc0f20fe3 code review 2022-10-03 13:55:14 -07:00
shirou
16b3aac6ad
Merge pull request #1336 from johanburati/job043
Add hostinfo Virtualization hyperv
2022-09-30 17:33:58 +09:00
Ties de Wit
f253d81d1b
Update common.go 2022-09-01 09:18:20 +02:00
Johan Burati
e7034b47f2 Add hostinfo Virtualization hyperv 2022-08-02 16:23:43 +09:00
shirou
839e8b731f fix(common): simplify size check 2022-07-19 12:43:41 +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
shirou
80c890dc4c fix(host,linux): when platform is detected to be 'amazon' cleanup os-release ID 2022-07-12 09:53:22 +00:00
shirou
f11e3ba120 fix(net,linux): move IsLittleEndian to internal 2022-07-04 08:41:25 +00: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
Matthieu MOREL
b0469a470b
Merge branch 'master' into master 2022-02-01 19:28:26 +01:00
Ville Skyttä
1e56c6f421 Spelling and grammar fixes 2022-01-30 22:48:09 +02:00
Matthieu MOREL
8ba220d241 enable contextcheck linter 2022-01-24 09:26:50 +01:00
shirou
b4808b3e94
Merge pull request #1204 from YangKeao/fix-unstable-boottime
fix unstable boot time because of float conversion
2022-01-06 21:09:53 +09:00
shirou
2f8da0a394
Merge pull request #1205 from mmorel-35/master
enable more linters, report coverage and cache mods
2021-12-29 22:31:24 +09:00
Makazeu
521fafd945
Fix a typo in comment 2021-12-24 17:14:50 +08:00
Matthieu MOREL
851bffc0f1
enable gosec linter 2021-12-23 00:31:04 +01:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
shirou
69ea4bfdae
Merge pull request #1194 from mmorel-35/master
Enable errorlint and gci linters
2021-12-22 21:43:03 +09:00
YangKeao
1b5757b7d1 fix unstable boot time because of float conversion
Signed-off-by: YangKeao <yangkeao@chunibyo.icu>
2021-12-21 16:14:07 +08:00
wyl
5a288fb852 Fix bug for func named ReadLinesOffsetN 2021-12-20 09:07:46 +08:00
Matthieu MOREL
b673968d5d
enable errorlint linter 2021-12-04 22:29:38 +01:00
shirou
d2e27c1712 fix dependabot v2 deletion. 2021-12-01 00:12:55 +00:00