Skip to content

Commit d824192

Browse files
Fix the target pid of oomkill example, expose metrics by default (#91)
1 parent a1bb243 commit d824192

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

examples/oomkill/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ bee run -f="exits,tcomm,bash" ghcr.io/solo-io/bumblebee/oomkill:$(bee version)
4040

4141
Visualizing and alerting on oomkills is crucial, and Bumblebee can help you with that.
4242

43-
You can modify your `oomkills` structure to generate a `counter` from the oomkill events:
43+
Since we have the `.counter` prefix added to our `oomkills` map, exposing the oomkill events as a `counter` metric is enabled by default:
4444

4545
```c
4646
struct {
4747
__uint(type, BPF_MAP_TYPE_RINGBUF);
4848
__uint(max_entries, 1 << 24);
4949
__type(value, struct data_t);
5050
} oomkills SEC(".maps.counter");
51-
```
51+
```
52+
53+
To disable this functionality, you can change the suffix to `.print`.

examples/oomkill/oomkill.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct {
2020
__uint(type, BPF_MAP_TYPE_RINGBUF);
2121
__uint(max_entries, 1 << 24);
2222
__type(value, struct data_t);
23-
} oomkills SEC(".maps.print");
23+
} oomkills SEC(".maps.counter");
2424

2525
SEC("kprobe/oom_kill_process")
2626
int BPF_KPROBE(oom_kill_process, struct oom_control *oc, const char *message)
@@ -32,7 +32,7 @@ int BPF_KPROBE(oom_kill_process, struct oom_control *oc, const char *message)
3232
return 0;
3333
}
3434

35-
e->tpid = bpf_get_current_pid_tgid();
35+
e->tpid = BPF_CORE_READ(oc, chosen, tgid);
3636
bpf_get_current_comm(&e->fcomm, TASK_COMM_LEN);
3737

3838
e->fpid = bpf_get_current_pid_tgid() >> 32;
@@ -44,4 +44,4 @@ int BPF_KPROBE(oom_kill_process, struct oom_control *oc, const char *message)
4444
return 0;
4545
}
4646

47-
char LICENSE[] SEC("license") = "GPL";
47+
char LICENSE[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)