功能强大的系统工具Sysdig命令实例介绍

Sysdig是一个能够让系统管理员和开发人员以前所未有方式洞察其系统行为的监控工具。我们可以用sysdig命令做很多很酷的事情。你如果有更有趣的用法,想添加到下面的命令例子中,请告诉我们!

1.网络

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


  1. sysdig -c topprocs_net 

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


  1. as binary:  
  2. sysdig -s2000 -X -c echo_fds fd.cip=192.168.0.1  
  3. as ASCII:  
  4. sysdig -s2000 -A -c echo_fds fd.cip=192.168.0.1 

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


  1. in terms of established connections:  
  2. sysdig -c fdcount_by fd.sport "evt.type=accept"  
  3. in terms of total bytes:  
  4. sysdig -c fdbytes_by fd.sport 

查看客户端连接最多的ip:


  1. in terms of established connections  
  2. sysdig -c fdcount_by fd.cip "evt.type=accept"  
  3. in terms of total bytes  
  4. sysdig -c fdbytes_by fd.cip 

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


  1. sysdig -p"%proc.name %fd.name" "evt.type=accept and proc.name!=httpd" 

2.容器

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


  1. sudo csysdig -vcontainers 

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


  1. sudo csysdig -pc 

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


  1. sudo sysdig -pc -c topprocs_cpu container.name=wordpress1 

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


  1. sudo sysdig -pc -c topprocs_net container.name=wordpress1 

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


  1. sudo sysdig -pc -c topprocs_net container.name=wordpress1 

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


  1. sudo sysdig -pc -c topfiles_bytes container.name=wordpress1 

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


  1. sudo sysdig -pc -c topconns container.name=wordpress1 

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


  1. sudo sysdig -pc -c spy_users container.name=wordpress1 

3.应用

查看机器所有的HTTP请求:


  1. sudo sysdig -s 2000 -A -c echo_fds fd.port=80 and evt.buffer contains GET 

查看机器所有的SQL select查询:


  1. sudo sysdig -s 2000 -A -c echo_fds evt.buffer contains SELECT  
  2. See queries made via apache to an external MySQL server happening in real time  
  3. sysdig -s 2000 -A -c echo_fds fd.sip=192.168.30.5 and proc.name=apache2 and evt.buffer contains SELECT 

4.硬盘 I/O

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


  1. sysdig -c topprocs_file 

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


  1. sysdig -c fdcount_by proc.name "fd.type=file"  
  2. See the top files in terms of read+write bytes  
  3. sysdig -c topfiles_bytes  
  4. Print the top files that apache has been reading from or writing to  
  5. sysdig -c topfiles_bytes proc.name=httpd  
  6. Basic opensnoop: snoop file opens as they occur  
  7. sysdig -p "%12user.name %6proc.pid %12proc.name %3fd.num %fd.typechar %fd.name" evt.type=open  
  8. See the top directories in terms of R+W disk activity  
  9. sysdig -c fdbytes_by fd.directory "fd.type=file"  
  10. See the top files in terms of R+W disk activity in the /tmp directory  
  11. sysdig -c fdbytes_by fd.filename "fd.directory=/tmp/"  
  12. Observe the I/O activity on all the files named 'passwd'  
  13. sysdig -A -c echo_fds "fd.filename=passwd"  
  14. Display I/O activity by FD type  
  15. sysdig -c fdbytes_by fd.type 

进程和CPU使用率:


  1. See the top processes in terms of CPU usage  
  2. sysdig -c topprocs_cpu  
  3. See the top processes for CPU 0  
  4. sysdig -c topprocs_cpu evt.cpu=0  
  5. Observe the standard output of a process  
  6. sysdig -s4096 -A -c stdout proc.name=cat 

性能和错误:


  1. See the files where most time has been spent  
  2. sysdig -c topfiles_time  
  3. See the files where apache spent most time  
  4. sysdig -c topfiles_time proc.name=httpd  
  5. See the top processes in terms of I/O errors  
  6. sysdig -c topprocs_errors  
  7. See the top files in terms of I/O errors  
  8. sysdig -c topfiles_errors  
  9. See all the failed disk I/O calls  
  10. sysdig fd.type=file and evt.failed=true  
  11. See all the failed file opens by httpd  
  12. sysdig "proc.name=httpd and evt.type=open and evt.failed=true"  
  13. See the system calls where most time has been spent  
  14. sysdig -c topscalls_time  
  15. See the top system calls returning errors  
  16. sysdig -c topscalls "evt.failed=true"  
  17. snoop failed file opens as they occur  
  18. sysdig -p "%12user.name %6proc.pid %12proc.name %3fd.num %fd.typechar %fd.name" evt.type=open and evt.failed=true  
  19. Print the file I/O calls that have a latency greater than 1ms:  
  20. sysdig -c fileslower 1 

5.安全


  1. Show the directories that the user "root" visits  
  2. sysdig -p"%evt.arg.path" "evt.type=chdir and user.name=root"  
  3. Observe ssh activity  
  4. sysdig -A -c echo_fds fd.name=/dev/ptmx and proc.name=sshd  
  5. Show every file open that happens in /etc  
  6. sysdig evt.type=open and fd.name contains /etc  
  7. Show the ID of all the login shells that have launched the "tar" command  
  8. sysdig -r file.scap -c list_login_shells tar  
  9. Show all the commands executed by the login shell with the given ID  
  10. sysdig -r trace.scap.gz -c spy_users proc.loginshellid=5459 

本文作者:佚名

来源:51CTO

时间: 2024-09-24 12:41:37

功能强大的系统工具Sysdig命令实例介绍的相关文章

JAVA应用系统工具快捷托盘实例代码_java

 1.打开各种系统工具            2.定时关机(重启.睡眠未实现 请参照上面两个文章自行扩展)           3.简单文件操作 复制代码 代码如下: [java]  package com.cxy.f;  import java.awt.Image;  import java.awt.MenuItem;  import java.awt.PopupMenu;  import java.awt.SystemTray;  import java.awt.Toolkit;  impo

Linux系统中top命令详细介绍

后面会介绍一些linux中常用的运维命令,利用这些命令我们能够迅速的定位问题所在,并解决问题.今天先从最常见的开始-TOP命令. 命令含义介绍 运行top命令之后,会出现如下内容 top - 03:37:17 up 32 min,  2 users,  load average: 0.00, 0.00, 0.00 Tasks:  10 total,   1 running,   9 sleeping,   0 stopped,   0 zombie %Cpu(s):  0.0 us,  0.0

SQL Server Management Object(SMO)大大简化数据库工具的开发 几行代码开发功能强大的SQL工具

原文 http://www.cnblogs.com/JamesLi2015/archive/2013/05/24/3096214.html 开发与数据库有关的程序,经常需要对数据库进行自动化操作,而不是打开SQL Server Management Studio来写SQL或是图形化操作数据,于是需要一个公共类库,可以处理SQL Server有关的基础操作,比如连接数据库,读取所有的表,修改存储过程,读取表的所有字段及其类型.目前为止,我找到以下方法 1  DMO (legacy of SQL S

Inxi:一个功能强大的获取Linux系统信息的命令行工具

Inxi 最初是为控制台和 IRC(网络中继聊天)开发的一个强大且优秀的命令行系统信息脚本.可以使用它获取用户的硬件和系统信息,它也用于调试或者社区技术支持工具. 使用 Inxi 可以很容易的获取所有的硬件信息:硬盘.声卡.显卡.网卡.CPU 和 RAM 等.同时也能够获取大量的操作系统信息,比如硬件驱动.Xorg .桌面环境.内核.GCC 版本,进程,开机时间和内存等信息. 运行在命令行和 IRC 上的 Inxi 输出略有不同,IRC 上会有一些可供用户使用的默认过滤器和颜色选项.支持的 IR

Windows XP系统中功能强大的syskey命令

今天系统天地官网小编给大家浅析Windows XP系统中功能强大的syskey命令.也许大家对于syskey命令都很了解吧,其实syskey命令能帮助用户提高系统的安全,感兴趣的用户赶快来看看功能强大的syskey命令的用法. 一.利用syskey命令功能双重密码保护 1.点击"开始--运行",输入"syskey"命令后按回车. 2.在出现的界面就是帐户数据库,下一步点击"更新". 3.选择密码启动,输入一个密码后点击确定.这样做将使WINXP在

Ledger-复式记账的一个功能强大的命令行工具

无论你是一个电脑极客还是普通用户,记录账户开销总是必不可少的.虽然在Linux上有很多基于GUI的记账工具(比如 - GNUCash)受到大家欢迎,但是工作在命令行的记账工具是很多用户难以想象的.在本文中,我们将讨论一个功能强大的命令行记账工具-Ledger.   ledger-main Ledger - 复式记账工具 Ledger是复式记账的一个功能强大的命令行工具.对于那些不了解"复式(Double-Entry)"的用户,它这意味着每笔交易都必须有一个源.站在一个外行的角度来看,这

介绍10个功能强大的开源Web流量分析工具

&http://www.aliyun.com/zixun/aggregation/37954.html">nbsp;   最近在伦敦举行的世界旅游博览会上(World Travel Market),旅游行业的专家们齐聚一堂,对网站流量分析(Web analytics)和看似微不足道的网站观察和调整对业务产生的巨大影响进行了讨论. EXpedia商务发展部总监Cameron JonES,强调了网站的快速反应对业务的重要性:"在2006年,人们愿意花4秒钟等待网页打开.现在他

LFTP : 一个功能强大的命令行FTP程序

LFTP : 一个功能强大的命令行FTP程序 大家好,这篇文章是介绍Lftp以及如何在Linux操作系统下安装的.Lftp是一个基于命令行的文件传输软件(也被称为FTP客户端),由Alexander Lukyanov开发并以GNU GPL协议许可发行.除了FTP协议外,它还支持FTPS,HTTP,HTTPS,HFTP,FISH,以及SFTP等协议.这个程序还支持FXP,允许数据绕过客户端直接在两个FTP服务器之间传输. 它有很多很棒的高级功能,比如递归镜像整个目录树以及断点续传下载.传输任务可以

BRL-CAD 7.20.4发布 功能强大的立体建模工具

BRL-CAD是一款http://www.aliyun.com/zixun/aggregation/17547.html">功能强大的立体几何和实体造型系统的建模工具,功能类似AutoCAD.它具有一个交互式几何编辑器,支持光线追踪渲染和几何体分析.图像处理.分布式网络的framebuffer支持.图像和信号处理. BRL-CAD 7.20.4该版本提供了多个主要功能的增强和修复.支持NURBS继续改善与更好的步骤导入,射线追踪修复,更好的线框,以及众多的性能改进,支持alpha状态. 软