| 1 |
#! /usr/bin/env stap |
| 2 |
# |
| 3 |
# Copyright (C) 2010, 2018 Red Hat, Inc. |
| 4 |
# By Dominic Duval, Red Hat Inc. |
| 5 |
# [email protected] |
| 6 |
# |
| 7 |
# Monitors errors returned by system calls. |
| 8 |
# |
| 9 |
# USAGE: stap errno.stp |
| 10 |
# |
| 11 |
|
| 12 |
global execname, errors |
| 13 |
|
| 14 |
probe syscall_any.return { |
| 15 |
errno = retval |
| 16 |
if ( errno < 0 ) { |
| 17 |
p = pid() |
| 18 |
execname[p]=execname(); |
| 19 |
errors[p, errno, name] <<< 1 |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
probe end { |
| 24 |
printf("\n") |
| 25 |
printf("%8s %-32s %-16s %-12s %8s\n", |
| 26 |
"PID", "Syscall", "Process", "Error", "Count") |
| 27 |
foreach ([pid, error, thissyscall] in errors- limit 20) { |
| 28 |
printf("%8d %-32s %-16s %-12s %8d\n", |
| 29 |
pid, |
| 30 |
thissyscall, |
| 31 |
execname[pid], |
| 32 |
error ? errno_str(error) : "", |
| 33 |
@count(errors[pid, error, thissyscall]) |
| 34 |
) |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
global prom_arr |
| 39 |
|
| 40 |
probe prometheus { |
| 41 |
foreach ([p, errno, name] in errors- limit 20) { |
| 42 |
prom_arr[p, errno, name] = @count(errors[p, errno, name]) |
| 43 |
} |
| 44 |
|
| 45 |
@prometheus_dump_array3(prom_arr, "syscall_error_count", "pid", "errno", "name") |
| 46 |
delete prom_arr |
| 47 |
} |