sysdig现在可以监控的容器有 Docker, LXC, 和libvirt-lxc,同时还可以监控 K8s,它提供了一些凿子命令。

命令格式

sysdig [options] [-p <output_format>] [filter]

常用option

-c <chiselname> <chiselargs> 或者 --chisel <chiselname> <chiselargs>运行指定的凿子,如果这个凿子需要参数,就在chiselname 参数后面传递进去。
-cl, --list-chisels,列出所有可用的凿子,可以在目录中/usr/share/sysdig/chisels列举出来。
-C <file_size>, --file-size=<file_size>在往文件里写事件之前检查文件大小是否操作最大值,如果超过定义的最大值就关闭当前文件,并定义一 个新的文件。-w 定义保存文件的命名规范,文件名字后缀会带有数字,一般从0 开始。-W 定义多少文件会被保存。file_size单位为bytes 如10^6。
-i <chiselname>, 或者 --chisel-info <chiselname> 查询凿子的详情
-j 或者 --json 使用JSON格式打印事件。
-p <output_format>, --print=<output_format>指定打印事件的格式,
-pc或者 -pcontainer 用于docker等容器事件的打印.
-pk 或者-pkubernetes 用于K8s 事件格式的打印.
-pm or -pmesos 用于mesos 事件格式的打印.
-P, --progress Print progress on stderr while processing trace files

重点说明

事件日志格式可以通过 -p 定义, 可以使用的字段可以通过命令查询: 'sysdig -l'.

-pc或者 -pcontainer 用于docker等容器事件的打印.默认格式为:

%evt.num %evt.outputtime %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info

-pk 或者-pkubernetes 用于K8s 事件格式的打印.默认格式为:

%evt.num %evt.outputtime %evt.cpu %k8s.pod.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info

pm 或者 -pmesos 用于mesos 事件格式的打印..默认格式为:

%evt.num %evt.outputtime %evt.cpu %mesos.task.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info

命令样例

sysdig -cl # -cl, --list-chisels 列出所有可用的凿子

sysdig -i lscontainers # -i chiselname, --chisel-info 列出凿子命令的详细信息

sysdig -c lscontainers 所有在运行的容器

sysdig -pc -c topprocs_cpu 根据CPU占用率列出所有在运行的容器

sysdig -pcontainer -c topprocs_cpu 根据CPU占用率列出所有在运行的容器

其他一些chisel

topcontainers_cpu : 根据cpu 使用率对容器进行排序。

topcontainers_error: 根据错误数 使用率对容器进行排序。

topcontainers_file: 根据磁盘读写 使用率对容器进行排序。

topcontainers_net: 根据网络I/O 使用率对容器进行排序。

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐