failed-syscalls.pl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 trace_end
  24. {
  25. printf("\nfailed syscalls by comm:\n\n");
  26. printf("%-20s %10s\n", "comm", "# errors");
  27. printf("%-20s %6s %10s\n", "--------------------", "----------");
  28. foreach my $comm (sort {$failed_syscalls{$b} <=> $failed_syscalls{$a}}
  29. keys %failed_syscalls) {
  30. next if ($for_comm && $comm ne $for_comm);
  31. printf("%-20s %10s\n", $comm, $failed_syscalls{$comm});
  32. }
  33. }