如果从源代码构建 BCC 后“sudo /usr/share/bcc/tools/execsnoop”失败,我该怎么办?

问题描述 投票:0回答:2

从源代码构建 BCC 并运行测试“sudo /usr/share/bcc/tools/execsnoop”后,我得到以下输出:

回溯(最近一次调用最后一次): 文件“/usr/share/bcc/tools/execsnoop”,第 21 行,位于 从密件抄送导入BPF 导入错误:没有名为 bcc 的模块

这意味着什么?可以采取什么措施来补救?

安装依赖项后,我遵循以下步骤:

git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
# python2 can be substituted here, depending on your environment
cmake -DPYTHON_CMD=python3 ..
make && sudo make install

sudo /usr/share/bcc/tools/execsnoop #Test
python c++ linux ebpf bcc-bpf
2个回答
3
投票

这是由于 python2 设置为默认 python 导致的。

$ ls -l `which python`
lrwxrwxrwx 1 root root 7 Mar  4  2019 /usr/bin/python -> python2

有一种方法可以更改所有出现的

#!/usr/bin/python
#!/usr/bin/python3

sudo ln -s /usr/bin/python3 /usr/bin/python

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 100
update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python (python) in auto mode

这会将 python 更改为替代 python

$ ls -l `which python`
lrwxrwxrwx 1 root root 24 Nov 29 20:21 /usr/bin/python -> /etc/alternatives/python

0
投票

您可以使用不依赖于python的yeet实现。

https://yeet.cx/@yeet/execsnoop

© www.soinside.com 2019 - 2024. All rights reserved.