failed-syscalls.pl 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # failed system call counts
  2. # (c) 2010, Tom Zanussi <tzanussi@gmail.com>
  3. # Licensed under the terms of the GNU GPL License version 2
  4. #
  5. # Displays system-wide failed system call totals
  6. # If a [comm] arg is specified, only syscalls called by [comm] are displayed.
  7. use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
  8. use lib "./Perf-Trace-Util/lib";
  9. use Perf::Trace::Core;
  10. use Perf::Trace::Context;
  11. use Perf::Trace::Util;
  12. my $for_comm = shift;
  13. my %failed_syscalls;
  14. sub raw_syscalls::sys_exit
  15. {
  16. my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
  17. $common_pid, $common_comm,
  18. $id, $ret) = @_;
  19. if ($ret < 0) {
  20. $failed_syscalls{$common_comm}++;
  21. }
  22. }
  23. sub syscalls::sys_exit
  24. {
  25. raw_syscalls::sys_exit(@_)
  26. }
  27. sub trace_end
  28. {
  29. printf("\nfailed syscalls by comm:\n\n");
  30. printf("%-20s %10s\n", "comm", "# errors");
  31. printf("%-20s %6s %10s\n", "--------------------", "----------");
  32. foreach my $comm (sort {$failed_syscalls{$b} <=> $failed_syscalls{$a}}
  33. keys %failed_syscalls) {
  34. next if ($for_comm && $comm ne $for_comm);
  35. printf("%-20s %10s\n", $comm, $failed_syscalls{$comm});
  36. }
  37. }