linux之strace命令监控某段时间内系统函数调用(syscall)情况

linux之strace命令监控某段时间内系统函数调用(syscall)情况

strace 监控某段时间内系统调用命令(监控系统调用syscall系列函数,这些函数用于用户空间程序调用内核空间程序的桥梁,内核空间的程序具体执行与硬件的通信,如驱动程序都在内核空间执行)调用情况,包括调用次数,消耗时间等,从开启开始监控,结束命令则结束监控,输出这段时间的监控情况
案例:
[root@localhost ~]# strace -c -f -p 16745 #按下ctry +c 停止结束监控 并输出监控结果 -p为指定要监控的进程,本案例中writev函数使用频繁,耗时最多,这个函数是将内存中的缓存区的数据写入到文件,即写入到磁盘。可见输入/输出等操作占用大量时间。
strace: Process 16745 attached
strace: Process 18611 attached
strace: Process 18615 attached
strace: Process 18616 attached
strace: Process 18619 attached
strace: Process 18620 attached
strace: Process 19296 detached
strace: Process 19298 detached
% time seconds usecs/call calls errors syscall


55.11 3.121153 1471 2122 writev
14.76 0.835644 265 3151 1093 shutdown
11.17 0.632302 9 73337 484 stat
2.15 0.121973 19 6438 write
1.69 0.095901 13 7529 close
1.67 0.094722 44 2158 2158 connect
1.66 0.094130 26 3655 munmap
1.22 0.069288 32 2184 socket
1.16 0.065843 14 4872 getdents
1.08 0.061390 14 4390 1029 read
1.03 0.058192 53 1093 accept4
0.84 0.047575 6 7536 brk
0.75 0.042623 16 2592 968 open
0.68 0.038654 6 6502 fcntl
0.61 0.034264 14 2436 openat
0.60 0.034164 131 261 wait4
0.48 0.027432 6 4719 lseek
0.41 0.023203 6 4116 setitimer
0.41 0.023114 6 3561 fstat
0.41 0.022979 13 1735 mmap
0.32 0.018251 9 2058 chdir
0.26 0.014595 56 261 100 select
0.23 0.013218 12 1093 getsockname
0.22 0.012641 11 1129 poll
0.19 0.010599 6 1641 rt_sigaction
0.16 0.008991 9 1029 getcwd
0.14 0.008027 7 1093 times
0.11 0.006269 14 464 lstat
0.10 0.005682 6 1029 rt_sigprocmask
0.08 0.004507 4 1029 uname
0.05 0.003016 12 242 semop
0.03 0.001646 14 121 setgroups
0.03 0.001563 12 126 getsockopt
0.02 0.001333 11 121 epoll_ctl
0.02 0.001302 50 26 sendmsg
0.02 0.001302 11 121 epoll_create1
0.02 0.001296 11 121 setuid
0.02 0.001105 4 268 geteuid
0.02 0.000982 8 121 clone
0.02 0.000883 7 121 setgid
0.01 0.000725 14 52 26 setsockopt
0.00 0.000188 7 26 getgid
0.00 0.000175 7 26 getegid
0.00 0.000169 7 26 getuid
0.00 0.000089 1 121 set_robust_list


100.00 5.663100 156852 5858 total

你可能感兴趣的:(lamp服务器维护优化)