ubuntu20.04安装bcc性能监控工具

一、版本准备

bcc 0.24.0
libbpf 1.0.0

二、依赖项安装

sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
sudo apt-get install bcc-tools libbcc-examples linux-headers-$(uname -r)
sudo apt-get install clang-10 libclang-dev arping netperf  iperf

注:按需安装。

三、安装前准备

1.下载bcc

git clone  https://github.com/iovisor/bcc.git --branch v0.24.0 --depth 1

2.采用zrait的规避方案,修改bcc/cmake/clang_libs.cmake,相应内容如下:

list(APPEND clang_libs
  ${libclangParse}
  ${libclangSema}
  ${libclangCodeGen}
  ${libclangAnalysis}
  ${libclangRewrite}
  ${libclangEdit}
  ${libclangAST}
  ${libclangLex}
  ${libclangBasic}
  Polly
  PollyISL)

四、编译安装

cd bcc
git submodule update --init --recursive 
mkdir build
cd build/
cmake ..
make -j6
sudo make install
cmake -DPYTHON_CMD=python3 .. # build python3 binding
pushd src/python/
make
sudo make install
popd

五、编译问题

报错1:

could not open bpf map: counts, error: Operation not permitted
Traceback (most recent call last):
  File "/usr/share/bcc/tools/filetop", line 164, in <module>
    b = BPF(text=bpf_text)
  File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 475, in __init__
    raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>

root权限或者加sudo

报错2:

Traceback (most recent call last):
  File "./cachestat", line 21, in <module>
    from bcc import BPF
ImportError:No module named bcc

查看python版本,与当前python版本要一致

ls -l `which python`
# lrwxrwxrwx 1 root root 7 4月  15  2020 /usr/bin/python -> python2
sudo rm  /usr/bin/python
sudo ln -s /usr/bin/python3.8 /usr/bin/python

六、工具测试

在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值