Debian Codegraph @

testsuite/systemtap.examples/general/watchdog.stp

raw
1 #! /usr/bin/env stap
2 /*
3 * watchdog.stp
4 * usage: stap watchdog.stp start_event stop_event time_ms
5 */
6
7 global active, count
8
9 function trigger(p:long) {
10 /* may want to change the action here */
11 event=sprintf("/usr/bin/pstack %d", p);
12 system(event);
13 }
14
15 probe $1 { active[pid()]=1 }
16 probe $2 { delete active[pid()]; delete count[pid()]}
17
18 probe timer.ms($3) {
19 foreach (p in active) {
20 count[p]++
21 if (count[p] == 2)
22 trigger(p)
23 }
24 }