Sysdig是一个监控工具,可以让系统管理员和开发人员以最全面的方式洞察他们的系统行为。我们可以使用sysdig命令做很多很酷的事情。如果您有更多有趣的用途想要添加到下面的命令示例中,请告诉我们! 1。网络 查看占用网络带宽最多的进程: 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.byfd.sport 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" 2.Containers 查看机器上运行的容器列表及其资源使用情况: sudocsysdig-vcontainers 查看容器Context进程列表: 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 3.使用 查看本机所有HTTP请求: sudosysdig-s2000-A-cecho_fdsfd.port=80andevt.buffercontainsGET 查看所有SQLselectqueriesofthemachine:sudosysdig-s2000-A-cecho_fdsevt.buffercontainsSELECTSeequeriesmadeviaapachetoanexternalMySQLserverhappeninginrealtimesysdig-s2000-A-cecho_fdsfd.sip=192.168.30.5andproc.name=apache2andevtsys.buffercontainsSELECTd4.HarddiskI/OBandwidthmostusedView过程d4.硬盘I/O-ctopprocs_file 列出使用大量文件描述符的进程:sysdig-cfdcount_byproc.name"fd.type=file"Seethetopfilesintermsofread+writebytessysdig-ctopfiles_bytesPrintthetopfilesthatapachehasbeenreadingfromorwritingtosysdig-ctopfiles_bytesproc.name=httpdBasicopensnoop:snoopfileopensastheyoccursysdig-p"%12user.name%6proc.pid%12proc.name%3fd.num%fd.typechar%fd.name"evt.type=openSeethetopdirectoriesintermsofR+Wdiskactivitysysdig-cfdbytes_byfd.directory"fd.type=file"SeethetopfilesofR+Wdiskactivityinthe/tmpdirectorysysdig-cfdbytes_byfd.filename"fd.directory=/tmp/"ObservetheI/Oactivityonallthefilesnamed'passwd'sysdig-A-cecho_fds"fd.filename=passwd"DisplayI/OactivitybyFDtypesysdig-cfdbytes_byfd.type 进程和CPU使用率:SeethetopprocessesintermsofCPUusagesysdig-ctopprocs_cpuSeethetopprocessesforCPU0sysdig-ctopprocs_cpuevt.cpu=0Observethestandardoutputofaprocesssysdig-s4096-A-cstdoutproc.name=猫 性能和错误:Seethefileswheremosttimehasbeenspentsysdig-ctopfiles_timeSeethefileswhereapachespentmosttimesysdig-ctopfiles_timeproc.name=httpdSeethetopprocessesintermsofI/Oerrorssysdig-ctopprocs_errorsSeethetopfilesintermsofI/Oerrorssysdig-ctopfiles_errorsSeeallthefaileddiskI/Ocallssysdigfd.type=fileandevt.failed=trueSeeallthefailedfileopensbyhttpdsysdig"proc.name=httpdandevt.type=openandevt.failed=true"Seethesystemcallswheremosttimehasbeenspentsysdig-ctopscalls_timeSeethetopsystemcallsreturningerrorssysdig-ctopscalls"evt.failed=true"snoopfailedfileopensastheyoccursysdig-p"%12user.name%6proc.pid%12proc.name%3fd.num%fd.typechar%fd.name"evt.type=openandevt.failed=truePrintthefileI/Ocallsthathavealatencygreaterthan1ms:sysdig-cfileslower1 5.安全显示用户"root"访问sysdig-p"%evt.arg.path""evt.type=chdiranduser.name=root"Observessactivitysysdig-A-cecho_fdsfd.name=/dev/ptmxandproc.name=sshdShoweveryfileopenthathappensin/etcsysdigevt.type=的目录openandfd.namecontains/etcShowtheIDofalltheloginshellthathavelaunchedthe"tar"commandsysdig-rfile.scap-clist_login_shellstarShowallthecommandsexecutedbytheloginshellwiththegivenIDsysdig-rtrace.scap.gz-cspy_usersproc.loginshellid=5459 译文:http://www.orgsysdig/wiki-samp
