Skip to content
README.md 1.62 KiB
Newer Older
nirae's avatar
nirae committed
# PHP Tracing Tool

Athoune's avatar
Athoune committed
PHP tracing tool is a command line tool written in python 3 - based on the [BCC toolkit](https://github.com/iovisor/bcc) (eBPF) - for PHP code monitoring.
nirae's avatar
nirae committed

nirae's avatar
nirae committed
Built to help you understand your program behavior in a "normal" environment, directly in production.
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
It gives a deep observability of the application without adding specific php debugging code : function execution flow with latency of each function, tracing I/O syscalls with details …
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
You can also **monitor your containerized application** because it works on the PID of the php process, it discuss directly with the kernel (eBPF), there is **no impact on your application**. You just need a PHP compiled with the `--enable-dtrace` debug option (the image is in the repo)
nirae's avatar
nirae committed

![screenshot](assets/screenshot1.png)

Athoune's avatar
Athoune committed
This example trace a demo php program with a google maps API call.
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
## Command line options
nirae's avatar
nirae committed

**-h** : help

**-S** : print the syscalls details inside each function

**--check** : print the generated BPF C program and quit

**--debug** : debug mode: print the generated BPF C program

Athoune's avatar
Athoune committed
## Install an usage
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
Be sure to have BCC on your machine (a Debian Buster).
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
    apt-get install bpfcc-tools python3-bpfcc
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
Execute the script as root :
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
    sudo ./php_tool.py -h
nirae's avatar
nirae committed

## Complete Demo
nirae's avatar
nirae committed

nirae's avatar
nirae committed
Setup the vagrant machine and go in
Athoune's avatar
Athoune committed
    cd vagrant-buster && vagrant up
    vagrant ssh
    cd /vagrant/php_tool
nirae's avatar
nirae committed
Launch the PHP demo and nginx containers
Athoune's avatar
Athoune committed
    make
nirae's avatar
nirae committed

nirae's avatar
nirae committed
Instrumenting the code with php_tool
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
    sudo ./php_tool.py -S PID [PID ...]
nirae's avatar
nirae committed

nirae's avatar
nirae committed
Usage
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
    sudo ./php_tool.py
nirae's avatar
nirae committed

Athoune's avatar
Athoune committed
There is also a Wordpress demo image.
nirae's avatar
nirae committed

## Licence

Apache-2.0 © 2019 Nicolas Dubouilh, Mathieu Lecarme