Debian Codegraph @

testsuite/systemtap.examples/lwtools/execsnoop-nd.stp

raw
1 #!/usr/bin/stap
2 /*
3 * execsnoop-nd.stp Trace process exec()s with arguments.
4 * For Linux, uses SystemTap (non-debuginfo).
5 *
6 * This is useful for identifying new process creation, provided it follows the
7 * fork()->exec() sequence. New processes that only fork will not be seen; catch
8 * those by tracing fork() or using the process.begin probe.
9 *
10 * USAGE: ./execsnoop-nd.stp
11 *
12 * This is a basic version of execsnoop.
13 *
14 * Copyright (C) 2015 Brendan Gregg.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * 07-Apr-2014 Brendan Gregg Created this.
27 */
28
29 probe begin
30 {
31 printf("%-24s %6s %6s %6s %14s %s\n", "TIME", "UID", "PPID", "PID",
32 "COMM", "ARGS");
33 }
34
35 probe nd_syscall.execve.return
36 {
37 printf("%-24s %6d %6d %6d %14s %s\n", ctime(gettimeofday_s()), uid(),
38 ppid(), pid(), execname(), cmdline_str());
39 }