from
__future__
import
print_function
from
bcc
import
ArgString, BPF
from
bcc.containers
import
filter_by_containers
from
bcc.utils
import
printb
import
argparse
from
collections
import
defaultdict
from
datetime
import
datetime, timedelta
import
os
bpf_text
=
b
=
BPF(text
=
bpf_text)
b.attach_kprobe(event
=
"__x64_sys_openat"
, fn_name
=
"syscall__before_openat"
)
b.attach_kretprobe(event
=
"__x64_sys_openat"
, fn_name
=
"after_openat"
)
def
my_callback(cpu, data, size):
temp
=
b[
"events"
].event(data)
if
temp.
id
is
not
None
:
print
(
"[pid]"
,temp.
id
&
0xffffffff
, end
=
" "
)
if
temp.name
is
not
None
:
print
(
"[path]"
,temp.name, end
=
" "
)
if
temp.ret
is
not
None
:
print
(
"[ret]"
,temp.ret, end
=
" "
)
if
temp.comm
is
not
None
:
print
(
"[comm]"
,temp.comm, end
=
" "
)
print
("")
b[
"events"
].open_perf_buffer(my_callback, page_cnt
=
64
)
while
True
:
try
:
b.perf_buffer_poll()
except
KeyboardInterrupt:
exit()
pass