在干净的Ubuntu系统上安装BCC并进行测试.

Ref

环境

  • Ubuntu 22.04
  • 4GB RAM or above

Steps

Prep

安装依赖

1
2
3
apt install -y zip bison build-essential cmake flex git libedit-dev \
libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools \
liblzma-dev libdebuginfod-dev arping netperf iperf

测试

1
2
3
cmake --version
gcc --version
g++ --version

切换python为python3

1
apt install python-is-python3

Compile

1
2
3
4
5
6
7
8
9
10
git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
cmake ..
make
sudo make install
cmake -DPYTHON_CMD=python3 .. # build python3 binding
pushd src/python/
make
sudo make install
popd

如果安装正常,应该能在usr/share/bcc目录下看到tools目录

Test

1
2
3
cd /usr/share/bcc/tools
sudo ./cachestat 1 3
sudo ./execsnoop

Update

可以使用这里的一键脚本:
https://github.com/seclab-stonybrook/eaudit/blob/master/bcc_install.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fatal() {
echo "BCC installation failed at the following step: $1"
exit 1
}

sudo apt update || fatal "apt update"
sudo apt install -y zip bison build-essential cmake flex git libedit-dev \
libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev \
python3-setuptools liblzma-dev libdebuginfod-dev \
|| fatal "apt install (of required development packages)"
mkdir src || fatal "mkdir"
cd src
git clone https://github.com/iovisor/bcc.git || fatal "cloning BCC source from iovisor"
mkdir bcc/build; cd bcc/build
cmake .. || fatal "cmake"
make || fatal "Building BCC from source"
sudo make install || fatal "installing BCC"
cmake -DPYTHON_CMD=python3 .. || fatal "building python3 bindings"
pushd src/python/
( make && sudo make install ) || fatal "installing python bindings"