-
Notifications
You must be signed in to change notification settings - Fork 1
/
monitor-cgroup.bt
53 lines (44 loc) · 1.32 KB
/
monitor-cgroup.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/bpftrace
// # BPFTRACE_STRLEN=120 bpftrace cgroup_monitor.bt
#include <linux/kernfs.h>
BEGIN
{
printf("Trace cgroup file/dir create or delete... Hit Ctrl-C to end.\n");
printf("%-19s %-10s %-8s", "TIME", "PID", "COMM");
printf(" %-16s %s \n", "Probe","PATH/FNAME");
}
kprobe:__kernfs_create_file
{
time("%Y-%m-%d %H:%M:%S ");
$kn = (struct kernfs_node *)arg0;
printf(" %-8d %-16s ", pid, comm);
printf("%16s %s/%s/%s\n", probe, str($kn->parent->name), str($kn->name), str(arg1));
printf("%-39s ", kstack);
}
kprobe:kernfs_remove_by_name_ns
{
time("%Y-%m-%d %H:%M:%S ");
$kn = (struct kernfs_node *)arg0;
printf(" %-8d %-16s ", pid, comm);
printf("%16s %s/%s/%s\n", probe, str($kn->parent->name), str($kn->name), str(arg1));
}
kprobe:kernfs_remove
{
time("%Y-%m-%d %H:%M:%S ");
$kn = (struct kernfs_node *)arg0;
printf(" %-8d %-16s ", pid, comm);
printf("%16s %s/%s/%s\n", probe, str($kn->parent->name), str($kn->name), str(arg1));
}
/*
kprobe:cgroup_rmdir
{
time("%Y-%m-%d %H:%M:%S ");
$kn = (struct kernfs_node *)arg0;
printf(" %-8d %-16s ", pid, comm);
printf("%16s %s/%s/%s\n", probe, str($kn->parent->name), str($kn->name), str(arg1));
printf("%-39s ", kstack);
}
*/
END {
printf("Stopping monitoring cgroup file/dir create or delete...\n");
}