Debian Codegraph @

testsuite/systemtap.examples/network/connect_stat.stp

raw
1 #! /usr/bin/env stap
2
3 ############################################################
4 # connect_stat.stp
5 # Author: Robin Hack <[email protected]>
6 # An example script show process tree of process
7 # which tried to call connect with specific ip address
8 ############################################################
9
10 function process_tree (ip:string) {
11 cur_proc = task_current();
12 parent_pid = task_pid(task_parent (cur_proc));
13
14 printf ("%s: ", ip);
15 while (parent_pid != 0) {
16 printf ("%s (%d),%d,%d -> ", task_execname(cur_proc), task_pid(cur_proc), task_uid(cur_proc),task_gid (cur_proc));
17 cur_proc = task_parent(cur_proc);
18 parent_pid = task_pid(task_parent (cur_proc));
19 }
20 # init process
21 if (task_pid (cur_proc) == 1) {
22 printf ("%s (%d),%d,%d\n", task_execname(cur_proc), task_pid(cur_proc), task_uid(cur_proc),task_gid (cur_proc));
23 }
24 }
25
26 probe syscall.connect {
27 if ((uaddr_af !~ "AF_INET*") || (uaddr_ip != @1)) {
28 next;
29 }
30 process_tree (uaddr_ip);
31 }