Skip to content

Commit

Permalink
Fix the target pid of oomkill example, expose metrics by default (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
krisztianfekete authored Dec 9, 2022
1 parent a1bb243 commit d824192
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions examples/oomkill/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ bee run -f="exits,tcomm,bash" ghcr.io/solo-io/bumblebee/oomkill:$(bee version)

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

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

```c
struct {
__uint(type, BPF_MAP_TYPE_RINGBUF);
__uint(max_entries, 1 << 24);
__type(value, struct data_t);
} oomkills SEC(".maps.counter");
```
```
To disable this functionality, you can change the suffix to `.print`.
6 changes: 3 additions & 3 deletions examples/oomkill/oomkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct {
__uint(type, BPF_MAP_TYPE_RINGBUF);
__uint(max_entries, 1 << 24);
__type(value, struct data_t);
} oomkills SEC(".maps.print");
} oomkills SEC(".maps.counter");

SEC("kprobe/oom_kill_process")
int BPF_KPROBE(oom_kill_process, struct oom_control *oc, const char *message)
Expand All @@ -32,7 +32,7 @@ int BPF_KPROBE(oom_kill_process, struct oom_control *oc, const char *message)
return 0;
}

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

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

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

0 comments on commit d824192

Please sign in to comment.