sysdig 超级系统工具

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

使用示例

网络

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

sysdig-probe-loader  (不执行,下面会报错)

sysdig -c topprocs_net
Bytes               Process             PID                 
--------------------------------------------------------------------------------
18.03KB             prometheus          1408
388B                sshd                1495

显示主机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"

应用

查看机器所有的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

硬盘 I/O

查看使用硬盘带宽最多的进程

sysdig -c topprocs_file

列出使用大量文件描述符的进程

sysdig -c fdcount_by proc.name "fd.type=file"

更多用法参看:

https://www.oschina.net/p/sysdig?hmsr=aladdin1e1

https://www.cnblogs.com/NiceTime/p/7640558.html   安装

原文地址:https://www.cnblogs.com/zjz20/p/13849778.html