asked 194k views
3 votes
give a one-line, piped shell command that prints the occurrence counts and names of the top 5 most frequently invoked syscalls, sorted by increasing number of occurrences.

asked
User Hcura
by
8.4k points

1 Answer

4 votes

Final answer:

To display the top 5 most frequently invoked syscalls, a command sequence integrating strace, awk, sort, uniq, and tail can be used in the shell, with the output sorted by occurrence counts.

Step-by-step explanation:

To print the occurrence counts and names of the top 5 most frequently invoked syscalls, sorted by increasing number of occurrences using a piped shell command, you can utilize tools like strace, awk, sort, and uniq. However, it is important to note that this task requires you first to capture the syscalls made by a process. Here is an example of how you could achieve this using a shell command:

strace -c -p 2>&1 | awk '{print $2}' | sort | uniq -c | sort -n | tail -n 5

This command would attach strace to an already running process with process ID , counting the occurrences of each system call. Then it pipes the stderr to awk to extract the syscall names, sorts the result, counts unique occurrences with uniq -c, sorts the counts numerically, and finally uses tail to get the top 5 results.

answered
User Bo Jeanes
by
7.3k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.

Categories