summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2023-11-09python-linux-procfs: Remove specfiles and update versionHEADv0.7.3mainJohn Kacur4-214/+9
We should not be maintaining specfiles upstream, they should be maintained in the distributions instead. Also, a lot of the functionality in the Makefile was for working with rpms. This is not needed anymore because there are other tools that do this. So, the Makefile was gutted, leaving just a few things like making tags. Finally, for version 0.7.2, the version numbers were not bumped-up to match the git tag. Therefore, bumping version numbers up to 0.7.3 and creating a new git tag v0.7.3 Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-10Change the COPYING file for SPDX licensesv0.7.2John Kacur1-337/+3
Change the COPYING file for SPDX licenses Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-10python-linux-procfs: procfs: Added SPDX licenceAnubhav Shelat1-13/+1
procfs: Added SPDX licence Signed-off-by: Anubhav Shelat <ashelat@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-10python-linux-procfs: utilist: Added SPDX licenceAnubhav Shelat1-13/+1
utilist: Added SPDX licence Signed-off-by: Anubhav Shelat <ashelat@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-10python-linux-procfs: __init__: Added SPDX licenceAnubhav Shelat1-14/+2
__init__: Added SPDX licence Signed-off-by: Anubhav Shelat <ashelat@redhat.com> - Added Copyright back Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-10python-linux-procfs: setup: Added SPDX licenceAnubhav Shelat1-0/+2
setup: Added SPDX licence Signed-off-by: Anubhav Shelat <ashelat@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-10python-linux-procfs: bitmasklist_test: Added SPDX licenceAnubhav Shelat1-0/+1
bitmasklist_test: Added SPDX licence Signed-off-by: Anubhav Shelat <ashelat@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-10python_linux_procfs: setup.py: Remove distutilsJohn Kacur1-4/+8
distutils is deprecated, so use sysconfig instead different versions of python produce different results, which is why we test which SCHEME is available before calculating our answer. TODO: test whether we need to calculate PYTHONLIB at all. Is it being used during the setup? We don't appear to be using a --prefix from our specfiles. This patch ensures that if it is used, we are getting a correct PYTHONLIB without using distutils, but perhaps we can just drop this section. We need to bump the version number as well here, it looks like it was missed the last time. Signed-off-by: John Kacur <jkacur@redhat.com>
2022-11-18python-linux-procfs: Create release v0.7.1v0.7.1John Kacur2-2/+8
Create release v0.7.1 Signed-off-by: John Kacur <jkacur@redhat.com>
2022-08-22python-linux-procfs: Correct VERSION number in procfs.pyJohn Kacur1-1/+1
Fix the VERSION number in procfs. Note: this appears to be unused though. Consider either removing it or using it, and removing version numbers elsewhere like in the spec file Signed-off-by: John Kacur <jkacur@redhat.com>
2022-08-22python-linux-procfs: Use f-stringsJohn Kacur1-21/+19
Use f-strings instead of regular strings to improve readability Signed-off-by: John Kacur <jkacur@redhat.com>
2022-08-22python-linux-procfs: Add missing open in with statementJohn Kacur1-2/+2
- Add missing "open" to with statement. - Fix tests in __main__ Signed-off-by: John Kacur <jkacur@redhat.com>
2022-08-22python-linux-procfs: Use sys.exit and add some docstringsJohn Kacur1-1/+7
Use sys.exit and add some docstrings Signed-off-by: John Kacur <jkacur@redhat.com>
2022-01-10python-linux-procfs: Create release v0.7.0v0.7.0John Kacur2-2/+13
Create release v0.7.0 Signed-off-by: John Kacur <jkacur@redhat.com>
2021-12-09python-linux-procfs: Fix UnicodeDecodeErrorJohn Kacur1-4/+14
Commit 7570fc0d6082 meant to solve the UnicodeDecodeError Instead it actually increased the problem by reading lines as bytes and decoding them. The original problem is hard to trigger and doesn't trigger consistently with reproducers. In addition there seems to be a difference in how this is handled between python-3.6 to python-3.9 For now, we should return the code to reading as utf-8 (the default) since that handles more cases than the current code. We can catch the UnicodeDecodeError and ignore it for now. It is not ideal because we are not handling some pids that trigger the error. This patch also includes a fix for a FileNotFoundError which can occur if a pid exits and disappears before we try to read it in the /proc file system. Signed-off-by: John Kacur <jkacur@redhat.com>
2021-12-02python-linux-procfs: Various clean-upsJohn Kacur1-150/+142
- Replace f=open with 'with' (context managers), except in try-except blocks - Reformat lines that are too long, especially in comments - Use min() instead of if construct - Use bool instead of complicated and True or False constructs - Reorder imports Signed-off-by: John Kacur <jkacur@redhat.com>
2021-12-02python-linux-procfs: Remove procfs/sysctl.pyJohn Kacur3-70/+0
python-linux-procfs makes no use of sysctl.py, nor does tuna It appears to be code that was written to abstract some common operations reading procfs, but was never actually put into use. Just delete it Signed-off-by: John Kacur <jkacur@redhat.com>
2021-11-24python-linux-procfs: Makefile: Add ctagsJohn Kacur1-1/+9
Add the ability to use ctags to the Makefile. This adds the commands make tags make cleantags and modifies make clean to call cleantags Signed-off-by: John Kacur <jkacur@redhat.com>
2021-11-24python-linux-procfs: pflags: Handle pids that completedJohn Kacur1-2/+13
Sometimes pids disappear when they are completed. Programs such as pflags that use procfs must account for that. The solution is to simply recognize this situation, and to continue. Reviewed-by: Leah Leshchinsky <lleshchi@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
2021-11-24python-linux-procfs: Propagate error to user if a pid is completedJohn Kacur1-3/+16
If a pid is completed and disappears a FileNotFoundError will occur because /proc/pid/stat will disappear too. It is not possible to check for the file first because it could still disappear between the time of the check and the time of use. Propagate this error to the user. The user should handle this with a try, except clause and ignore it if an exception occurs. Reviewed-by: Leah Leshchinsky <lleshchi@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
2021-11-19python-linux-procfs: Fix traceback with non-utf8 chars in the /proc/PID/cmdlineJohn Kacur1-3/+3
Fix traceback if there are non-utf8 characters in the /proc/PID/cmdline Signed-off-by: John Kacur <jkacur@redhat.com>
2021-01-11python-linux-procfs: Add tar.xz and asc files to gitignoreJohn Kacur1-0/+2
Add tar.xz and *.asc files to .gitignore Signed-off-by: John Kacur <jkacur@redhat.com>
2021-01-11python-linux-procfs: Create release 0.6.3v0.6.3John Kacur2-2/+7
python-linux-procfs: Create release 0.6.3 with tag v0.6.3 Signed-off-by: John Kacur <jkacur@redhat.com>
2020-11-06python-linux-procfs: procfs.py: Fix a few more style problemsJohn Kacur1-5/+5
- elif not necessary after continue - don't use len() as a condition - Fix import order Signed-off-by: John Kacur <jkacur@redhat.com>
2020-11-06python-linux-procfs: procfs.py: Simplify is_s390John Kacur1-5/+3
Simply is_s390 by using bool instead of if statement. Add a docstring to the function and remove space from shebang while we're at it. Signed-off-by: John Kacur <jkacur@redhat.com>
2020-11-06python-linux-procfs: Fix more spacing problems with procfs.pyJohn Kacur1-52/+81
Fix spacing problems as recommended by PEP8 for procfs.py Signed-off-by: John Kacur <jkacur@redhat.com>
2020-06-24python-linux-procfs: Add gitignore and gitattributes filesJohn Kacur3-0/+6
Add gitignore and gitattributes files to make programming more pleasant. Also, procfs/procfs.pyc should not be tracked by git Signed-off-by: John Kacur <jkacur@redhat.com>
2020-06-24python-linux-procfs: Fix import of utilistJohn Kacur1-1/+1
If procfs/utilist.py is not in your PYTHONPATH, the import can fail. Specify it fully. Reported-by: David Runge <dave@sleepmap.de> Suggested-by: Guy Streeter <guy.streeter@gmail.com> Signed-off-by: John Kacur <jkacur@redhat.com>
2020-06-22python-linux-procfs: Create release 0.6.2v0.6.2John Kacur2-2/+7
Release 0.6.2 Signed-off-by: John Kacur <jkacur@redhat.com>
2020-06-19python-linux-procfs: Parse the number of cpus correctly on s390(x)john/develJohn Kacur1-0/+12
Getting the number of cpus breaks on s390 and s390x due to differences in /proc/cpuinfo This can cause problems in other programs such as tuna when running tuna --cpus=1 --isolate for example Fix this by testing whether we are on s390 and increasing the cpu count if we match "cpu number" Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: utilist: Clean-upsJohn Kacur1-26/+26
- Specify python3 explictly - Fixing tabbing and spacing Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: sysctl: Use is None and is not NoneJohn Kacur1-3/+3
Use is None and is not None instead of == or != Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: sysctl.py: Changes for python3John Kacur1-1/+1
- use list to loop over keys Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: sysctl.py: Fix tabbing and other issuesJohn Kacur1-40/+40
- Replaces tabs with 4 spaces - Specify python3 explicitly Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: procfs: Fix import and other issuesJohn Kacur1-29/+27
- fix order of imports - fix spacing in assignment of lists - fix spacing in defaults of methods and functions - fix a few more indentation problems Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: procfs: Updates for python3John Kacur1-13/+13
- Remove __future__ - Fix import - Use list where required Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: procfs.py: use Python spacingJohn Kacur2-941/+941
Use Python spacing - remove tabs and replace with 4 spaces - specify python3 - Remove spaces on empty lines Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: __init__ Clean-upsJohn Kacur1-3/+1
- python3 only, so remove from __future__ - explicitly specify python3 Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: pflags: Conform to python spacing recommendationsJohn Kacur1-41/+41
Conform to python spacing recommendations, for easier maintainence - remove tabs, for 4 spaces - remove unnecessary parenthesis - remove unnecessary spacing around return Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: setup.py: Fix a few pythonesque issuesJohn Kacur1-16/+15
- Remove tabs for spaces - Don't import unused glob module - Changes order of imports so that os comes before from os.path Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: bitmasklist_test: Rename class to BitmasklistTestJohn Kacur1-12/+12
- Rename class to conform to python naming conventions - Remove unneeded semicolons Signed-off-by: John Kacur <jkacur@redhat.com>
2020-04-14python-linux-procfs: bitmasklist_test.py: python3 changesJohn Kacur1-5/+5
Only python3 is supported now Changes to python3 - Specify python3 on the shebang - Get rid of future - Apply optional ws_comma from 2to3 Signed-off-by: John Kacur <jkacur@redhat.com>
2019-02-05release 0.6.1v0.6.1Jiri Kastner2-2/+5
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2019-02-05procfs: Fix removing vanished processes in pidstats.reload_threads()Ondřej Lysoněk1-1/+4
If a process disappears while iterating the loop in pidstats.reload_threads(), we get a RuntimeError as shown below. This is because we cannot remove an entry from a dictionary while iterating the dictionary. Reproducer: 1. Add the following line to the beginning of pidstats.reload_threads(): import pdb; pdb.set_trace() 2. Start some process 3. Start the python interpreter and proceed as follows: [~/git/python-linux-procfs]$ python3 Python 3.6.8 (default, Jan 3 2019, 16:11:14) [GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import procfs >>> ps = procfs.pidstats() >>> ps.reload_threads() > /home/olysonek/git/python-linux-procfs/procfs/procfs.py(462)reload_threads() -> for pid in self.processes.keys(): (Pdb) next > /home/olysonek/git/python-linux-procfs/procfs/procfs.py(463)reload_threads() -> try: At this point, terminate the process started in step 2. Return to the python interpreter: (Pdb) continue Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/olysonek/git/python-linux-procfs/procfs/procfs.py", line 463, in reload_threads try: RuntimeError: dictionary changed size during iteration Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2019-01-11sysctl: Fix refreshing cacheOndřej Lysoněk1-1/+1
Fix iterating over the 'cache' dictionary in refresh(). A dictionary is not callable. This fixes the following error: >>> import procfs.sysctl >>> s = procfs.sysctl() >>> s.refresh() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.6/site-packages/procfs/sysctl.py", line 64, in refresh for key in self.cache(): TypeError: 'dict' object is not callable Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2019-01-11python-linux-procfs: pflags: Ignore non-existent pids or process namesJohn Kacur1-2/+4
If the user enters a non-existent pid or process name, skip over it, Also, if the user enters nothing but a non-existent pid, then make sure the max_comm_len defaults to 0 instead of generating an error. Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2019-01-11python-linux-procfs: pflags: Use argparse to create a help optionJohn Kacur1-3/+9
The purpose of this change was to create a -h, or --help option. The following changes were made. 1. pflags is now python3 only, since it uses argparse. 2. The handling of pids or process names is improved, instead of a command separated list (without spaces), the more standard unix way of space separated command line arguements are used. This is explained in the help ./pflags -h usage: pflags [-h] [pid [pid ...]] Print process flags positional arguments: pid a list of pids or names optional arguments: -h, --help show this help message and exit Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2019-01-11procfs: Reduce not in python3 by defaultJohn Kacur1-0/+1
Reduce not in python3 by default, so import it from functools Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2018-08-09release 0.6v0.6Jiri Kastner2-5/+8
new functionality, new version :) Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2018-08-09python-linux-procfs: Add some functions for affinity from tunaJohn Kacur1-0/+16
Add cannot_set_affinity and cannot_set_thread_affinity from tuna Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-21release 0.5.1v0.5.1Jiri Kastner2-1/+2
trying to keep setup.py and rpm specfile coherent :) Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-21rpm: missed snippet in specfile for python2 onlyJiri Kastner1-0/+3
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-21setup.py: added scripts to setup.pyJiri Kastner3-2/+7
added scripts to setup.py, pflags renamed and added to setup.py Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20rpm: bump up version to 0.5v0.5Jiri Kastner3-16/+57
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: Use `setuptools.setup()` instead of distutilsLumir Balhar1-1/+2
We need to specify new dependency on `six` module with `install_requires` which is supported via setuptools. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: Use `range()` function from six.movesLumir Balhar1-0/+3
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: `print`, from statement to functionLumir Balhar3-17/+19
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: Fix usage of `map()` functionLumir Balhar2-4/+5
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: Use absolute import for import from local modulesLumir Balhar2-5/+11
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: `open()` is preferred way for opening files.Lumir Balhar2-10/+10
Moreover, `file()` is not available in Python 3. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: Fixes related to new Python 3 dict views.Lumir Balhar3-19/+19
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: `reduce()` is moved to `functools` module in Python 3Lumir Balhar1-0/+1
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-11-20python3: Use `in` operator instead of `has_key()` method.Lumir Balhar2-7/+7
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2017-09-26rpm: fixed Source, URL, bumped versionv0.4.11Jiri Kastner1-3/+6
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2016-12-22New release: 0.4.10v0.4.10Jiri Kastner1-1/+5
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2016-12-22python-linux-procfs: bitmasklist_test.py Add the first unit testJohn Kacur1-0/+67
This adds the first unit test to python-linux-procfs It adds the bitmasklist_test for testing the function bitmasklist, which is called by parse_affinity. Unlike parse_affinity, the number of cpus is not detected, so the unit test can simulate different numbers of cpus. This is an expanded form of a reproducer from Jozef Bacik from Bugzilla 1365902 If we add more unit tests in the future (we should), then we can consider some kind of python package scheme, but for now this can live in the base directory. Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2016-12-22fix parse_affinity for CPU numbers greater than 31Jozef Bacik1-10/+6
The function parse_affinity reports wrong results for CPU numbers greater than 31. The problem is caused by the function bitmastlist which parse_affinity calls. The fix treats the inpput line as a long hexbitmask instead of an array in order to produce correct results Signed-off-by: Jozef Bacik <jobacik@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
2015-10-09pidstats: fix documentation indentationJiri Kastner1-11/+11
Signed-off-by: Jiri Kastner <jkastner@redhat.com> Signed-off-by: John Kacur <jkacur at redhat.com>
2015-10-08New release: 0.4.9v0.4.9Arnaldo Carvalho de Melo2-2/+7
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-08pidstats: Add documentation for the reload() methodArnaldo Carvalho de Melo1-0/+14
Mention python-perf as an alternative way of noticing thread lifetime events (FORK, EXIT). Requested-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-02interrupts: Add documentation about 'cpu' fieldArnaldo Carvalho de Melo1-0/+5
Reported-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-02Add values() methods to all classes with dictsArnaldo Carvalho de Melo1-0/+30
Reported-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-02Add items() method to all the classes with dictsArnaldo Carvalho de Melo1-0/+24
Reported-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@edhat.com>
2015-10-02cpustat: Add __repr__ methodArnaldo Carvalho de Melo1-0/+9
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-02cmdline: Document itArnaldo Carvalho de Melo1-1/+20
Reported-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-02cmdline: Add dict methodsArnaldo Carvalho de Melo1-0/+6
So that we can use procfs.cmdline()["BOOT_IMAGE"], for instance. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-02Document smaps_libArnaldo Carvalho de Melo1-0/+9
Reported-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-09-01smaps: Provide usage example in the class documentationArnaldo Carvalho de Melo1-0/+19
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-09-01smaps: Add __len__ methodArnaldo Carvalho de Melo1-0/+3
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-09-01smaps: Add __getitem__ methodArnaldo Carvalho de Melo1-0/+3
So that we can do: >>> import procfs >>> processes = procfs.pidstats() >>> sshd = processes.find_by_name("sshd") >>> print sshd_maps[0].perms >>> sshd_maps = procfs.smaps(sshd[0]) >>> print sshd_maps[0].perms r-xp I.e. access it like an array. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-09-01smaps: Add documentationArnaldo Carvalho de Melo1-0/+5
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-31cpusstats, cpuinfo: Provide documentationArnaldo Carvalho de Melo1-0/+37
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-26interrupts: Document classArnaldo Carvalho de Melo1-0/+48
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-26procfs: Document the process pidstats classesArnaldo Carvalho de Melo1-0/+34
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-25pidstat: Add missing documentationArnaldo Carvalho de Melo1-0/+44
Getting the process flags documentation from the kernel include/linux/sched.h file, that is what 'man procfs' references when describing the processor flags in /proc/PID/stat. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-12pidstatus, process: Provide class level documentationArnaldo Carvalho de Melo1-0/+42
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-05pidstat: Provide class level documentationArnaldo Carvalho de Melo1-0/+25
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-08-05interrupts: Fix parsing of users fieldArnaldo Carvalho de Melo1-1/+1
It is the last field, in CSV format, and that was what was being parsed, but in a convoluted way, fixing it also simplified it. Buggy: [root@zoo ~]# tuna -Q # users affinity 0 2-edge timer 0,1,2,3 8 8-edge rtc0 0,1,2,3 9 9-fasteoi acpi 0,1,2,3 17 17-fasteoi brcmsmac 0,1,2,3 22 22-fasteoi ehci_hcd:usb4 0,1,2,3 23 23-fasteoi ehci_hcd:usb3 0,1,2,3 26 2146304-edge pciehp 0,1,2,3 27 2162688-edge pciehp 0,1,2,3 28 2179072-edge pciehp 0,1,2,3 29 2195456-edge pciehp 0,1,2,3 30 512000-edge 0000:00:1f.2 0,1,2,3 31 327680-edge xhci_hcd 0,1,2,3 32 32768-edge i915 0,1,2,3 33 360448-edge mei_me 0,1,2,3 34 2621440-edge thunderbolt 0,1,2,3 35 442368-edge snd_hda_intel 0,1,2,3 [root@zoo ~]# Fixed: # tuna -Q # users affinity 0 timer 0,1,2,3 8 rtc0 0,1,2,3 9 acpi 0,1,2,3 17 brcmsmac 0,1,2,3 22 ehci_hcd:usb4 0,1,2,3 23 ehci_hcd:usb3 0,1,2,3 26 pciehp 0,1,2,3 27 pciehp 0,1,2,3 28 pciehp 0,1,2,3 29 pciehp 0,1,2,3 30 0000:00:1f.2 0,1,2,3 31 xhci_hcd 0,1,2,3 32 i915 0,1,2,3 33 mei_me 0,1,2,3 34 thunderbolt 0,1,2,3 35 snd_hda_intel 0,1,2,3 # Reported-by: Flavio Leitner <fbl@redhat.com> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1245677 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-23New release: 0.4.8v0.4.8Arnaldo Carvalho de Melo2-2/+6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-15pidstat: Support COMM names with spacesArnaldo Carvalho de Melo1-1/+2
The load method was just splitting the fields using space as the separator, but since some COMM names started having spaces... We better use the () as the COMM "quotes", using spaces as the separator for the remaining fields. Reported-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11New release: 0.4.7v0.4.7Arnaldo Carvalho de Melo3-2/+12
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11pflags: Add command line utility to print processor flagsArnaldo Carvalho de Melo1-0/+65
E.g.: $ ./pflags-cmd.py ssh*,bash,6941 1278 sshd RANDOMIZE|SUPERPRIV|USED_ASYNC|USED_MATH 2692 bash RANDOMIZE|USED_ASYNC|USED_MATH 2919 bash RANDOMIZE|SUPERPRIV|USED_ASYNC|USED_MATH 3116 bash RANDOMIZE|USED_ASYNC|USED_MATH 3149 bash RANDOMIZE|USED_ASYNC|USED_MATH 3384 bash RANDOMIZE|USED_ASYNC|USED_MATH 3579 bash RANDOMIZE|USED_ASYNC|USED_MATH 3834 ssh RANDOMIZE|USED_ASYNC|USED_MATH 4372 bash RANDOMIZE|USED_ASYNC|USED_MATH 5024 bash RANDOMIZE|USED_ASYNC|USED_MATH 6339 bash RANDOMIZE|USED_ASYNC|USED_MATH 6941 vim FREEZER_SKIP|RANDOMIZE|USED_ASYNC|USED_MATH $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11pidstat: Add missing PF_ flagsArnaldo Carvalho de Melo1-0/+10
Adding the ones found in the v4.1-rc kernel. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11pidstat: Fix process_flags() methodArnaldo Carvalho de Melo1-1/+1
It was referencing self.flags, that doesn't exists, fix it by making it access self.fields["flags"] instead. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-10interrupts: Do not refrain from parsing the irq affinities for !rootArnaldo Carvalho de Melo1-2/+0
I.e. let the OS be the one to decide if access to this file is allowed or not, and non root users can see this, at least around 4.1-rc times: Running: procfs/procfs.py: 31: {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI-edge', 'cpu': [178564, 0, 285828, 0], 'users': ['xhci_hcd']} 30: {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI-edge', 'cpu': [342630, 0, 197229, 0], 'users': ['0000:00:1f.2']} 35: {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI-edge', 'cpu': [858, 0, 565, 0], 'users': ['snd_hda_intel']} 34: {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI-edge', 'cpu': [306, 0, 44, 0], 'users': ['thunderbolt']} And now 'tuna -Q' works for non root users: [acme@zoo python-linux-procfs]$ ../tuna/tuna-cmd.py -Q # users affinity 0 timer 0,1,2,3 8 rtc0 0,1,2,3 9 acpi 0,1,2,3 17 17-fasteoi brcmsmac 0,1,2,3 22 22-fasteoi ehci_hcd:usb4 0,1,2,3 23 23-fasteoi ehci_hcd:usb3 0,1,2,3 26 pciehp 0,1,2,3 27 pciehp 0,1,2,3 28 pciehp 0,1,2,3 29 pciehp 0,1,2,3 30 0000:00:1f.2 0,1,2,3 31 xhci_hcd 0,1,2,3 32 i915 0,1,2,3 33 mei_me 0,1,2,3 34 thunderbolt 0,1,2,3 35 snd_hda_intel 0,1,2,3 [acme@zoo python-linux-procfs]$ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-10pidstat: Add PF_NO_SETAFFINITY constArnaldo Carvalho de Melo1-1/+2
For the stat flag that means that userland is not allowed to meddle with cpus_allowed, i.e. with the thread's smp affinity, via sched_setaffinity. This indeed has the same value as PF_THREAD_BOUND, see the kernel sources for an explanation, but basically was in this cset: commit 14a40ffccd6163bbcd1d6f32b28a88ffe6149fc6 Author: Tejun Heo <tj@kernel.org> Date: Tue Mar 19 13:45:20 2013 -0700 sched: replace PF_THREAD_BOUND with PF_NO_SETAFFINITY PF_THREAD_BOUND was originally used to mark kernel threads which were bound to a specific CPU using kthread_bind() and a task with the flag set allows cpus_allowed modifications only to itself. Workqueue is currently abusing it to prevent userland from meddling with cpus_allowed of workqueue workers. --------------------------------------------------------------- So add the new const but keep the old one, we may have some tool out there using it. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-05-28procfs: Add a __contains__ method to dict classesGuy Streeter1-0/+15
Signed-off-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-06-07New release: 0.4.6v0.4.6Arnaldo Carvalho de Melo2-2/+6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-06-07procfs: Parse environment variablesJiri Kastner1-1/+12
Signed-off-by: Jiri Kastner <jkastner@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-04-05pidstats: Added support for parsing cgroups as a per thread attributePetr Oros1-0/+12
Signed-off-by: Petr Oros <poros@redhat.com>
2013-03-30smaps: Improve parsing of mmapsArnaldo Carvalho de Melo1-2/+7
Recent kernels (detected on 3.9.0-rc2) have a VmFlags field that has string flags that broke the detection of multiple memory maps. Fix it by checking for a ':' as the last character of the first token in the split() line. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-10rpm: Tag 0.4.5v0.4.5Arnaldo Carvalho de Melo2-2/+5
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-03-26pidstats: Catch more vanished processes casesArnaldo Carvalho de Melo1-7/+31
When the process vanishes after we got a list of pids that match some criteria, just catch it, remove it from the pid dictionary and continue. Reported-by: Clark Williams <williams@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-10rpm: More fixes from the fedora review processArnaldo Carvalho de Melo4-2/+347
Reviewed-by: Parag AN(पराग) <panemade@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-09Add shebangs and licensesv0.4.3Arnaldo Carvalho de Melo5-2/+72
Part of the fedora review process. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-09rpm: Fixup rpmlint warningsArnaldo Carvalho de Melo1-1/+2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-01-28Makefile: Add clean targetArnaldo Carvalho de Melo1-0/+11
Reported-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-01-28rpm: Add missing changelog entry with changes since 0.4Arnaldo Carvalho de Melo1-0/+8
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-01-13rpm: bump to 0.4.2Arnaldo Carvalho de Melo1-1/+1
Thanks to Guy Streeter for letting me know about this problem. Signed-off-by: Arnaldo Carvalho de Melo <acme@doppio.ghostprotocols.net>
2009-01-09interrupts: Add find_by_user_regexv0.4.2Arnaldo Carvalho de Melo1-1/+12
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-12-08process: Always set the "cmdline" array, even if emptyv0.4.1Arnaldo Carvalho de Melo1-5/+2
So that we don't require the tools that use p-l-procfs to call load_cmdline everytime we refresh the list of processes, leaving parsing of /proc/cmdline to the last possible moment. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-12-08pidstats: Remove dead processes in find_by_name()Arnaldo Carvalho de Melo1-2/+9
Since we now defer looking at the contents till we really need to parse the files, we have to check if the process died in this method. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-12-08pidstats: Add process class to catch dict references for late parsingArnaldo Carvalho de Melo1-33/+44
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-12-03pidstats: Move the /proc/PID/{stat,status} parsing to classesArnaldo Carvalho de Melo1-37/+79
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-12-02pidstats: Introduce process_flags methodArnaldo Carvalho de Melo1-0/+12
Usage example: >>> import procfs >>> ps = procfs.pidstats() >>> for t in ps.find_by_name("sirq-net-tx/6"): ... print "%s: %s" % (t, ps.process_flags(t)) ... 85: ['PF_FORKNOEXEC', 'PF_NOFREEZE', 'PF_SUPERPRIV', 'PF_THREAD_BOUND'] >>> for t in ps.find_by_name("pdflush"): ... print "%s: %s" % (t, ps.process_flags(t)) ... 398: ['PF_FLUSHER', 'PF_FORKNOEXEC', 'PF_SWAPWRITE'] 399: ['PF_FLUSHER', 'PF_FORKNOEXEC', 'PF_SWAPWRITE'] >>> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-12rpm: Package .egg-info files if version is new enoughv0.4Arnaldo Carvalho de Melo1-0/+3
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-12rpm: v0.4Arnaldo Carvalho de Melo1-1/+4
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-12pidstats: Add per process flagsArnaldo Carvalho de Melo1-0/+34
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-07Makefile: add make rpmdevArnaldo Carvalho de Melo1-0/+8
To build an rpm without first commiting the latest changes. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-05Makefile: Use --prefix in git-archiveArnaldo Carvalho de Melo2-2/+3
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-05Makefile: add rpmdirs target and trigger it when doing make rpmArnaldo Carvalho de Melo1-2/+8
Thanks to Jon Masters for pointing out this. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-06-13MANIFEST: add MakefileArnaldo Carvalho de Melo1-0/+1
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-06-13Makefile: make rpmv0.3Arnaldo Carvalho de Melo2-1/+12
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-06-13cpustats: handle CPU hotplugArnaldo Carvalho de Melo1-6/+17
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-16[CPUSTAT]: 2.6.9 has only 8 fields in /proc/statArnaldo Carvalho de Melo1-4/+5
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-25[PROCFS] cpustats: allow specifying a filenameArnaldo Carvalho de Melo1-2/+3
So that we can experiment with files saved from different machines. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-20[CPUINFO]: Handle the non-multicore formatArnaldo Carvalho de Melo1-2/+3
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-20[CPUINFO]: Count number of sockets and coresArnaldo Carvalho de Melo1-4/+11
Number of cpus remains with the same algorithms, so for a 16 socket machine with dual core cpus with ht enabled we have: nr_sockets: 16 nr_cores: 32 nr_cpus: 64 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-26[PROCFS] pidstats: Fixup load_cmdline exception handlingArnaldo Carvalho de Melo1-1/+1
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-26[PIDSTATS]: Check if process has vanished when accessing cmdline & tasks/Arnaldo Carvalho de Melo2-13/+21
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-25Created repo from files previously in ait.gitArnaldo Carvalho de Melo7-0/+608
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>