Reference for USDT Tracepoint for Python
https://github.com/paulross/dtrace-py
https://www.collabora.com/news-and-blog/blog/2019/05/14/an-ebpf-overview-part-5-tracing-user-processes/
https://github.com/iovisor/bcc/pull/698
Install build tools and python prerequisites
sudo apt install systemtap-sdt-dev
sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev
Download and extract python
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xf Python-3.7.0.tar.xz
cd Python-3.7.0
curl -o Python-3.7.0.tgz https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -xzf Python-3.7.0.tgz
cd Python-3.7.0
./configure --with-dtrace --enable-optimizations
make -j 8
# altinstall does not alter original system python install
sudo make altinstall
Run python3.7 when you type python3 ( update-alternatives )
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.7 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
Run below and select python3.7 from the list
sudo update-alternatives --config python3
or create a shortcut
sudo ln -s /usr/local/bin/python3.7 /usr/bin/py
Example:
~/git/ebpfKit/Examples/python$ python main3.py
~/git/bcc/tools/lib$ sudo ./uflow.py -M func -l python `pgrep python`
Tracing method calls in python process 5640... Ctrl-C to quit.
CPU PID TID TIME(us) METHOD
0 5640 5650 8.361 -> main3.py.func_danny
0 5640 5650 8.361 <- main3.py.func_danny
1 5640 5651 8.366 -> main3.py.func_danny
1 5640 5651 8.366 <- main3.py.func_danny
0 5640 5650 18.371 -> main3.py.func_danny
0 5640 5650 18.371 <- main3.py.func_danny
1 5640 5651 18.376 -> main3.py.func_danny
1 5640 5651 18.376 <- main3.py.func_danny
0 5640 5650 28.400 -> main3.py.func_danny
0 5640 5650 28.400 <- main3.py.func_danny
3 5640 5651 28.405 -> main3.py.func_danny
3 5640 5651 28.405 <- main3.py.func_danny
0 5640 5650 38.415 -> main3.py.func_danny
0 5640 5650 38.415 <- main3.py.func_danny
3 5640 5651 38.415 -> main3.py.func_danny
3 5640 5651 38.415 <- main3.py.func_danny
^Cliudanny@52-A90058-03:~/git/bcc/tools/lib$ sudo ./uflow.py -M put -l python `pgrep python3`
Tracing method calls in python process 3807... Ctrl-C to quit.
CPU PID TID TIME(us) METHOD
2 3807 3815 2.884 -> /usr/local/lib/python3.7/queue.py.put
2 3807 3815 2.884 <- /usr/local/lib/python3.7/queue.py.put
0 3807 3816 2.885 -> /usr/local/lib/python3.7/queue.py.put
0 3807 3816 2.885 <- /usr/local/lib/python3.7/queue.py.put
3 3807 3817 2.885 -> /usr/local/lib/python3.7/queue.py.put
3 3807 3817 2.885 <- /usr/local/lib/python3.7/queue.py.put
1 3807 3818 2.886 -> /usr/local/lib/python3.7/queue.py.put
1 3807 3818 2.886 <- /usr/local/lib/python3.7/queue.py.put
No comments:
Post a Comment