| 1 |
#! /usr/bin/env stap |
| 2 |
# |
| 3 |
# This is a stap script to monitor process creations (fork(), exec()'s). |
| 4 |
# Based on stap script found: http://picobot.org/wordpress/?p=27 |
| 5 |
# With some minor modifications (i.e. timestamping) |
| 6 |
# |
| 7 |
# Usage: stap forktracker.stp |
| 8 |
# |
| 9 |
# Sample output: |
| 10 |
# |
| 11 |
# timestamp: process_name (pid) new_pid |
| 12 |
# |
| 13 |
# Version 0.1 |
| 14 |
|
| 15 |
probe kprocess.create { |
| 16 |
printf("%-25s: %s (%d:%d) created %d:%d\n", |
| 17 |
ctime(gettimeofday_s()), execname(), pid(), tid(), new_pid, new_tid) |
| 18 |
} |
| 19 |
|
| 20 |
probe kprocess.exec { |
| 21 |
printf("%-25s: %s (%d) is exec'ing %s\n", |
| 22 |
ctime(gettimeofday_s()), execname(), pid(), filename) |
| 23 |
} |