Sysdig是一个超级系统工具,比strace、tcpdump、lsof加起来还强大。可用来捕获系统状态信息,保存数据并进行过滤和分析。使用Lua开发,提供命令行接口以及强大的交互界面。
使用示例:
网络
查看占用网络带宽最多的进程
sysdig-ctopprocs_et
显示主机192.168.0.1的网络传输数据
asbiary:sysdig-s2000-X-cecho_fdsfd.cip=192.168.0.1asASCII:sysdig-s2000-A-cecho_fdsfd.cip=192.168.0.1
查看连接最多的服务器端口
itermsofestablishedcoectios:sysdig-cfdcout_byfd.sport"evt.type=accept"itermsoftotalbytes:sysdig-cfdbytes_byfd.sport
查看客户端连接最多的ip
itermsofestablishedcoectiossysdig-cfdcout_byfd.cip"evt.type=accept"itermsoftotalbytessysdig-cfdbytes_byfd.cip
列出所有不是访问apache服务的访问连接
sysdig-p"%proc.ame%fd.ame""evt.type=acceptadproc.ame!=httpd"
容器查看机器上运行的容器列表及其资源使用情况
sudocsysdig-vcotaiers
查看容器上下文的进程列表
sudocsysdig-pc
查看运行在wordpress1容器里CPU的使用率
sudosysdig-pc-ctopprocs_cpucotaier.ame=wordpress1
查看运行在wordpress1容器里网络带宽的使用率
sudosysdig-pc-ctopprocs_etcotaier.ame=wordpress1
查看在wordpress1容器里使用网络带宽最多的进程
sudosysdig-pc-ctopprocs_etcotaier.ame=wordpress1
查看在wordpress1容器里占用I/O字节最多的文件
sudosysdig-pc-ctopfiles_bytescotaier.ame=wordpress1
查看在wordpress1容器里网络连接的排名情况
sudosysdig-pc-ctopcoscotaier.ame=wordpress1
显示wordpress1容器里所有命令执行的情况
sudosysdig-pc-cspy_userscotaier.ame=wordpress1
应用查看机器所有的HTTP请求
sudosysdig-s2000-A-cecho_fdsfd.port=80adevt.buffercotaisGET
查看机器所有的SQLselect查询
sudosysdig-s2000-A-cecho_fdsevt.buffercotaisSELECT
SeequeriesmadeviaapachetoaexteralMySQLserverhappeigirealtime
sysdig-s2000-A-cecho_fdsfd.sip=192.168.30.5adproc.ame=apache2adevt.buffercotaisSELECT
硬盘I/O查看使用硬盘带宽最多的进程
sysdig-ctopprocs_file
列出使用大量文件描述符的进程
sysdig-cfdcout_byproc.ame"fd.type=file"
Seethetopfilesitermsofread+writebytes
sysdig-ctopfiles_bytes
Pritthetopfilesthatapachehasbeereadigfromorwritigto
sysdig-ctopfiles_bytesproc.ame=httpd
Basicopesoop:soopfileopesastheyoccur
sysdig-p"%12user.ame%6proc.pid%12proc.ame%3fd.um%fd.typechar%fd.ame"evt.type=ope
SeethetopdirectoriesitermsofR+Wdiskactivity
sysdig-cfdbytes_byfd.directory"fd.type=file"
SeethetopfilesitermsofR+Wdiskactivityithe/tmpdirectory
sysdig-cfdbytes_byfd.fileame"fd.directory=/tmp/"
ObservetheI/Oactivityoallthefilesamed'passwd'
sysdig-A-cecho_fds"fd.fileame=passwd"
DisplayI/OactivitybyFDtype
sysdig-cfdbytes_byfd.type
进程和CPU使用率SeethetopprocessesitermsofCPUusage
sysdig-ctopprocs_cpu
SeethetopprocessesforCPU0
sysdig-ctopprocs_cpuevt.cpu=0
Observethestadardoutputofaprocess
sysdig-s4096-A-cstdoutproc.ame=cat
性能和错误Seethefileswheremosttimehasbeespet
sysdig-ctopfiles_time
Seethefileswhereapachespetmosttime
sysdig-ctopfiles_timeproc.ame=httpd
SeethetopprocessesitermsofI/Oerrors
sysdig-ctopprocs_errors
SeethetopfilesitermsofI/Oerrors
sysdig-ctopfiles_errors
SeeallthefaileddiskI/Ocalls
sysdigfd.type=fileadevt.failed=true
Seeallthefailedfileopesbyhttpd
sysdig"proc.ame=httpdadevt.type=opeadevt.failed=true"
Seethesystemcallswheremosttimehasbeespet
sysdig-ctopscalls_time
Seethetopsystemcallsreturigerrors
sysdig-ctopscalls"evt.failed=true"
soopfailedfileopesastheyoccur
sysdig-p"%12user.ame%6proc.pid%12proc.ame%3fd.um%fd.typechar%fd.ame"evt.type=opeadevt.failed=true
PritthefileI/Ocallsthathavealatecygreatertha1ms:
sysdig-cfileslower1
安全Showthedirectoriesthattheuser"root"visits
sysdig-p"%evt.arg.path""evt.type=chdiraduser.ame=root"
Observesshactivity
sysdig-A-cecho_fdsfd.ame=/dev/ptmxadproc.ame=sshd
Showeveryfileopethathappesi/etc
sysdigevt.type=opeadfd.amecotais/etc
ShowtheIDofallthelogishellsthathavelauchedthe"tar"commad
sysdig-rfile.scap-clist_logi_shellstar
ShowallthecommadsexecutedbythelogishellwiththegiveID
sysdig-rtrace.scap.gz-cspy_usersproc.logishellid=5459










评论