Introduction to powerful system tool Sysdig command example

Source: Internet
Author: User
Tags sysdig

Introduction to powerful system tool Sysdig command example

Sysdig is a monitoring tool that allows system administrators and developers to gain unprecedented insight into their system behavior. We can use the sysdig command to do a lot of cool things. If you have more interesting usage and want to add it to the following command example, please let us know!

1. Network

View the processes that consume the most network bandwidth:

 
 
  1. sysdig -c topprocs_net 

The network transmission data of host 192.168.0.1 is displayed:

 
 
  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 

View the most connected server ports:

 
 
  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 

View the most connected ip addresses on the client:

 
 
  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 

List all access connections that are not accessing the apache service:

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

2. Container

View the list of containers running on the machine and their resource usage:

 
 
  1. sudo csysdig -vcontainers 

View the process list of the container context:

 
 
  1. sudo csysdig -pc 

View the CPU usage in the wordpress1 container:

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

View the network bandwidth usage in the wordpress1 container:

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

View the processes that use the most network bandwidth in the wordpress1 container:

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

View the files that occupy the most I/O bytes in the wordpress1 container:

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

View the ranking of network connections in the wordpress1 container:

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

Display the execution of all commands in the wordpress1 container:

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

3. Application

View All HTTP requests on the machine:

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

View All SQL select queries on the machine:

 
 
  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. Hard Disk I/O

View the process that uses the most disk bandwidth:

 
 
  1. sysdig -c topprocs_file 

List processes that use a large number of file descriptors:

 
 
  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 

Process and CPU usage:

 
 
  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 

Performance and errors:

 
 
  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. Security

 
 
  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 

Original article:Http://www.sysdig.org/wiki/sysdig-examples/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.