Linux“Perf”工具无法在docker镜像内运行?
作者:互联网
我知道“perf”工具需要安装对应于特定的Linux内核版本.而且我知道所有的docker镜像都使用相同的Linux内核版本,无论Linux发行版本如何.
我在docker中使用ubuntu 16.04并且已经安装了linux-tools-common,启动perf告诉我我还缺少一些包:’
# perf
/usr/bin/perf: line 32: lsb_release: command not found
WARNING: perf not found for kernel 4.9.12
You may need to install the following packages for this specific kernel:
linux-tools-4.9.12-moby
linux-cloud-tools-4.9.12-moby
You may also want to install one of the following packages to keep up to date:
linux-tools-moby
linux-cloud-tools-moby
然后我试着安装我错过的东西:
root@xxxxxx:/# apt-get install linux-tools-4.9.12-moby linux-cloud-tools-4.9.12-moby
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-tools-4.9.12-moby
E: Couldn't find any package by glob 'linux-tools-4.9.12-moby'
E: Couldn't find any package by regex 'linux-tools-4.9.12-moby'
E: Unable to locate package linux-cloud-tools-4.9.12-moby
E: Couldn't find any package by glob 'linux-cloud-tools-4.9.12-moby'
E: Couldn't find any package by regex 'linux-cloud-tools-4.9.12-moby'
root@b2543b6e985d:/# apt-get install linux-tools-moby linux-cloud-tools-moby
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-tools-moby
E: Unable to locate package linux-cloud-tools-moby
(1)太奇怪了,但是如何解决这个安装问题呢?
(2)另外:我仍然感到困惑,如果“perf”和“kernel”之间没有严格匹配,那么“perf”如何在linux的docker中运行良好?
解决方法:
I knew that “perf” tool requires installation correspond to specific linux kernel versions. And I knew that all docker images run with the same linux kernel version, no matter linux distribution version.
仍然可以使用来自其他版本内核的Perf工具(perf_event子系统中的系统调用具有良好的设计并且与旧/新工具兼容).所以,你可以在任何地方找到任何perf二进制文件(不是/usr/bin/perf脚本),检查它的库依赖于(ldd ..path_to_perf / perf)并在Docker中复制perf(并安装libs).
在docker中可能会限制硬件事件,系统范围或内核分析的使用,所以请尝试
> perf -e cycles:u ./program(仅用于用户空间的硬件计数器),
> perf -e task-clock ./program(内核和用户空间的软件定时器),
> perf -e task-clock:u ./program(仅限用户空间的软件定时器),
标签:docker,linux,installation,apt-get,perf 来源: https://codeday.me/bug/20190627/1307917.html