basebuilder_pel7ppc64lebuilder0
4 years ago
3 changed files with 120 additions and 3 deletions
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
From 1694ab2ab3628cead18ba7aa59e134e80675c601 Mon Sep 17 00:00:00 2001 |
||||
From: John Kacur <jkacur@redhat.com> |
||||
Date: Fri, 30 Nov 2018 11:50:34 -0500 |
||||
Subject: [PATCH 1/2] python-linux-procfs: pflags: Use argparse to create a |
||||
help option |
||||
|
||||
The purpose of this change is to create a -h or --help option. |
||||
In addition 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 arguments 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> |
||||
--- |
||||
pflags-cmd.py | 8 +++++++- |
||||
1 file changed, 7 insertions(+), 1 deletion(-) |
||||
|
||||
diff --git a/pflags-cmd.py b/pflags-cmd.py |
||||
index 9228c688e7a2..f180ed505977 100755 |
||||
--- a/pflags-cmd.py |
||||
+++ b/pflags-cmd.py |
||||
@@ -15,6 +15,7 @@ |
||||
# General Public License for more details. |
||||
|
||||
import procfs, re, fnmatch, sys |
||||
+import argparse |
||||
|
||||
ps = None |
||||
|
||||
@@ -35,8 +36,13 @@ def main(argv): |
||||
global ps |
||||
ps = procfs.pidstats() |
||||
|
||||
+ parser = argparse.ArgumentParser(description='Print process flags') |
||||
+ parser.add_argument('pid', nargs='*', help='a list of pids or names') |
||||
+ args = parser.parse_args() |
||||
+ |
||||
if (len(argv) > 1): |
||||
- pids = reduce(lambda i, j: i + j, map(thread_mapper, argv[1].split(","))) |
||||
+ pids = args.pid |
||||
+ pids = reduce(lambda i, j: i + j, list(map(thread_mapper, pids))) |
||||
else: |
||||
pids = ps.processes.keys() |
||||
|
||||
-- |
||||
2.19.2 |
||||
|
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
From e153f5177e1ae4b7859454a2d3011d6f55710600 Mon Sep 17 00:00:00 2001 |
||||
From: John Kacur <jkacur@redhat.com> |
||||
Date: Mon, 3 Dec 2018 09:02:34 -0500 |
||||
Subject: [PATCH 2/2] python-linux-procfs: pflags: Ignore non-existent pids or |
||||
process names |
||||
|
||||
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 don't |
||||
calculte max_comm_len since you can't take the max of an empty list. |
||||
|
||||
Signed-off-by: John Kacur <jkacur@redhat.com> |
||||
--- |
||||
pflags-cmd.py | 7 +++++-- |
||||
1 file changed, 5 insertions(+), 2 deletions(-) |
||||
|
||||
diff --git a/pflags-cmd.py b/pflags-cmd.py |
||||
index f180ed505977..c2627dcec14e 100755 |
||||
--- a/pflags-cmd.py |
||||
+++ b/pflags-cmd.py |
||||
@@ -47,11 +47,14 @@ def main(argv): |
||||
pids = ps.processes.keys() |
||||
|
||||
pids.sort() |
||||
- len_comms = map(lambda pid: len(ps[pid]["stat"]["comm"]), pids) |
||||
- max_comm_len = max(len_comms) |
||||
+ len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps] |
||||
+ if len_comms: |
||||
+ max_comm_len = max(len_comms) |
||||
del(len_comms) |
||||
|
||||
for pid in pids: |
||||
+ if pid not in ps: |
||||
+ continue |
||||
flags = ps[pid].stat.process_flags() |
||||
# Remove flags that were superseeded |
||||
if "PF_THREAD_BOUND" in flags and "PF_NO_SETAFFINITY" in flags: |
||||
-- |
||||
2.19.2 |
||||
|
Loading…
Reference in new issue