执行命令/usr/share/bcc/tools/filetop -C,报错:
modprobe: FATAL: Module kheaders not found.
Unable to find kernel headers. Try rebuilding kernel with CONFIG_IKHEADERS=m (module) or installing the kernel development package for your running kernel version.
chdir(/lib/modules/3.10.0-1127.18.2.el7.x86_64/build): No such file or directory
Traceback (most recent call last):
File "./filetop", line 163, in <module>
b = BPF(text=bpf_text)
File "/usr/lib/python2.7/site-packages/bcc/__init__.py", line 359, in __init__
raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>
解决方法:
1、http://rpmfind.net/linux/centos/7.8.2003/updates/x86_64/Packages
进入网址,搜索找到对应的内核版本的文件
2、使用命令下载对应版本的内核文件,我的内核版本是3.10.0-1127.18.2.el7.x86_64
wget http://rpmfind.net/linux/centos/7.8.2003/updates/x86_64/Packages/kernel-devel-3.10.0-1127.18.2.el7.x86_64.rpm
3、安装文件
rpm -Uvh kernel-devel-3.10.0-1127.18.2.el7.x86_64.rpm
4、检查是否安装成功
ls /usr/src/kernels
5、再次执行/usr/share/bcc/tools/filetop -C,不报错了,问题解决