`

超级系统工具 Sysdig

阅读更多

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

分享到:
评论

相关推荐

    sysdig-0.26.4-x86_64.rpm

    sysdig可用于捕获系统调用信息 官方文档 https://github.com/draios/sysdig/wiki

    sysdig-0.26.7-x86_64.rpm&dkms-2.8.1-4.20200214git5ca628c.el7.noarch.rpm

    系统分析与排障工具sysdig 的rpm包,不好下载,整理了一份方便大家使用,应用环境(Centos7 x86_64版) rpm包以及依赖包dkms。版本:sysdig-0.26.7-x86_64.rpm & dkms-2.8.1-4.20200214git5ca628c.el7.noarch.rpm

    sysdig:具有对容器的一流支持Linux系统探索和故障排除工具

    Sysdig是一种通用的系统可见性工具,对容器具有本机支持: ~$ sysdig Csysdig是用于sysdig的简单,直观且可完全自定义的curses UI: ~$ csysdig sysdig会做什么,为什么要使用它? Sysdig是提供深层系统可见性的...

    arm64平台 外设寄存器读写工具 内存测试小工具 系统调用工具 存储flash操作工具 音频录制工具

    例如,`strace` 或 `sysdig` 可以监控和记录程序的系统调用,这对于理解程序如何与内核交互,以及查找性能瓶颈或错误非常有帮助。通过这些工具,开发者可以追踪到每一个打开文件、网络连接或进程创建等操作。 4. **...

    sysdig-inspect:Sysdig Inspect-用于容器故障排除和安全调查的功能强大的开源界面

    Inspect的用户界面旨在直观地浏览数据密集型sysdig捕获,其中包含Linux系统的精细系统,网络和应用程序活动。 Sysdig Inspect可帮助您了解趋势,关联指标并找到大海捞针。 它具有旨在支持性能和安全性调查的功能,并...

    构建高交互型蜜罐监控系统

    总的来说,构建高交互型蜜罐监控系统结合Sysdig和Falco这样的工具,可以形成一个强大的安全防御体系,有效检测和预防网络攻击。通过深入了解和分析这些工具的工作原理和实践操作,网络管理员可以更好地保护网络资源...

    sysdigcloud-kubernetes:Kubernetes上的Sysdig Cloud

    该项目包含将Sysdig本地版本部署到Kubernetes基础架构所需的工具。 使用Sysdig安装程序二进制文件进行部署 从3.5.0版开始,此存储库托管Sysdig安装程序二进制文件的发行版。 请参考以获取使用指导。 发行版 使用...

    Monitoring-with-Sysdig:Sysdig监控

    Sysdig是一款强大的开源系统探查工具,它提供了一种深入观察Linux系统运行状态的方法,包括系统调用、网络活动、进程行为等。Sysdig监控则是其监控解决方案,可以帮助IT管理员实时了解并诊断系统的性能问题,确保...

    Linux操作系统内核实习_operation6rz_linux操作系统内核_操作系统内核_

    9. **调试工具**:gdb、strace、sysdig等工具是分析和调试内核行为的重要助手。学习如何使用它们能提升对内核运行的理解。 10. **源码阅读**:阅读Linux内核源码是深入学习的高级阶段。通过源码,可以了解内核内部...

    mobydig:在Mac上的Docker上运行Sysdig的映像

    在Mac上的Docker上运行Sysdig的映像(但不仅如此,它应在Linux主机上的docker引擎上运行)#为什么? 为什么为Mac的Docker使用特定的映像? Sysdig提供了一个Docker映像以在Docker上但在Linux主机上运行sysdig / ...

    Linux 入门,培训,教程,调试工具使用指南.rar

    Linux是世界上最受欢迎的开源操作系统之一,它为个人用户、企业级服务器和超级计算机提供了一个强大且灵活的平台。本教程旨在帮助初学者踏入Linux的世界,同时也适用于那些希望深入学习和提升Linux技能的用户。我们...

    ARM应用系统开发详解(linux)

    调试工具如GDB、strace、sysdig等帮助开发者跟踪和优化代码。 ### 8. 系统优化与性能调优 在实际应用中,性能和资源效率是关键考虑因素。这包括内存管理、进程调度、中断处理等方面的优化。通过分析工具如perf、...

    LINUX系统分析与高级编程技术1

    这部分内容需要了解内核模块的编译与加载,以及如何使用strace和sysdig等工具来监控系统调用。 系统进程和内存管理涉及到进程的生命周期、调度、通信以及内存分配和管理。理解fork、exec、wait和kill等进程控制函数...

    terraform-provider-sysdig:Sysdig Terraform提供程序。 允许将Sysdig Secure策略作为代码处理

    Sysdig的Terraform提供商网站: : 邮件列表:要求 > 0.12.x > 1.14(构建提供程序插件)建立提供者将存储$GOPATH/src/github.com/draios/terraform-provider-sysdig到: $GOPATH/src/github....git clone git@github....

    IT运维工程师的23个细节进阶.docx

    13. **故障排查与性能优化**: 系统性能分析工具如Systemtap和Sysdig有助于定位问题,Percona's TPCC-MYSQL Tool用于数据库性能基准测试。 以上只是IT运维工程师23个细节进阶中的部分要点,实际工作中还需要结合具体...

    Linux系统分析与高级编程技术_____

    8. **性能分析与调优**:利用工具如`strace`, `gdb`, `perf`, `sysdig`等进行系统和程序性能分析,学习如何调整系统参数和代码优化,以提升系统整体效率。 9. **安全性与权限**:理解Linux的用户和组管理,以及权限...

    Linux系统内核调试的研究.pdf

    9. **系统调用调试**:通过`strace`或`sysdig`等工具,可以跟踪系统调用,理解程序与内核之间的交互。 10. **故障转储(Kernel panic)**:当内核遇到无法恢复的错误时,会产生一个故障转储,记录下当时的系统状态,...

    齐鲁工业大学操作系统实验报告

    学生可能需要完成一些高级任务,如编写系统调用,或者分析和优化系统的性能,比如通过strace或sysdig工具进行系统调用跟踪。 这些实验不仅帮助学生巩固理论知识,还提高了他们的编程和问题解决能力。每个实验报告都...

Global site tag (gtag.js) - Google Analytics