1#!/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 __future__ import print_function 10from bcc import BPF 11 12prog = """ 13int hello(void *ctx) { 14 bpf_trace_printk("Hello, World!\\n"); 15 return 0; 16} 17""" 18b = BPF(text=prog) 19b.attach_kprobe(event=b.get_syscall_fnname("clone"), fn_name="hello") 20print("PID MESSAGE") 21b.trace_print(fmt="{1} {5}") 22