| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|\ |
|
| |
| |
| |
| | |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
| |
| |
| | |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|/
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|\ |
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 was missing a note about percentage memory usage
Signed-off-by: Aaron Shaw <shawaj@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
```
|
| |
|
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
|
| |
Signed-off-by: Daniel Widdis <widdis@gmail.com>
|
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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,
|
| |
|
| |
|
| |
|
|\
| |
| |
| | |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
|
|/
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|\ |
|
| |
| |
| | |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|/
|
|
|
|
|
|
|
|
|
| |
psutil/_psutil_linux.c: In function ‘psutil_proc_cpu_affinity_set’:
psutil/_psutil_linux.c:317:80: warning: unknown conversion type character ‘R’ in format [-Wformat=]
317 | return PyErr_Format(PyExc_TypeError, "sequence argument expected, got %R", Py_TYPE(py_cpu_set));
| ^
psutil/_psutil_linux.c:317:46: warning: too many arguments for format [-Wformat-extra-args]
317 | return PyErr_Format(PyExc_TypeError, "sequence argument expected, got %R", Py_TYPE(py_cpu_set));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
creating build/lib.linux-x86_64-2.7
|
| |
|
|
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
B028: No explicit stacklevel argument found. The warn method from
the warnings module uses a stacklevel of 1 by default. This will
only show a stack trace for the line on which the warn method is
called. It is therefore recommended to use a stacklevel of 2 or
greater to provide more information to the user.
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
On windows, starting with python 3.7,
virtual environments use a venvlauncher startup process
This does not play well when counting spawned processes or
when relying on the pid of the spawned process to do some checks
e.g. connection check per pid
This commit detects this situation and uses the base python
executable to spawn processes when required.
Signed-off-by: mayeut <mayeut@users.noreply.github.com>
|
|
|
|
| |
Signed-off-by: Gerard Weatherby <gweatherby@uchc.edu>
Co-authored-by: Gerard Weatherby <gweatherby@uchc.edu>
|