| 1 |
#! /usr/bin/env stap |
| 2 |
# |
| 3 |
# Copyright (C) 2018 Red Hat, Inc. |
| 4 |
# By William Cohen, Red Hat Inc. |
| 5 |
# [email protected] |
| 6 |
# |
| 7 |
# USAGE: stap syscallbypid.stp --suppress-handler-errors |
| 8 |
# |
| 9 |
# The "--suppress-handler-errors" option allows the script to continue |
| 10 |
# run when probes are skipped. The probe skips make the data less accurate, |
| 11 |
# but are otherwise harmless. |
| 12 |
|
| 13 |
global arr%[20000] |
| 14 |
global procname% |
| 15 |
|
| 16 |
probe syscall_any { |
| 17 |
arr[pid(), syscall_nr]++ |
| 18 |
procname[pid()] = execname() |
| 19 |
} |
| 20 |
|
| 21 |
probe scheduler.process_exit { |
| 22 |
delete arr[pid(),*] |
| 23 |
delete procname[pid()] |
| 24 |
} |
| 25 |
|
| 26 |
function process_name(pid) { |
| 27 |
return sprintf("%s[%d]", procname[pid], pid) |
| 28 |
} |
| 29 |
|
| 30 |
probe prometheus { |
| 31 |
@prometheus_dump_array2_map(arr, "syscall_count", "pid", "name", |
| 32 |
sprint, process_name, syscall_name ) |
| 33 |
} |