sysdig

https://github.com/draios/sysdig/wiki/Sysdig%20Examples#disk

sysdig is a great solution now.

Some usage cases include (their wiki has some exceptionally interesting examples):

For Disk I/O

  • See the top processes in terms of disk bandwidth usage

    sysdig -c topprocs_file

  • List the processes that are using a high number of files

    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

### Sysdig 使用教程与学习指南 Sysdig 是一款强大的开源工具,能够帮助用户深入了解 Linux 系统的行为以及容器化应用的工作原理。以下是关于如何使用 Sysdig 的一些核心概念和学习资源。 #### 1. 基础安装与配置 要开始使用 Sysdig,首先需要将其安装到目标系统中。对于大多数 Linux 发行版,可以通过包管理器完成安装: ```bash # Ubuntu/Debian sudo apt-get update && sudo apt-get install -y sysdig # CentOS/RHEL sudo yum install -y epel-release sudo yum install -y sysdig ``` 如果希望在容器环境中运行 Sysdig,则可以考虑使用官方 Docker 镜像[^2]。 --- #### 2. 基本命令结构 Sysdig 支持多种过滤条件来捕获特定事件数据。以下是一些常用的命令示例: - **查看当前活动进程** ```bash sudo sysdig -pc ``` - **跟踪指定进程的 I/O 活动** ```bash sudo sysdig proc.name=nginx and evt.type=read ``` - **模拟 `ps` 输出** ```bash sudo sysdig -c pslist ``` 这些基础操作可以帮助快速掌握 Sysdig 的基本功能[^2]。 --- #### 3. 进阶用法:Chisels 脚本 Sysdig 提供了一组内置脚本(称为 Chisels),它们简化了许多复杂的分析任务。例如: - 显示网络连接统计信息: ```bash sudo sysdig -c netstat ``` - 展示磁盘读写情况: ```bash sudo sysdig -c iostat_file ``` 开发者还可以编写自定义 Chisel 来满足特殊需求[^2]。 --- #### 4. 日志记录与回放 除了实时监控外,Sysdig 还支持将捕捉的数据保存为文件以便后续分析。这被称为“时间旅行”特性。 - 记录一段时间内的系统行为: ```bash sudo sysdig -w capture.scap ``` - 回放已录制的日志并执行查询: ```bash sudo sysdig -r capture.scap fd.curl ``` 此功能特别适合调试间歇性问题或离线排查错误。 --- #### 5. 容器环境下的集成 当部署于 Kubernetes 或其他编排平台之上时,Sysdig 不仅能监测主机状态,还能深入洞察单个 Pod 和服务的表现。具体方法可参阅相关文档链接[^2]。 --- #### 6. 推荐的学习材料 为了更全面地理解 Sysdig 功能及其应用场景,建议参考以下资源: - [官方用户手册](https://www.sysdig.com/docs/sysdig-monitor/) - 社区贡献的文章集合[^2] 通过以上途径逐步积累经验后,便能在日常运维工作中更加高效地运用该技术解决实际难题。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值