可以用sysdig命令做很多很酷的事情

网络

查看占用网络带宽最多的进程
sysdig -c topprocs_net
显示主机192.168.0.1的网络传输数据
as binary:
sysdig -s2000 -X -c echo_fds fd.cip=192.168.0.1
as ASCII:
sysdig -s2000 -A -c echo_fds fd.cip=192.168.0.1
查看连接最多的服务器端口
in terms of established connections:
sysdig -c fdcount_by fd.sport "evt.type=accept"
in terms of total bytes:
sysdig -c fdbytes_by fd.sport
查看客户端连接最多的ip
in terms of established connections
sysdig -c fdcount_by fd.cip "evt.type=accept"
in terms of total bytes
sysdig -c fdbytes_by fd.cip
列出所有不是访问apache服务的访问连接
sysdig -p"%proc.name %fd.name" "evt.type=accept and proc.name!=httpd"

容器

查看机器上运行的容器列表及其资源使用情况
sudo csysdig -vcontainers
查看容器上下文的进程列表
sudo csysdig -pc
查看运行在wordpress1容器里CPU的使用率
sudo sysdig -pc -c topprocs_cpu container.name=wordpress1
查看运行在wordpress1容器里网络带宽的使用率
sudo sysdig -pc -c topprocs_net container.name=wordpress1
查看在wordpress1容器里使用网络带宽最多的进程
sudo sysdig -pc -c topprocs_net container.name=wordpress1
查看在wordpress1 容器里占用 I/O 字节最多的文件
sudo sysdig -pc -c topfiles_bytes container.name=wordpress1
查看在wordpress1 容器里网络连接的排名情况
sudo sysdig -pc -c topconns container.name=wordpress1
显示wordpress1容器里所有命令执行的情况
sudo sysdig -pc -c spy_users container.name=wordpress1

应用

查看机器所有的HTTP请求
sudo sysdig -s 2000 -A -c echo_fds fd.port=80 and evt.buffer contains GET
查看机器所有的SQL select查询
sudo sysdig -s 2000 -A -c echo_fds evt.buffer contains SELECT
See queries made via apache to an external MySQL server happening in real time
sysdig -s 2000 -A -c echo_fds fd.sip=192.168.30.5 and proc.name=apache2 and evt.buffer contains SELECT

硬盘 I/O

查看使用硬盘带宽最多的进程
sysdig -c topprocs_file
列出使用大量文件描述符的进程
sysdig -c fdcount_by proc.name "fd.type=file"
See the top files in terms of read+write bytes
sysdig -c topfiles_bytes
Print the top files that apache has been reading from or writing to
sysdig -c topfiles_bytes proc.name=httpd
Basic opensnoop: snoop file opens as they occur
sysdig -p "%12user.name %6proc.pid %12proc.name %3fd.num %fd.typechar %fd.name" evt.type=open
See the top directories in terms of R+W disk activity
sysdig -c fdbytes_by fd.directory "fd.type=file"
See the top files in terms of R+W disk activity in the /tmp directory
sysdig -c fdbytes_by fd.filename "fd.directory=/tmp/"
Observe the I/O activity on all the files named 'passwd'
sysdig -A -c echo_fds "fd.filename=passwd"
Display I/O activity by FD type
sysdig -c fdbytes_by fd.type

进程和CPU使用率

See the top processes in terms of CPU usage
sysdig -c topprocs_cpu
See the top processes for CPU 0
sysdig -c topprocs_cpu evt.cpu=0
Observe the standard output of a process
sysdig -s4096 -A -c stdout proc.name=cat

性能和错误

See the files where most time has been spent
sysdig -c topfiles_time
See the files where apache spent most time
sysdig -c topfiles_time proc.name=httpd
See the top processes in terms of I/O errors
sysdig -c topprocs_errors
See the top files in terms of I/O errors
sysdig -c topfiles_errors
See all the failed disk I/O calls
sysdig fd.type=file and evt.failed=true
See all the failed file opens by httpd
sysdig "proc.name=httpd and evt.type=open and evt.failed=true"
See the system calls where most time has been spent
sysdig -c topscalls_time
See the top system calls returning errors
sysdig -c topscalls "evt.failed=true"
snoop failed file opens as they occur
sysdig -p "%12user.name %6proc.pid %12proc.name %3fd.num %fd.typechar %fd.name" evt.type=open and evt.failed=true
Print the file I/O calls that have a latency greater than 1ms:
sysdig -c fileslower 1

安全

Show the directories that the user "root" visits
sysdig -p"%evt.arg.path" "evt.type=chdir and user.name=root"
Observe ssh activity
sysdig -A -c echo_fds fd.name=/dev/ptmx and proc.name=sshd
Show every file open that happens in /etc
sysdig evt.type=open and fd.name contains /etc
Show the ID of all the login shells that have launched the "tar" command
sysdig -r file.scap -c list_login_shells tar
Show all the commands executed by the login shell with the given ID
sysdig -r trace.scap.gz -c spy_users proc.loginshellid=5459

原文链接:http://www.sysdig.org/wiki/sysdig-examples/

网摘文章,如有不妥,请联系我们!

【转载】超级系统工具Sysdig,比 strace、tcpdump、lsof 加起来还强大的更多相关文章

  1. Linux工具- Sysdig

    Sysdig 是一个超级系统工具,比 strace.tcpdump.lsof 加起来还强大.可用来捕获系统状态信息,保存数据并进行过滤和分析.使用 Lua 开发,提供命令行接口以及强大的交互界面. 使 ...

  2. 使用 ps、strace、lsof 进行 Linux 进程 trouble-shooting

      linux_observability_tools 介绍 在Linux 下进行进程的排错,有很多方法.比如,修改源代码,print出一些关键的信息,如果代码是Python 的话,可以使用trace ...

  3. [转载]性能测试工具 2 步解决 too many open files 的问题,让服务器支持更多连接数

    [转载]性能测试工具 2 步解决 too many open files 的问题,让服务器支持更多连接数 大话性能 · 2018年10月09日 · 最后由 大话性能 回复于 2018年10月09日 · ...

  4. https://www.jqhtml.com/30047.html strace + 命令: 这条命令十分强大,可以定位你程序到底是哪个地方出了问题

    https://www.jqhtml.com/30047.html 我的Linux手册 服务器 浏览数:72 2019-1-30 原文链接 基础安装 # CentOS sudo yum install ...

  5. CSS3 Generator提供了13个CSS3较为常用的属性代码生成工具,而且可以通过这款工具除了在线生成效果代码之外,还可以实时看到你修改的效果,以及浏览器的兼容性。

    CSS3 Generator提供了13个CSS3较为常用的属性代码生成工具,而且可以通过这款工具除了在线生成效果代码之外,还可以实时看到你修改的效果,以及浏览器的兼容性. CSS3 Generator ...

  6. 转载:monkeyrunner工具

    前言: 最近开始研究Android自动化测试方法,对其中的一些工具.方法和框架做了一些简单的整理,其中包括 android测试框架.CTS.Monkey.Monkeyrunner.benchmark. ...

  7. [转载]Process工具类,提供设置timeout功能

    FROM:http://segmentfault.com/blog/lidonghao/1190000000372535 在前一篇博文中,简单介绍了如何使用Process类来调用命令行的功能,那样使用 ...

  8. [转载][效率工具推荐]Mathpix – 将图片数学公式转换为 LaTeX

    转自小众软件:Mathpix – 将图片数学公式转换为 LaTeX Mathpix 是一款跨平台(Windows.macOS.Linux)的 OCR 工具,它能够识别复杂的数学公式,并将其转换为 La ...

  9. (转载)测试工具monkey

    转自http://www.418log.org/post-32.html 1)进入shell 在桌面点开始--运行 输入cmd 点确定 或打开 cmd.exe 进入sdk tools目录如: 1 C: ...

  10. 【转载】Vue自定义指令实现pc端加载更多

    转载来源:https://www.86886.wang/detail/5a6f19e644f9da55274c3bbd,谢谢作者分享! 原理 document.documentElement.scro ...

随机推荐

  1. KingbaseES Clusterware 高可用案例之---构建iSCSI共享存储

    案例说明: 在KingbaseES Clusterware高可用的架构中,集群节点需要访问共享的存储设备,可以使用FC SAN.iscsi SAN.NAS等存储设备.本案例详细描述了,在Linux系统 ...

  2. KingbaseES 查询优化消除SubPlan

    说明: 日常业务系统在使用SQL语句进行查询时,开发人员容易将sql查询的子查询放到select语句中进行使用,会造成sql性能的下降. 数据准备: test=# test=# select coun ...

  3. python爬虫爬取科技报告数据,共计40余万条(来自国家科技报告服务系统)

    按学科分类[中图分类] 共计三十余万条科技报告数据 爬取的网址:https://www.nstrs.cn/kjbg/navigation !!! 如果要完整地跑起来代码,需要先看一下我的这篇博客,完成 ...

  4. Windows11右键菜单设置成Win10旧版模式

    Windows按键+X,打开终端(cmd),复制命令    reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c ...

  5. 【VMware vSAN】创建vSAN Max集群并配置挂载远程数据存储。

    VMware Explore 2023大会上,VMware正式发布了vSAN Max,这是VMware的一种全新分解存储架构,可以为vSphere集群提供PB级分解存储.vSAN Max是基于vSAN ...

  6. #并查集,树状数组#洛谷 5610 [Ynoi2013] 大学

    题目 分析 设最大值为 \(mx\),考虑每个数最多被除以 \(\log{mx}\) 次,那么加上树状数组的维护为 \(O(n\log{n}\log{mx})\) 问题就是如何快速找到这些位置,可以对 ...

  7. Spring Boot 2.X系列教程:七天从无到有掌握Spring Boot-持续更新

    目录 简介 Spring Boot的基本操作 Spring Boot的构建和部署 Spring Boot工具 Spring Boot的测试 Spring Boot中使用JPA Spring Boot和 ...

  8. OpenHarmony 4.0 Beta1发布,邀您体验

      初夏之际,OpenAtom OpenHarmony(简称"OpenHarmony") 4.0 Beta1版本如期而至.4.0 Beta1版本在3.2 Release版本基础上, ...

  9. OpenHarmony Docker移植实践

     Docker简介 从操作系统诞生之日起,虚拟化技术就不断的演进与发展,结合目前云原生的发展态势,容器无疑是其中的重要一环. Docker是一个开源的软件项目,可以在Linux操作系统上提供一层额外的 ...

  10. FreeMarker 去除循环末尾的符号

    在使用 FreeMarker 模板引擎来生成文件时,经常会使用到 list 标签用于循环生成. 有时会遇到需要处理末尾符号的情况,比如 Json 文件,循环生成的标签中末尾是不需要 , 的,例如: & ...