summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* fix typos and some other minor bugs (#2253)HEADmastercui fliter2023-05-096-9/+9
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* skip who CLI related test if necessaryGiampaolo Rodola2023-05-022-3/+4
|
* NetBSD, cmdline(): add debug message on EINVAL (re. to #2250)Giampaolo Rodola2023-05-021-4/+6
|
* makefile: integrate abi3audit CLI tool + refactoringGiampaolo Rodola2023-04-291-34/+34
|
* revert previous makefile commit as it requires bashGiampaolo Rodola2023-04-291-11/+10
|
* Makefile: expand variablesGiampaolo Rodola2023-04-291-11/+12
| | | | | | Using $(shell ...) instead of `...` expands all variables. Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Run `abi3audit` on produced abi3 wheels (#2247)Matthieu Darbois2023-04-242-1/+9
| | | Signed-off-by: mayeut <mayeut@users.noreply.github.com>
* SunOS: fix some C compilation warningsGiampaolo Rodola2023-04-225-15/+17
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* use glob.glob() in setup.pyGiampaolo Rodola2023-04-201-68/+29
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* OSX / refact: get rid of process_info.c (#2243)Giampaolo Rodola2023-04-208-436/+397
|
* OSX C refact: reconstruct _psutil_osx.c to preserve historyosx-move-proc-funcsGiampaolo Rodola2023-04-196-167/+191
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* OSX: rename psutil/_psutil_osx.c to arch/osx/proc.c to preserve GIT historyGiampaolo Rodola2023-04-192-1/+1
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* OSX big C refactoring (#2242)Giampaolo Rodola2023-04-2015-792/+921
|
* fix failing users() test; update HISTORY; give CREDITS to @0-wiz-0 for #2241Giampaolo Rodola2023-04-204-7/+21
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* win, C, refact: rename process_*.c files to proc_*.cwin-c-refactGiampaolo Rodola2023-04-1913-22/+43
|\
| * win C refact: reconstruct _psutil_windows.c trying to preserve historyGiampaolo Rodola2023-04-196-301/+363
| | | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
| * rename _psutil_windows.c -> proc.cGiampaolo Rodola2023-04-192-1/+1
| | | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* | Win, C, refact: move proc funcs into proc.c fileGiampaolo Rodola2023-04-195-1224/+1278
|/ | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Merge branch 'c-refact'Giampaolo Rodola2023-04-1914-1004/+1093
|\
| * BSD big refact: move proc funcs in new proc.c fileGiampaolo Rodola2023-04-1914-1004/+1093
| |
* | Fix build on NetBSD due to missing .h include. (#2241)Thomas Klausner2023-04-191-0/+1
|/
* Win, C, refact: move boot_time() and users() in new sys.cGiampaolo Rodola2023-04-184-170/+198
|
* Windows / refact: new sensors.c fileGiampaolo Rodola2023-04-184-26/+44
|
* C refact: remove useless cmdline / cwd / environ layers. Call direct functionsGiampaolo Rodola2023-04-1814-281/+170
|
* pre releaserelease-5.9.5Giampaolo Rodola2023-04-173-6/+20
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Add CI testing for OpenBSD and NetBSD (#2240)Giampaolo Rodola2023-04-177-50/+92
|
* Fix #2239 / proc name(): don't fail with ZombieProcess on cmdline()Giampaolo Rodola2023-04-173-3/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent failure observed on OpenBSD led me to an interesting consideration. ``` ====================================================================== ERROR: psutil.tests.test_process.TestProcess.test_long_name ---------------------------------------------------------------------- Traceback (most recent call last): File "/vagrant/psutil/psutil/_psbsd.py", line 566, in wrapper return fun(self, *args, **kwargs) File "/vagrant/psutil/psutil/_psbsd.py", line 684, in cmdline return cext.proc_cmdline(self.pid) ProcessLookupError: [Errno 3] No such process During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/vagrant/psutil/psutil/tests/test_process.py", line 751, in test_long_name self.assertEqual(p.name(), os.path.basename(testfn)) File "/vagrant/psutil/psutil/__init__.py", line 628, in name cmdline = self.cmdline() File "/vagrant/psutil/psutil/__init__.py", line 681, in cmdline return self._proc.cmdline() File "/vagrant/psutil/psutil/_psbsd.py", line 569, in wrapper raise ZombieProcess(self.pid, self._name, self._ppid) psutil.ZombieProcess: PID still exists but it's a zombie (pid=48379) ---------------------------------------------------------------------- ``` The exception above occurs sporadically. It originates from `sysctl (KERN_PROC_ARGV)`: https://github.com/giampaolo/psutil/blob/0a81fa089fd4b25b4b7ee71ed39213b83f73c052/psutil/arch/openbsd/proc.c#L149 The error per se does not represent a bug in the OpenBSD `cmdline ()` implemention because the process **really** is a zombie at that point (I'm not sure why it's a zombie - this seems only to occur only on OpenBSD for this specific test case - but that's not the point). The interesting thing is that the test calls process `name()` (which succeeds, despite it's a zombie process), but since the process name is too long it gets truncated to 15 chars (this is a UNIX thing) so psutil tries to guess the remaining characters from the process `cmdline()`, which fails: https://github.com/giampaolo/psutil/blob/0a81fa089fd4b25b4b7ee71ed39213b83f73c052/psutil/__init__.py#L623-L630 The problem to fix here is that, if `name()` succeeds but `cmdline()` fails, we should not raise `ZombieProcess`: we should simply return the (truncated) process `name()` instead, because that is better than nothing. Not on OpenBSD but on all platforms. Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* #2238: passed wrong value to Py_BuildValueGiampaolo Rodola2023-04-172-2/+2
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* fix #2238 if cwd() cannot be determined always return "" instead of NoneGiampaolo Rodola2023-04-179-27/+34
|
* Fix #2237, OpenBSD, cwd(): return None instead of FileNotFoundErrorGiampaolo Rodola2023-04-164-5/+12
|
* BSD: refactor py code related to filtering connectionsGiampaolo Rodola2023-04-161-42/+18
|
* Fix #2236 / NetNBSD: skip terminated process threadsGiampaolo Rodola2023-04-142-0/+6
| | | | | | | | | Process threads() and num_threads() methods now skip threads which are in ZOMBIE or IDLE state. It turns out that after a thread is terminated / join()ed, instead of disappearing it can stick around in a ZOMBIE or IDLE state, presumably for a while before being garbage collected. Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* [NetBSD] virtual_memory() metrics are completely wrong (#2235), fixes #2234Giampaolo Rodola2023-04-154-36/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Match values shown by **htop**. This is before. In here: * available mem is almost the same as total (unrealistic) * used is higher than total; there's also a failing test: ``` MEMORY ------ Total : 972.7M Available : 959.1M Percent : 1.4 Used : 1.1G Free : 173.6M Active : 434.3M Inactive : 258.4M Buffers : 509.4M Cached : 692.9M Shared : 0.0B Wired : 280.0K ``` Now: ``` MEMORY ------ Total : 972.7M Available : 538.1M Percent : 44.7 Used : 434.5M Free : 173.6M Active : 434.2M Inactive : 258.4M Buffers : 509.4M Cached : 692.9M Shared : 0.0B Wired : 280.0K ```
* docs: add percentage usage of virtual memory (#2223)Aaron Shaw2023-04-141-0/+1
| | | | | docs was missing a note about percentage memory usage Signed-off-by: Aaron Shaw <shawaj@gmail.com>
* [NetBSD] available mem can be higher than total (#2233)Giampaolo Rodola2023-04-143-14/+26
| | | | | | | | | | | | | | | | | On NetBSD "available" memory can be higher than "total". From now now calculate it exactly the same as Zabbix: https://github.com/zabbix/zabbix/blob/af5e0f80253e585ca7082ca6bc9cc07400afe2a7/src/libs/zbxsysinfo/netbsd/memory.c Fixes https://github.com/giampaolo/psutil/issues/2231 which produced this failure: ``` ====================================================================== FAIL: psutil.tests.test_system.TestMemoryAPIs.test_virtual_memory ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/vagrant/psutil/psutil/tests/test_system.py", line 275, in test_virtual_memory assert 0 <= mem.percent <= 100, mem ^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: svmem(total=1019899904, available=1046573056, percent=-2.6, used=603414528, free=545050624, active=234807296, inactive=133210112, buffers=260288512, cached=368312320, shared=0, wired=294912) ```
* [NetBSD] move files / refactoring of C files (#2232)Giampaolo Rodola2023-04-1411-271/+337
|
* fix NetBSD test failure + add test for cached memGiampaolo Rodola2023-04-131-0/+12
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* OpenBSD: rewrite net_connections() from scratch (#2230)Giampaolo Rodola2023-04-1313-277/+246
|
* Get Windows percent swap usage from performance counters (#2160)Daniel Widdis2023-04-137-6/+88
| | | Signed-off-by: Daniel Widdis <widdis@gmail.com>
* fix users() test on OpenBSDGiampaolo Rodola2023-04-121-5/+7
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* OpenBSD is unable to recognize zombie process. (#2229)Giampaolo Rodola2023-04-122-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenBSD is unable to recognize zombie process. It will raise NoSuchProcess instead of ZombieProcess. Test failure: ====================================================================== ERROR: psutil.tests.test_process.TestProcess.test_zombie_process ---------------------------------------------------------------------- Traceback (most recent call last): File "/vagrant/psutil/psutil/_psbsd.py", line 560, in wrapper return fun(self, *args, **kwargs) File "/vagrant/psutil/psutil/_psbsd.py", line 862, in open_files rawlist = cext.proc_open_files(self.pid) ProcessLookupError: [Errno 3] No such process During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/vagrant/psutil/psutil/tests/test_process.py", line 1312, in test_zombie_process zproc.as_dict() File "/vagrant/psutil/psutil/__init__.py", line 528, in as_dict ret = meth() File "/vagrant/psutil/psutil/__init__.py", line 1142, in open_files return self._proc.open_files() File "/vagrant/psutil/psutil/_psbsd.py", line 565, in wrapper raise NoSuchProcess(self.pid, self._name) psutil.NoSuchProcess: process no longer exists (pid=67013) This happens because OpenBSD is the only BSD defining 2 codes for zombie processes: # According to /usr/include/sys/proc.h SZOMB is unused. # test_zombie_process() shows that SDEAD is the right # equivalent. Also it appears there's no equivalent of # psutil.STATUS_DEAD. SDEAD really means STATUS_ZOMBIE. # cext.SZOMB: _common.STATUS_ZOMBIE, cext.SDEAD: _common.STATUS_ZOMBIE, cext.SZOMB: _common.STATUS_ZOMBIE,
* [POSIX] psutil.users() loses precision for "started" attribute #2225 (#2226)Giampaolo Rodola2023-04-121-2/+2
|
* fix some tests on BSD platformsGiampaolo Rodola2023-04-124-5/+14
|
* [POSIX] psutil.users() loses precision for "started" attribute #2225 (#2226)Giampaolo Rodola2023-04-118-17/+47
|
* merge from masterGiampaolo Rodola2023-04-1035-187/+207
|\ | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
| * move psutil_getpagesize() in a new mem.c fileGiampaolo Rodola2023-04-103-12/+10
| |
| * move psutil_virtual_mem() in a new mem.c fileGiampaolo Rodola2023-04-104-29/+46
| |
| * update cpu_freq() docGiampaolo Rodola2023-04-091-8/+9
| |
| * Fix Linux test: allow '-dirty' or other version postfixes (#2221)Mark Asselstine2023-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is possible that 'free -V' will return a version that includes a postfix such as '-dirty'. For example procps-ng will explicitly add this when building from git: https://gitlab.com/procps-ng/procps/-/blob/master/local/git-version-gen#L154 Process the version string to drop these string postfixes from the version tuple, failing to do so will result in the test failing File ".../psutil/tests/test_linux.py", line 204, in get_free_version_info return tuple(map(int, out.split()[-1].split('.'))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: '3-dirty' Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
| * Fix pylint warnings / cleanup (#2218)Giampaolo Rodola2023-04-0130-143/+146
| |