| 1 |
#! /usr/bin/env stap |
| 2 |
|
| 3 |
# Copyright (C) 2006 IBM Corp. |
| 4 |
# |
| 5 |
# This file is part of systemtap, and is free software. You can |
| 6 |
# redistribute it and/or modify it under the terms of the GNU General |
| 7 |
# Public License (GPL); either version 2, or (at your option) any |
| 8 |
# later version. |
| 9 |
|
| 10 |
# |
| 11 |
# Print signal counts by process IDs in descending order. |
| 12 |
# |
| 13 |
|
| 14 |
global sigcnt, pid2name, sig2name |
| 15 |
|
| 16 |
probe begin { |
| 17 |
print("Collecting data... Type Ctrl-C to exit and display results\n") |
| 18 |
} |
| 19 |
|
| 20 |
probe signal.send |
| 21 |
{ |
| 22 |
rcv_pid = sig_pid |
| 23 |
|
| 24 |
sigcnt[pid(), rcv_pid, sig] <<< 1 |
| 25 |
|
| 26 |
if (!(pid() in pid2name)) pid2name[pid()] = execname() |
| 27 |
if (!(rcv_pid in pid2name)) pid2name[rcv_pid] = pid_name |
| 28 |
if (!(sig in sig2name)) sig2name[sig] = sig_name |
| 29 |
} |
| 30 |
|
| 31 |
probe end |
| 32 |
{ |
| 33 |
printf("%-8s %-16s %-5s %-16s %-16s %s\n", |
| 34 |
"SPID", "SENDER", "RPID", "RECEIVER", "SIGNAME", "COUNT") |
| 35 |
|
| 36 |
foreach ([snd_pid, rcv_pid, sig_num] in sigcnt-) { |
| 37 |
printf("%-8d %-16s %-5d %-16s %-16s %d\n", |
| 38 |
snd_pid, pid2name[snd_pid], rcv_pid, pid2name[rcv_pid], |
| 39 |
sig2name[sig_num], @count(sigcnt[snd_pid, rcv_pid, sig_num])) |
| 40 |
} |
| 41 |
} |