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

使用示例:

网络

  • 查看占用网络带宽最多的进程

    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

Linux工具- Sysdig的更多相关文章

  1. 第2章 Linux系统安装(3)_SSH连接Linux工具:SecureCRT和WinSCP

    4. SSH连接Linux工具 4.1 Linux网卡配置 (1)临时配置: ifconfig eth0 192.168.32.100 //给eth0网卡指定IP,写在ROM里的,关机会丢失. (2) ...

  2. 发布《Linux工具快速教程》

    发布<Linux工具快速教程> 阶段性的完成了这本书开源书籍,发布出来给有需要的朋友,同时也欢迎更多的朋友加入进来,完善这本书: 本书Github地址:https://github.com ...

  3. Linux工具XFTP、Xshell(centos配置java环境 工具篇 总结一)

    ♣Xmanager5是什么? ♣安装XFTP ♣安装Xshell 1.Xmanager5(官网:https://www.netsarang.com/download/software.html)是全新 ...

  4. Linux工具参考篇(网摘)

    Linux工具参考篇 原文出处:[Linux Tools Quick Tutorial] 1. gdb 调试利器 2. ldd 查看程序依赖库 3. lsof 一切皆文件 4. ps 进程查看器 5. ...

  5. linux 工具学习网站

    推荐一个很不错的linux工具学习网站; 对于一个开发人员来说,我觉得掌握这些工具对于基于linux的应用开发来说事半功倍. http://linuxtools-rst.readthedocs.io/ ...

  6. Kali Linux 工具清单

    Kali Linux 工具清单 Information Gathering acccheck ace-voip Amap Automater bing-ip2hosts braa CaseFile C ...

  7. Linux工具[转]

    ref: https://github.com/linw7/Skill-Tree/blob/master/Linux%E5%B7%A5%E5%85%B7.md Linux工具 Linux下还是有很多超 ...

  8. 推荐两款远程管理Linux工具(基于Windows系统)

    推荐两款远程管理Linux工具(基于Windows系统) 1.Xshell 百度百科:Xshell 是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Microsoft Windows ...

  9. Linux工具快速教程

    看到一linux中常用工具使用教程,非常好.猛击下面的地址 github:https://github.com/me115/linuxtools_rst 在线文档:http://linuxtools- ...

随机推荐

  1. 最新create-react-native-app搭建rn教程

    一.前置条件: 1.nodeJS环境 2.npm 3.yarn 二.安装及项目初始化 1.安装脚手架 npm install -g create-react-native-app 2.用脚手架初始化创 ...

  2. easyUI之Tree(树)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...

  3. springboot自定义filter获取spring容器bean对象

    今天在自己定义的filter中,想要直接注入spring容器的其它bean进行操作,发现不能正常的注入: 原因:web容器加载顺序导致, 加载顺序是listener——filter——servlet, ...

  4. 一百一十一:CMS系统之后端权限验证功能

    实现方式 使用装饰器的形式,将权限判断加在视图上 声明接口需要什么权限,用户访问接口的时候,判断用户是否有此权限 权限判断,接收权限 def permission_required(permissio ...

  5. Linux高级命令 ==> find、grep、sed、awk

    一.find find命令用来在指定目录下查找文件.如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件.并且将查找到的子目录和文件全部进行显示. 语法 find path ...

  6. R语言与概率统计(一) 描述性统计分析

      #查看已安装的包,查看已载入的包,查看包的介绍 ########例题3.1 #向量的输入方法 w<-c(75.0, 64.0, 47.4, 66.9, 62.2, 62.2, 58.7, 6 ...

  7. koa2中间件

    在我看来,前端框架的中间件的思想来源于传统后端的切面编程(AOP)思想,比如我们常见的身份校验(JWT). axios的拦截器也是基于这种程序设计模式的. 在koa中,实际上是由一个数组对象来保存所有 ...

  8. 拒绝LOW ---青鸟影院购票系统

    1.首先我们需要了解这个软件的功能: 1).影院每天更新放映列表,系统支持实时查看,包括电影放映场次的时间: 2).影院提供三类影票:普通票,学生票和赠票: 3).允许用户查看某场次座位的售出情况: ...

  9. python之selenium三种等待方法

    前提: 我们在做Web自动化时,有的时候要等待元素加载出来,才能操作,不然会报错 1.强制等待 2.隐式等待 3.显示等待 内容: 一,强制等待 这个比较简单,就是利用time模块的sleep的方法来 ...

  10. java知识随笔整理-Oracle存储过程优缺点

    优点: 1.存储过程可以使得程序执行效率更高.安全性更好. 2.建立过程不会很耗系统资源,因为过程只是在调用才执行. 3.存储过程可以用于降低网络流量,存储过程代码直接存储于数据库中,所以不会产生大量 ...