[英]type of syscall a process or program is making
I am trying to find how many different type of syscalls a process or program is making. 我试图找到一个进程或程序正在进行多少种不同类型的系统调用。 I know that I can do following to get total number of calls for each syscall as below.
我知道我可以执行以下操作以获取每个syscall的总调用次数,如下所示。
strace -c cat abc.txt
The output of above is command. 上面的输出是命令。
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
-nan 0.000000 0 10 read
-nan 0.000000 0 1 write
-nan 0.000000 0 12 open
-nan 0.000000 0 14 close
-nan 0.000000 0 12 fstat
-nan 0.000000 0 28 mmap
-nan 0.000000 0 16 mprotect
-nan 0.000000 0 3 munmap
-nan 0.000000 0 3 brk
-nan 0.000000 0 2 rt_sigaction
-nan 0.000000 0 1 rt_sigprocmask
-nan 0.000000 0 2 ioctl
-nan 0.000000 0 1 1 access
-nan 0.000000 0 1 execve
-nan 0.000000 0 1 fcntl
-nan 0.000000 0 2 getdents
-nan 0.000000 0 1 getrlimit
-nan 0.000000 0 1 statfs
-nan 0.000000 0 1 arch_prctl
-nan 0.000000 0 2 1 futex
-nan 0.000000 0 1 set_tid_address
-nan 0.000000 0 1 set_robust_list
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 116 2 total
As you can see that it returns the total number of syscalls made which is 116
. 如您所见,它返回的系统调用总数为
116
。 I only need to know how many different type syscalls were made which is 22
in this case. 我只需要知道进行了多少种不同类型的syscall,在这种情况下为
22
。
Is there a way to do that in one line using strace
? 有没有一种方法可以使用
strace
做到这一点?
Pipe the output to wc -l
to get the number of lines in the statistics. 将输出通过管道传输到
wc -l
以获取统计信息中的行数。 Since the statistics are written to standard error, you'll need to do some redirection for this. 由于统计信息被写入标准错误,因此您需要为此进行一些重定向。
strace -c cat abc.txt 2>&1 >/dev/null | wc -l
You'll also need to subtract 4 from this, because of the header, total, and divider lines. 由于标题行,总数行和分隔线,您还需要从中减去4。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.