blob: 512d6ca629b6b8d545e419123d49ee0713e61533 [file] [log] [blame]
Brendan Gregg48fbc3e2015-08-18 14:56:14 -07001/*
2 * pidpersec.c Count new processes (via fork).
3 * For Linux, uses BCC, eBPF. See the Python front-end.
4 *
5 * USAGE: pidpersec.py
6 *
7 * Copyright (c) 2015 Brendan Gregg.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
11 *
12 * 11-Aug-2015 Brendan Gregg Created this.
13 */
14
15#include <uapi/linux/ptrace.h>
16
17enum stat_types {
18 S_COUNT = 1,
19 S_MAXSTAT
20};
21
22BPF_TABLE("array", int, u64, stats, S_MAXSTAT + 1);
23
24void stats_increment(int key) {
25 u64 *leaf = stats.lookup(&key);
26 if (leaf) (*leaf)++;
27}
28
29void do_count(struct pt_regs *ctx) { stats_increment(S_COUNT); }