blob: 173f21f4c1d231a06240fe7767de40bebd97df21 [file] [log] [blame]
Brendan Gregge845c522015-09-07 14:51:53 -07001#!/usr/bin/env python
2# Copyright (c) PLUMgrid, Inc.
3# Licensed under the Apache License, Version 2.0 (the "License")
4
5# This is an example of tracing an event and printing custom fields.
6# run in project examples directory with:
7# sudo ./trace_fields.py"
8
9from bcc import BPF
10
11prog = """
12int hello(void *ctx) {
13 bpf_trace_printk("Hello, World!\\n");
14 return 0;
15}
16"""
17b = BPF(text=prog)
18b.attach_kprobe(event="sys_clone", fn_name="hello")
19print "PID MESSAGE"
20b.trace_print(fmt="{1} {5}")