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

129 Commits

Author SHA1 Message Date
shirou
5f158096be fix: golangci lint with max -> maxConn 2024-08-17 22:41:29 +09:00
shirou
6bdbf65126 [process]: Introduce DiskReadBytes on process which shows Disk IO only. 2024-05-28 22:27:17 +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
shirou
b10acd4894 [host]: add EnableBootTimeCache function 2024-01-11 00:49:11 +09:00
shirou
0665cafa1b chore: replace deprecated ioutil package to os and io 2023-09-08 17:05:14 +00: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
38b94668ea allow to pass context values to override environment variables 2023-06-02 01:31:05 -07: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
shirou
e2ae339eaf fix(process,linux): remove trailing multiple \x00 2022-07-12 09:49:23 +00:00
shirou
9a667f1188
Merge pull request #1210 from mmorel-35/master
enable contextcheck linter
2022-02-24 20:44:35 +09:00
Rishabh Arya
0bf4299250 Add support for reading smaps_rollup 2022-02-17 20:12:19 +00: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
shirou
50cad0760c
Merge branch 'master' into refactor/parentwithcontext-ppidwithcontext 2022-01-30 10:47:00 +09:00
Matthieu MOREL
8ba220d241 enable contextcheck linter 2022-01-24 09:26:50 +01: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
shirou
35fbe38505 [process][linux] Fix error handling on Children.
If pgrep returns error, `CallPgrepWithContext` always returns empty pids. So this Children always returns ErrorNoChildren. This PR fixes that handling.
2022-01-15 14:09:57 +00: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
Matthieu MOREL
c8fd8c7b1f
enable unparam linter 2021-12-22 19:53:14 +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
Tom Barker
bc4661937d Minor cleanups motivated by staticcheck warnings. 2021-08-19 10:43:06 -04:00
shirou
b27be3812b [v2][process][linux] port 1112 to v2.
This port includes only code. test is not included.
2021-08-14 08:22:57 +00: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
shirou
7ea8062810
Merge pull request #1083 from elmeyer/fix-processes-smartos
process, v3/process (Linux): fix Processes in SmartOS lx containers
2021-06-20 00:30:09 +09:00
Lars Meyer
0ab3954dc4 [process][linux] fix Processes in SmartOS lx containers
In Linux containers running in LX Branded Zones on SmartOS (potentially
other Solaris-based OSes with LX Branded Zones),
fillFromTIDStatWithContext panics as the delayacct_blkio_ticks field is
not present and thus results in an out-of-bounds slice access.
Check the slice length before and only attempt to parse the
delayacct_blkio_ticks field if there is an appropriate number of fields.
2021-06-04 10:15:21 +02: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
shirou
9bd4bc70ae [process][linux] fix 1056 test and copy to v2 2021-05-29 21:31:50 +09:00
Jens Meißner
fc074343f8
[process][linux] Fix fillFromStatusWithContext() on systems with 128 bit signal masks. 2021-04-13 21:24:39 +02:00
eriknordmark
0e13743b77 Avoid returning slice into buffer from Readfile
Signed-off-by: eriknordmark <erik@zededa.com>
2021-02-08 19:21:22 +01:00
Rishabh Arya
5b1d8ecae7 fix smap parser 2021-01-03 21:06:54 +05:30
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
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
Tyler Davis
8d28f1b305 Clean up boolean condition 2020-07-07 18:02:06 +10:00
Tyler Davis
9473d01f0f Fix MemoryMaps on ARM
ARM has some tab characters in smaps instead of spaces, hence switching to strings.Fields instead of strings.Split which handles splitting on all whitespace instead of just spaces.
2020-07-07 15:02:10 +10:00
JuanLeon Lahoz
426b5148e3 Provide an estimation of Iowait metric per process 2020-04-14 16:03:21 +02: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
36aa63bdd1 [process][linux] Propagate context internally 2019-09-04 19:47:23 +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
2ac72f1fa1 [process][linux] Fix NewProcess() on Linux
Related to #704.
Don't break previous API where a Process is always returned, fix undefined variable p.
2019-06-23 15:52:01 +02:00
Jose De La O
258343806a Preventing file open and bad defer close. Allocating mem as late as
possible
2019-06-21 17:26:52 -04:00
Tyler Dixon
4e81681ab3 code review 2019-05-24 09:48:27 -07:00
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.
2019-05-22 17:45:50 -07:00
mingrammer
017c9f9cbc Fix typos 2019-03-18 02:52:26 +09:00