Debugging Linux Kernel using SystemTap Part-8 - Find top 10 system calls executed every 5 seconds
In this post, we will write a system tap script to find out the top 10 system calls being executed in your Linux Machine every 5 seconds.
# This script continuously lists the top 10 system calls in the
# 5 second interval
global syscalls_count
probe syscall.* {
syscalls_count[name]++
}
function print_sysstop() {
printf("%25s %10s \n", "SYSCALL", "COUNT")
foreach(syscall in syscalls_count- limit 10) {
printf("%25s %10d\n", syscall, syscalls_count[syscall])
}
delete syscalls_count
}
probe timer.s(5) {
print_sysstop()
printf("---------------------------------------------------------------\n")
}
# This script continuously lists the top 10 system calls in the
# 5 second interval
global syscalls_count
probe syscall.* {
syscalls_count[name]++
}
function print_sysstop() {
printf("%25s %10s \n", "SYSCALL", "COUNT")
foreach(syscall in syscalls_count- limit 10) {
printf("%25s %10d\n", syscall, syscalls_count[syscall])
}
delete syscalls_count
}
probe timer.s(5) {
print_sysstop()
printf("---------------------------------------------------------------\n")
}
Notes:
1. We declared a global array named syscalls_count
2. We have probed for all the system calls using "probe syscall.*", once the system call is probed its count is incremented
3. We are using timer with 5 second interval to print the results
O/P:
Comments
Post a Comment