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

105 Commits

Author SHA1 Message Date
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
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
shirou
457f04671d [process] move PageFaultsStat to process.go 2019-01-13 17:27:42 +09:00
shirou
98c84ed30a [process]: move HWM to MemoryInfo
at least FreeBSD and Darwin has HWM.
2019-01-13 17:23:01 +09:00
shirou
a33a26bd97
Merge pull request #567 from tagirb/grouped_memorymaps
implement grouped memorymaps output
2019-01-13 17:17:11 +09:00
shirou
48b37fa45e
Merge pull request #616 from nefeli/linux_page_faults
[process][linux] Export process page fault info
2019-01-13 16:56:41 +09:00
chi-chi weng
ec5a8b2a50
Add VmHWM
VmHWM: Peak resident set size ("high water mark").

http://man7.org/linux/man-pages/man5/proc.5.html
2019-01-04 17:31:43 +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
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
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
Aleksandr Balezin
e2c79a1af7 use full cmdline in case of proc renaming 2018-06-23 17:17:39 +03:00
Michal Rostecki
91ac1d66ac process: Check for error objects 2018-06-21 16:53:53 +02:00
shirou
145dca90f7 change to use CommandContext. 2018-03-31 21:35:53 +09:00
shirou
26a4a2f995 [process]: move ErrorNoChildren to platform independent. 2018-03-24 15:56:32 +09:00
Ihde
44ef466a5a Resolve issue #492 to reduce CPU overhead associated with fillFromStat 2018-02-20 13:13:53 -05: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
482ca3af6d Parses the tgid field, which is the thread group id (aka user-space process id) on Linux. Returns error on other platforms. 2018-01-04 11:30:39 -08:00
shirou
4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
tycho garen
08a382b207 make process.processes function public 2017-11-05 20:40:33 -05:00
Leonid Podolny
7ee4a4c6ff Fix Threads() signature to better match python original 2017-10-04 15:38:01 -04:00
Leonid Podolny
7ad3836ad3 Implement Threads() for Linux 2017-10-04 15:38:01 -04:00