Sysdig 超级系统工具开源项目

我要开发同款
匿名用户2015年10月30日
56阅读
开发技术Lua
所属分类管理和监控、DevOps/运维工具
授权协议GPLv2

作品详情

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

使用示例:

网络

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

sysdig-ctopprocs_net

显示主机192.168.0.1的网络传输数据

asbinary:sysdig-s2000-X-cecho_fdsfd.cip=192.168.0.1asASCII:sysdig-s2000-A-cecho_fdsfd.cip=192.168.0.1

查看连接最多的服务器端口

intermsofestablishedconnections:sysdig-cfdcount_byfd.sport"evt.type=accept"intermsoftotalbytes:sysdig-cfdbytes_byfd.sport

查看客户端连接最多的ip

intermsofestablishedconnectionssysdig-cfdcount_byfd.cip"evt.type=accept"intermsoftotalbytessysdig-cfdbytes_byfd.cip

列出所有不是访问apache服务的访问连接

sysdig-p"%proc.name%fd.name""evt.type=acceptandproc.name!=httpd"

容器

查看机器上运行的容器列表及其资源使用情况

sudocsysdig-vcontainers

查看容器上下文的进程列表

sudocsysdig-pc

查看运行在wordpress1容器里CPU的使用率

sudosysdig-pc-ctopprocs_cpucontainer.name=wordpress1

查看运行在wordpress1容器里网络带宽的使用率

sudosysdig-pc-ctopprocs_netcontainer.name=wordpress1

查看在wordpress1容器里使用网络带宽最多的进程

sudosysdig-pc-ctopprocs_netcontainer.name=wordpress1

查看在wordpress1容器里占用I/O字节最多的文件

sudosysdig-pc-ctopfiles_bytescontainer.name=wordpress1

查看在wordpress1容器里网络连接的排名情况

sudosysdig-pc-ctopconnscontainer.name=wordpress1

显示wordpress1容器里所有命令执行的情况

sudosysdig-pc-cspy_userscontainer.name=wordpress1

应用

查看机器所有的HTTP请求

sudosysdig-s2000-A-cecho_fdsfd.port=80andevt.buffercontainsGET

查看机器所有的SQLselect查询

sudosysdig-s2000-A-cecho_fdsevt.buffercontainsSELECT

SeequeriesmadeviaapachetoanexternalMySQLserverhappeninginrealtime

sysdig-s2000-A-cecho_fdsfd.sip=192.168.30.5andproc.name=apache2andevt.buffercontainsSELECT

硬盘I/O

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

sysdig-ctopprocs_file

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

sysdig-cfdcount_byproc.name"fd.type=file"

Seethetopfilesintermsofread+writebytes

sysdig-ctopfiles_bytes

Printthetopfilesthatapachehasbeenreadingfromorwritingto

sysdig-ctopfiles_bytesproc.name=httpd

Basicopensnoop:snoopfileopensastheyoccur

sysdig-p"%12user.name%6proc.pid%12proc.name%3fd.num%fd.typechar%fd.name"evt.type=open

SeethetopdirectoriesintermsofR+Wdiskactivity

sysdig-cfdbytes_byfd.directory"fd.type=file"

SeethetopfilesintermsofR+Wdiskactivityinthe/tmpdirectory

sysdig-cfdbytes_byfd.filename"fd.directory=/tmp/"

ObservetheI/Oactivityonallthefilesnamed'passwd'

sysdig-A-cecho_fds"fd.filename=passwd"

DisplayI/OactivitybyFDtype

sysdig-cfdbytes_byfd.type

进程和CPU使用率

SeethetopprocessesintermsofCPUusage

sysdig-ctopprocs_cpu

SeethetopprocessesforCPU0

sysdig-ctopprocs_cpuevt.cpu=0

Observethestandardoutputofaprocess

sysdig-s4096-A-cstdoutproc.name=cat

性能和错误

Seethefileswheremosttimehasbeenspent

sysdig-ctopfiles_time

Seethefileswhereapachespentmosttime

sysdig-ctopfiles_timeproc.name=httpd

SeethetopprocessesintermsofI/Oerrors

sysdig-ctopprocs_errors

SeethetopfilesintermsofI/Oerrors

sysdig-ctopfiles_errors

SeeallthefaileddiskI/Ocalls

sysdigfd.type=fileandevt.failed=true

Seeallthefailedfileopensbyhttpd

sysdig"proc.name=httpdandevt.type=openandevt.failed=true"

Seethesystemcallswheremosttimehasbeenspent

sysdig-ctopscalls_time

Seethetopsystemcallsreturningerrors

sysdig-ctopscalls"evt.failed=true"

snoopfailedfileopensastheyoccur

sysdig-p"%12user.name%6proc.pid%12proc.name%3fd.num%fd.typechar%fd.name"evt.type=openandevt.failed=true

PrintthefileI/Ocallsthathavealatencygreaterthan1ms:

sysdig-cfileslower1

安全

Showthedirectoriesthattheuser"root"visits

sysdig-p"%evt.arg.path""evt.type=chdiranduser.name=root"

Observesshactivity

sysdig-A-cecho_fdsfd.name=/dev/ptmxandproc.name=sshd

Showeveryfileopenthathappensin/etc

sysdigevt.type=openandfd.namecontains/etc

ShowtheIDofalltheloginshellsthathavelaunchedthe"tar"command

sysdig-rfile.scap-clist_login_shellstar

ShowallthecommandsexecutedbytheloginshellwiththegivenID

sysdig-rtrace.scap.gz-cspy_usersproc.loginshellid=5459

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论