Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
c8177e9b
Commit
c8177e9b
authored
Dec 18, 2017
by
Brendan Gregg
Committed by
GitHub
Dec 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1419 from runejuhl/fix-cachetop-getpwuid
Handle unknown user in cachetop
parents
cf378e25
2933df58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
tools/cachetop.py
tools/cachetop.py
+10
-1
No files found.
tools/cachetop.py
View file @
c8177e9b
...
...
@@ -222,11 +222,20 @@ def handle_loop(stdscr, args):
)
(
height
,
width
)
=
stdscr
.
getmaxyx
()
for
i
,
stat
in
enumerate
(
process_stats
):
uid
=
int
(
stat
[
1
])
try
:
username
=
pwd
.
getpwuid
(
uid
)[
0
]
except
KeyError
as
ex
:
# `pwd` throws a KeyError if the user cannot be found. This can
# happen e.g. when the process is running in a cgroup that has
# different users from the host.
username
=
'UNKNOWN({})'
.
format
(
uid
)
stdscr
.
addstr
(
i
+
2
,
0
,
"{0:8} {username:8.8} {2:16} {3:8} {4:8} "
"{5:8} {6:9.1f}% {7:9.1f}%"
.
format
(
*
stat
,
username
=
pwd
.
getpwuid
(
int
(
stat
[
1
]))[
0
]
*
stat
,
username
=
username
)
)
if
i
>
height
-
4
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment