当前位置:网站首页>bcc安装和基本工具使用说明
bcc安装和基本工具使用说明
2022-04-23 05:58:00 【魏言华】
目录
bcc 提供的所有工具就都安装到 /usr/share/bcc/tools 这个目录中了。不过这里提醒你,bcc 软件包默认不会把这些工具配置到系统的 PATH 路径中,所以你得自己手动配置:
$ export PATH=$PATH:/usr/share/bcc/tools
0. bcc安装
0.1 yum 安装
yum install bcc-tools
0.2 源码安装
Install build dependencies:
sudo yum groupinstall -y "Development tools"
sudo yum install -y elfutils-libelf-devel cmake3 git bison flex ncurses-devel
sudo yum install -y luajit luajit-devel # for Lua support
Install and compile LLVM:
curl -LO http://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz
curl -LO http://releases.llvm.org/7.0.1/cfe-7.0.1.src.tar.xz
tar -xf cfe-7.0.1.src.tar.xz
tar -xf llvm-7.0.1.src.tar.xz
mkdir clang-build
mkdir llvm-build
cd llvm-build
cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../llvm-7.0.1.src
make
sudo make install
cd ../clang-build
cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../cfe-7.0.1.src
make
sudo make install
cd ..
Install and compile BCC:
git clone GitHub - iovisor/bcc: BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
mkdir bcc/build; cd bcc/build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
PS:
1. 使用make 不能使用make -j8
2. ln -s python2 python #创建python的软连接
3. make install路径:/usr/share/bcc/tools
1. cachestat
./cachestat 1 3
TOTAL MISSES HITS DIRTIES BUFFERS_MB CACHED_MB
0 0 0 0 3 303
1 0 1 0 3 303
0 0 0 0 3 303
你可以看到,cachestat 的输出其实是一个表格。每行代表一组数据,而每一列代表不同的缓存统计指标。这些指标从左到右依次表示
TOTAL ,表示总的 I/O 次数;
MISSES ,表示缓存未命中的次数;
HITS ,表示缓存命中的次数;
DIRTIES, 表示新增到缓存中的脏页数;
BUFFERS_MB 表示 Buffers 的大小,以 MB 为单位;
CACHED_MB 表示 Cache 的大小,以 MB 为单位。
2. cachetop
./cachetop
13:52:30 Buffers MB: 3 / Cached MB: 391 / Sort: HITS / Order: ascending
PID UID CMD HITS MISSES DIRTIES READ_HIT% WRITE_HIT%
1506 root cachetop 1 0 0 100.0% 0.0%
1534 nginx nginx 1 3 0 25.0% 50.0%
1544 root curl 20 0 0 100.0% 0.0%
1543 root bash 198 4 0 98.0% 2.0%
1543 root curl 1993 80 0 96.1% 3.9%
它的输出跟 top 类似,默认按照缓存的命中次数(HITS)排序,展示了每个进程的缓存命中情况。具体到每一个指标,这里的 HITS、MISSES和DIRTIES ,跟 cachestat 里的含义一样,分别代表间隔时间内的缓存命中次数、未命中次数以及新增到缓存中的脏页数。
而 READ_HIT 和 WRITE_HIT ,分别表示读和写的缓存命中率。
3. funccount
./funccount -i 1 c:malloc
Tracing 1 functions for "b'c:malloc'"... Hit Ctrl-C to end.
FUNC COUNT
b'malloc' 2
FUNC COUNT
b'malloc' 1
FUNC COUNT
b'malloc' 1
FUNC COUNT
b'malloc' 1
FUNC COUNT
b'malloc' 1
funccount 支持一些参数, 比如-p指定某个进程ID, -i指定输出的时间间隔。它当前只能同时支持最多1000个跟踪对象(probe), 对于fmt.*来说,函数不多还OK, 但是如果跟踪所有的libgo中的函数就有问题了
# funccount 'go:*'
maximum of 1000 probes allowed, attempted 21178
嗯哼, 不工作了。 就像 bcc/BPF 中其它一些问题一样, 如果这个限制在应用中阻碍太多的话我们考虑寻找一个方式来解决它。
4. trace
4.1 trace
./trace do_sys_open
PID TID COMM FUNC
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
1 1 systemd do_sys_open
1 1 systemd do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
1 1 systemd do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
832 832 irqbalance do_sys_open
4.2 trace查看它的传入的参数
./trace '/root/bcc_test/test_malloc:add "%d %d" arg1, arg2' PID TID COMM FUNC - 1691 1691 test_malloc add 2 3 1692 1692 test_malloc add 2 3 1693 1693 test_malloc add 2 3 1694 1694 test_malloc add 2 3 1695 1695 test_malloc add 2 3 1696 1696 test_malloc add 2 3
版权声明
本文为[魏言华]所创,转载请带上原文链接,感谢
https://blog.csdn.net/u013743253/article/details/120707690
边栏推荐
- freeCodeCamp----prob_calculator练习
- 七牛上传图片(前台JS+后台C#API获取token)
- Counts the number of occurrences of each character in the string
- Leak detection and vacancy filling (III)
- Add serial number to El table
- Color string conversion
- 1-2 NodeJS的特点
- file_ get_ Two solutions to content accessing SSL errors
- Leetcode刷题之实现strStr()
- 【代码解析(2)】Communication-Efficient Learning of Deep Networks from Decentralized Data
猜你喜欢
随机推荐
端口占用1
1-3 组件与模块
时间格式不对,运行sql文件报错
批量修改/批量更新数据库某一个字段的值
tp5 报错variable type error: array解决方法
1-4 NodeJS的安装之配置可执行脚本
Counts the number of occurrences of each character in the string
Baidu map coordinates, Google coordinates and Tencent coordinates are mutually transformed
.NET类型转移
1-2 NodeJS的特点
TP5 uses redis
The time format is incorrect, and an error is reported when running the SQL file
常用网站汇总
【代码解析(3)】Communication-Efficient Learning of Deep Networks from Decentralized Data
NodeJS 模块之间的使用
freeCodeCamp----prob_calculator练习
Solution to page cache problem (use with caution)
fdfs启动
Implementation of leetcode question brushing str ()
Scientists say Australian plan to cull up to 10,000 wild horses doesn’t go far enough