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
bfdb3d48
Commit
bfdb3d48
authored
Jun 02, 2016
by
Mark Drayton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
execsnoop: show PPID in output
parent
5b47e0f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
tools/execsnoop.py
tools/execsnoop.py
+17
-2
No files found.
tools/execsnoop.py
View file @
bfdb3d48
...
@@ -145,7 +145,7 @@ b = BPF(text=bpf_text)
...
@@ -145,7 +145,7 @@ b = BPF(text=bpf_text)
# header
# header
if
args
.
timestamp
:
if
args
.
timestamp
:
print
(
"%-8s"
%
(
"TIME(s)"
),
end
=
""
)
print
(
"%-8s"
%
(
"TIME(s)"
),
end
=
""
)
print
(
"%-16s %-6s %
3s %s"
%
(
"PCOMM"
,
"
PID"
,
"RET"
,
"ARGS"
))
print
(
"%-16s %-6s %
-6s %3s %s"
%
(
"PCOMM"
,
"PID"
,
"P
PID"
,
"RET"
,
"ARGS"
))
TASK_COMM_LEN
=
16
# linux/sched.h
TASK_COMM_LEN
=
16
# linux/sched.h
ARGSIZE
=
128
# should match #define in C above
ARGSIZE
=
128
# should match #define in C above
...
@@ -166,6 +166,19 @@ class EventType(object):
...
@@ -166,6 +166,19 @@ class EventType(object):
start_ts
=
time
.
time
()
start_ts
=
time
.
time
()
argv
=
defaultdict
(
list
)
argv
=
defaultdict
(
list
)
# TODO: This is best-effort PPID matching. Short-lived processes may exit
# before we get a chance to read the PPID. This should be replaced with fetching
# PPID via C when available (#364).
def
get_ppid
(
pid
):
try
:
with
open
(
"/proc/%d/status"
%
pid
)
as
status
:
for
line
in
status
:
if
line
.
startswith
(
"PPid:"
):
return
int
(
line
.
split
()[
1
])
except
IOError
:
pass
return
0
# process event
# process event
def
print_event
(
cpu
,
data
,
size
):
def
print_event
(
cpu
,
data
,
size
):
event
=
ct
.
cast
(
data
,
ct
.
POINTER
(
Data
)).
contents
event
=
ct
.
cast
(
data
,
ct
.
POINTER
(
Data
)).
contents
...
@@ -183,7 +196,9 @@ def print_event(cpu, data, size):
...
@@ -183,7 +196,9 @@ def print_event(cpu, data, size):
if
not
skip
:
if
not
skip
:
if
args
.
timestamp
:
if
args
.
timestamp
:
print
(
"%-8.3f"
%
(
time
.
time
()
-
start_ts
),
end
=
""
)
print
(
"%-8.3f"
%
(
time
.
time
()
-
start_ts
),
end
=
""
)
print
(
"%-16s %-6s %3s %s"
%
(
event
.
comm
,
event
.
pid
,
event
.
retval
,
ppid
=
get_ppid
(
event
.
pid
)
print
(
"%-16s %-6s %-6s %3s %s"
%
(
event
.
comm
,
event
.
pid
,
ppid
if
ppid
>
0
else
"?"
,
event
.
retval
,
' '
.
join
(
argv
[
event
.
pid
])))
' '
.
join
(
argv
[
event
.
pid
])))
del
(
argv
[
event
.
pid
])
del
(
argv
[
event
.
pid
])
...
...
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