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

104 Commits

Author SHA1 Message Date
uubulb
9e6efdb991 update disk & cpu & process 2024-09-20 22:24:12 +08:00
shirou
37f531010d fix golangcilint errors, ignore gosec G115 2024-08-23 08:22:42 +00:00
shirou
5f158096be fix: golangci lint with max -> maxConn 2024-08-17 22:41:29 +09:00
shirou
85f5f3a8e2 process.Uids and process.Gids are now return uint32 2024-05-28 22:27:17 +09:00
Sergey Chernomorets
aace5e9d8f Groups in /proc/PID/status has type uint32.
Fix error of parser:
> error get info about worker process status 3150292: strconv.ParseInt:
> parsing "4294967293": value out of range

$ grep Groups /proc/self/status
Groups: 20001 [...] 4294967293
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
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
Antoine Toulme
b712e59295 fix more linting reports 2023-06-03 14:17:16 -07: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
shirou
50cad0760c
Merge branch 'master' into refactor/parentwithcontext-ppidwithcontext 2022-01-30 10:47:00 +09:00
Ville Skyttä
0306525d78 [process] implement ParentWithContext using PpidWithContext
Removes need for redundant ParentWithContext implementations. It had led
to it being unsupported on FreeBSD and OpenBSD even though
PpidWithContext was available for them, and different implementations
for getting the parent info used in ParentWithContext and
PpidWithContext on Darwin and Linux.
2022-01-22 18:27:52 +02:00
Pierre Fersing
43e50e1d7d Reduce call to ps for process package on darwin 2022-01-14 09:41:54 +01:00
Pierre Fersing
b9b3dbe67a Avoid ps command and use KProc on MacOS 2022-01-13 11:57:04 +01:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
shirou
0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
Tobias Klauser
611c8b576e process, v3/process: use SC_CLK_TCK sysconf value instead of hard-coding clock ticks
The github.com/tklauser/go-sysconf package is already a dependency used
in the cpu and v3/cpu packages to determine clock ticks using
`sysconf.Sysconf(sysconf.SC_CLK_TCK)`, see #1036. Use the same in
packages process and v3/process as well instead of hard-coding clock
ticks to 100.
2021-06-02 14:11:11 +02:00
John Blesener
07797b12d3
Make cmdNameWithContext lower-case to avoid exporting it
Signed-off-by: John Blesener <jblesener@reactivelabs.com>
2021-03-27 17:14:18 +09:00
John Blesener
e8b2bea47f
Fix spaces on long process names for MacOS 2021-02-16 14:51:44 +09:00
Lomanic
5641beec4c [process][darwin] Fix Parent() when lsof returns warnings
Same as #867, the error being:
error strconv.Atoi: parsing "      Output information may be incomplete.": invalid syntax
2020-11-08 17:13:56 +01:00
Lomanic
148a662b06 [process][darwin] Remove Groups() as it's non-functional 2020-11-08 17:13:56 +01:00
Sergey Vinogradov
065e609cbf Refactor "process" package
* All context-less wrapping functions (the ones without WithContext
suffix) were moved into process.go since they all are the same.
* Call context is now passed to all underlying functions in
*WithContext() functions.
* All common *BSD bits were moved to process_bsd.go.
* Process.Tgid() method lacked a WithContext counterpart, so
Process.TgidWithContext() was added for uniformity.
* NewProcessWithContext() function was added since NewProcess() is
used a lot throughout the module, and there is no way to pass a
context to it.

This is a part of #761 effort.
2020-10-12 18:15:29 +03:00
Lomanic
c9c40215f5 [process][darwin] Fix #925 properly with unix.SysctlRaw("kern.proc.pid", PID) 2020-09-29 23:56:25 +02:00
Lomanic
e1082dabb6 [process][darwin] Fix #925 remove references to removed const unix.SYS___SYSCTL from x/sys/unix
More like a workaround, wanted to port process.getKProcWithContext() to use unix.SysctlRaw() to get rid of exec calls to ps
in the same time but didn't have time.
2020-09-08 11:44:46 +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
Lomanic
f586a57353
Merge pull request #796 from Lomanic/issue795
[process][darwin][openbsd][freebsd] Fix #795 don't truncate process names to 16 characters
2019-12-15 23:31:26 +01:00
Lomanic
8e4dde660a [process][darwin] Fix Test_Process_Status and Status returning more than status letter 2019-12-07 00:39:46 +01:00
Lomanic
4f0e679e35 [process][darwin][openbsd][freebsd] Fix #795 don't truncate process names to 16 characters 2019-12-01 17:54:08 +01:00
TakayukiB Goto
a93796494b [Process] Define the Groups() only once 2019-10-24 18:42:13 +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
6f5b1dbee7 [darwin][process] Add cgo implementation of Exe() from PR #243
Original from ppanyukov 4473014098
2019-09-05 18:36:32 +02:00
Lomanic
3eefe64948 [process] Fix #752 sort PIDS returned by process.Pids() 2019-08-24 09:08:28 +02:00
Lomanic
3465186bca [process] Fix #729 check process existence in NewProcess() 2019-08-01 21:12:48 +02:00
Lomanic
0e0dd767df [process][darwin] Fix #670 remove call to common.Pipeline (prone to race condition)
Also properly parse lsof to get second txt record instead of hoping the 5th line is the right one (wrong data returned for pid 57)
2019-05-08 18:17:56 +02:00
Liam Xu
1b525b7c9c Return cpu time format error
Return cpu time format error
2019-03-22 11:44:52 -07:00
Liam Xu
f2f18df9db Use Swith to replace if else
Use Swith to replace if else
2019-03-22 10:21:01 -07:00
Xu Lian
6eb4d73bde Fix an indentation issues 2019-03-18 20:36:12 -07:00
Liam Xu
b3670f8027 Add hour handling in convertCPUTimes function
This commit add hour handling in convertCPUTimes function.

The time string usually comes from macOS command line:
ps -a -o stime,utime -p <pid>

which could contain hour string.
2019-03-18 15:48:08 -07:00
Lomanic
41e774419f
Merge pull request #643 from wcc526/master
Update process_linux.go for Add process ConnectionsMax
2019-02-23 21:23:09 +01:00
wcc526
462e0f6c2f Update process_linux.go for Add process ConnectionsMax 2019-02-23 18:55:31 +08:00
David Naylor
414c76f159 [process][linux] Export process page fault info
Add a function for retrieving page fault counts from /proc/[pid]/stat on
Linux.
2018-12-13 16:19:40 -08:00
Lomanic
8ef9b01052 Fix process.Foreground for BSDs, add openbsd implementation 2018-11-11 19:05:34 +01:00
Lomanic
878e0a701b Fix #596 Implement process.Background and process.Foreground functions 2018-11-08 20:52:01 +01:00
Lomanic
e38ea9f318 [process] Don't lose context in ProcessesWithContext() on Windows and Linux 2018-09-01 16:18:32 +02:00
shirou
145dca90f7 change to use CommandContext. 2018-03-31 21:35:53 +09:00
shirou
6a368fb7cd [process]: add ProcessesWithContext. 2018-01-11 11:47:13 +09:00
shirou
cd61c36c4f
Merge branch 'master' into feature/add_context_support 2018-01-09 11:18:25 +09:00
Nick Kirsch
6c35887d02 Add ErrNotImplementedError to Darwin, FreeBSD, and OpenBSD. 2018-01-04 11:51:49 -08:00
shirou
4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
Sam Kleinman
4d92a03da8 fix cross compiles 2017-11-09 10:31:12 -05:00