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

83 Commits

Author SHA1 Message Date
shirou
37f531010d fix golangcilint errors, ignore gosec G115 2024-08-23 08:22:42 +00:00
shirou
e9591b5b01 rename redundant test function names, such as TestCPU in cpu package 2024-05-28 22:27:17 +09:00
shirou
bc060cc227 add SPDX License, remove old build tag, and replace import 2024-05-28 22:27:17 +09:00
shirou
83427f964f [process][darwin]: skip process.Nice test if darwin on GitHub Action
fix: https://github.com/shirou/gopsutil/issues/1532
2023-10-07 13:27:39 +00:00
Matthieu MOREL
c806740b34
ci(lint): ensure io/ioutil replacement (#1525)
* ci(lint): enure ioutil replacement

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

* Update host_solaris.go
* Update process_linux_test.go
* Update net_linux_test.go
* Update net_linux_test.go
* Update process_test.go
* Update process_linux_test.go
* Update process_linux_test.go

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-09-12 21:14:04 +09:00
shirou
0665cafa1b chore: replace deprecated ioutil package to os and io 2023-09-08 17:05:14 +00:00
shirou
febdeab871 chore: change CIRCLECI environment variable to CI. 2023-08-30 14:07:47 +00:00
Antoine Toulme
6fff1c0e99
proper benchmark 2023-08-27 09:42:51 -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
Lomanic
8b96d2e9e2 [process][posix] Realign process.Name() with python psutil to return same value on python3 scripts processes
e2c79a1 started to blindly set the process name to the full path (instead of the basename) of the cmdline exectuable
if the process name from the process comm was truncated on linux. Python psutil never did that, and this is just wrong
for python (or any executable interpreted script) where the process name is not the interpreter binary but the script
itself.

A new test to check process name value against psutil value is added here, which would hopefully catch any potential
future changes in psutil.

Reverts #542

Fixes #1485
2023-07-09 00:43:24 +02:00
Lomanic
c0f3eb1dfb [process] Remove all noisy and useless Test_AllProcesses_X tests
These tests can't fail more than their invidiual counterparts and produce an incredibly verbose output
2023-07-01 14:44:04 +02:00
Matthieu MOREL
1fb1e3e3e6 ci(lint): correct gci linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-04-04 18:07:22 +00:00
Lomanic
980cc82c08 [process][windows] Retrieve process name as basename of executable
We align ourself with psutil
8e4099d9f0/psutil/_pswindows.py (L749-L759)

Benchmarks show vast improvements

    go test -run=BenchmarkProcessName -bench=BenchmarkProcessName ./process
    goos: windows
    goarch: amd64
    pkg: github.com/shirou/gopsutil/v3/process
    cpu: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
    BenchmarkProcessName-4               180           6564033 ns/op
    BenchmarkProcessNameViaExe-4       22111             51153 ns/op
    PASS
    ok      github.com/shirou/gopsutil/v3/process   3.914s

Fixes #1368
2022-10-22 21:43:23 +02:00
Pierre Fersing
60eae48e6a Drop test for Darwin Pids() 2022-01-13 13:27:05 +01:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00: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
shirou
0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
shirou
0ce33dbe64
Merge pull request #1166 from easyops-cn/kestrel/process
feat(process): implement the 'OpenFilesWithContext' function of the windows system
2021-11-13 20:51:25 +09:00
kestrelcjx
5832fdfb9b chore(process): open file in process test case 2021-10-29 20:20:23 +08:00
Max Altgelt
a4679b798b
feat: Add support for Cwd() on Windows 2021-10-27 09:55:26 +02:00
shirou
7be7e7807f [process] extend maxElapsedTime on process_test 2021-09-30 07:47:05 +00:00
Tom Barker
9248140c98 Wait for server connection to be established before checking
connections.
2021-08-23 16:30:51 -04:00
Tom Barker
bc4661937d Minor cleanups motivated by staticcheck warnings. 2021-08-19 10:43:06 -04:00
Tom Barker
5ce887df8f Make sure that Test_AllProcesses_cmdLine doesn't ignore failures. 2021-08-19 10:43:06 -04:00
Tom Barker
34cdfa258b Test_Connections currently fails intermittently on Linux (and maybe
other OSs), and fails consistently if run with `go test -times=N`

On inspection, Go closes TCP connections when they go out of scope and
are garbage collected. I've re-written Test_Connections() to explicitly
close connectections once the test has finished. This has the other
benefit of closing gracefully, which means the -times argument should
work.

I've also removed the t.Skip() calls inside goroutines as they are
unsupported.
2021-08-19 10:40:27 -04:00
Max Altgelt
73fee847e6
chore: add tests
Add simple tests to verify that environment variables are read.
2021-07-13 16:38:49 +02:00
Max Altgelt
b02b92e16b
feat: Add support for environment variable read
Add support (for Linux and Windows for now) for reading the
environment variables of a process, with a similar syntax to
os.Environ().
For Windows, this includes some refactoring for clean access to the
RTL_USER_PROCESS_PARAMETERS structure which points to the command
line and the environment variables.
2021-07-13 15:11:29 +02:00
John Blesener
e8b2bea47f
Fix spaces on long process names for MacOS 2021-02-16 14:51:44 +09:00
Lomanic
995610e109 [process][windows] Fix Nice() test expecting Unix values 2020-11-08 17:13:56 +01:00
Lomanic
eaa34817d0 [process] Add benchmarks for New(), Name() Ppid()
run only them with: go test -bench=. -run=xxx github.com/shirou/gopsutil/process
2020-10-01 10:24:54 +02:00
Lomanic
64ba9d03cd [process] Properly test Ppid() against known value 2020-09-29 23:58:34 +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
shirou
7e94bb8bcd
Merge pull request #775 from TakayukiBGoto/add_additional_gids_support
[Process] Implement Groups() to get additional gids.
2020-07-24 22:09:41 +09:00
Mauro Leggieri
00957cfedc Fixed slow command line retrieval on Windows 2020-04-30 22:44:43 -03:00
Lomanic
e7090ba9fc [process] Fix Test_Children test regression because of some other running test 2019-12-01 20:24:34 +01:00
Lomanic
1fcea92f73 [process] Skip if not implemented Test_IsRunning (for openbsd) 2019-12-01 19:31:54 +01:00
Lomanic
e4f087a4af [process] Test process.Name() with long names #795 2019-12-01 19:31:48 +01:00
TakayukiB Goto
9c6cedb822 [Process] Fix typo 2019-10-24 18:48:28 +09:00
TakayukiB Goto
f55f202e81 [Process] Implement Groups() to get additional gids. 2019-10-07 12:59:36 +09:00
Lomanic
547679f88e [process] Fix #760 implement IsRunning by checking process with same PID has same CreateTime as current process 2019-09-07 18:54:49 +02:00
Lomanic
f09ba75b25 [process] Skip tests on non-implemented platforms #446 and fix Kill/Children tests on windows 2019-09-05 18:48:00 +02:00
Lomanic
f49203762b [process] Fix Connections() test with goroutines listening/connecting on TCP 2019-09-05 11:07:08 +02:00
mingrammer
64a995aad4 Refactor with gofmt 2019-03-23 21:57:24 +09:00
mingrammer
017c9f9cbc Fix typos 2019-03-18 02:52:26 +09:00
shirou
a33a26bd97
Merge pull request #567 from tagirb/grouped_memorymaps
implement grouped memorymaps output
2019-01-13 17:17:11 +09:00
Iskander Sharipov
f3d4342c30 cpu,process: remove commented-out code
Found using https://go-critic.github.io/overview#commentedOutCode-ref
2018-09-13 23:56:24 +03:00
Tagir Bakirov
29b3c3719b fix slice indices 2018-08-14 09:12:09 +02:00
Tagir Bakirov
47166d6a81 implement grouped memorymaps output 2018-08-08 09:37:17 +02:00