Commit 32326203 authored by Brenden Blanco's avatar Brenden Blanco

Updates to README and INSTALL documents

* Some changes to python API examples
* Reflect non-rc kernel availability in install doc
* Add binary rpm section to install doc
* Remove docker build instructions
Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent 3df1288d
...@@ -4,9 +4,9 @@ Install a 4.2+ kernel from http://kernel.ubuntu.com/~kernel-ppa/mainline, ...@@ -4,9 +4,9 @@ Install a 4.2+ kernel from http://kernel.ubuntu.com/~kernel-ppa/mainline,
for example: for example:
```bash ```bash
VER=4.2.0-040200rc5 VER=4.2.0-040200
REL=201508030228 REL=201508301530
PREFIX=http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-rc5-unstable PREFIX=http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-unstable
wget ${PREFIX}/linux-headers-${VER}-generic_${VER}.${REL}_amd64.deb wget ${PREFIX}/linux-headers-${VER}-generic_${VER}.${REL}_amd64.deb
wget ${PREFIX}/linux-headers-${VER}_${VER}.${REL}_all.deb wget ${PREFIX}/linux-headers-${VER}_${VER}.${REL}_all.deb
wget ${PREFIX}/linux-image-${VER}-generic_${VER}.${REL}_amd64.deb wget ${PREFIX}/linux-image-${VER}-generic_${VER}.${REL}_amd64.deb
...@@ -22,7 +22,7 @@ To install: ...@@ -22,7 +22,7 @@ To install:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D4284CDD sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D4284CDD
echo "deb http://52.8.15.63/apt trusty main" | sudo tee /etc/apt/sources.list.d/iovisor.list echo "deb http://52.8.15.63/apt trusty main" | sudo tee /etc/apt/sources.list.d/iovisor.list
sudo apt-get update sudo apt-get update
sudo apt-get install libbcc sudo apt-get install libbcc libbcc-examples python-bcc
``` ```
Test it: Test it:
...@@ -36,24 +36,24 @@ cd pyroute2; sudo make install ...@@ -36,24 +36,24 @@ cd pyroute2; sudo make install
sudo python /usr/share/bcc/examples/simple_tc.py sudo python /usr/share/bcc/examples/simple_tc.py
``` ```
# Fedora - Docker edition # Fedora - Binary
The build dependencies are captured in a [Dockerfile](Dockerfile.fedora), the Install a 4.2+ kernel from
output of which is a .rpm for easy installation. This version takes longer since http://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug, for example:
LLVM needs to be compiled from source.
```bash
* Start with a recent Fedora install (tested with F22) sudo wget http://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo -O /etc/yum.repos.d/fedora-rawhide-kernel-nodebug.repo
* Install a [>= 4.2 kernel](http://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/x86_64/) sudo dnf install -y kernel-core-4.2.0-1.fc24.x86_64 kernel-4.2.0-1.fc24.x86_64 kernel-devel-4.2.0-1.fc24.x86_64 kernel-modules-4.2.0-1.fc24.x86_64 kernel-headers-4.2.0-1.fc24.x86_64
with headers # reboot
* Reboot ```
* Install [docker](https://docs.docker.com/installation/fedora/)
* Run the Dockerfile for Fedora - results in an installable .rpm Tagged binary packages are built for Fedora 22 and hosted at http://52.8.15.63/yum/.
* `git clone https://github.com/iovisor/bcc; cd bcc`
* `docker build -t bcc -f Dockerfile.fedora .` To install:
* `docker run --rm -v /tmp:/mnt bcc sh -c "cp /root/bcc/build/*.rpm /mnt"` ```bash
* `sudo rpm -ivh /tmp/libbcc*.rpm` wget http://52.8.15.63/yum/main/f22/iovisor.repo -O /etc/yum.repos.d/iovisor.repo
* Run the example dnf install -y libbcc libbcc-examples python-bcc
* `sudo python /usr/share/bcc/examples/hello_world.py` ```
# Ubuntu - From source # Ubuntu - From source
...@@ -79,3 +79,19 @@ To build the toolchain from source, one needs: ...@@ -79,3 +79,19 @@ To build the toolchain from source, one needs:
* `make` * `make`
* `sudo make install` * `sudo make install`
# Fedora - From source
* Install build dependencies
* `sudo dnf install -y cmake ethtool git iperf libstdc++-static python-netaddr python-pip gcc gcc-c++ make zlib-devel`
* `sudo dnf install -y http://pkgs.repoforge.org/netperf/netperf-2.6.0-1.el6.rf.x86_64.rpm`
* `sudo pip install pyroute2`
* Install binary clang
* `wget http://llvm.org/releases/3.7.0/clang+llvm-3.7.0-x86_64-fedora22.tar.xz`
* `sudo tar xf clang+llvm-3.7.0-x86_64-fedora22.tar.xz -C /usr/local --strip 1`
* Install and compile BCC
* `git clone https://github.com/iovisor/bcc.git`
* `mkdir bcc/build; cd bcc/build`
* [optional] `export CC=/usr/local/bin/clang CXX=/usr/local/bin/clang++`
* `cmake .. -DCMAKE_INSTALL_PREFIX=/usr`
* `make`
* `sudo make install`
...@@ -41,6 +41,7 @@ The features of this toolkit include: ...@@ -41,6 +41,7 @@ The features of this toolkit include:
tc actions, and kprobes tc actions, and kprobes
* Bindings for Python * Bindings for Python
* Examples for socket filters, tc classifiers, and kprobes * Examples for socket filters, tc classifiers, and kprobes
* Self-contained tools for tracing a running system
In the future, more bindings besides python will likely be supported. Feel free In the future, more bindings besides python will likely be supported. Feel free
to add support for the language of your choice and send a pull request! to add support for the language of your choice and send a pull request!
...@@ -77,19 +78,14 @@ For this example, we will call the program every time `fork()` is called by a ...@@ -77,19 +78,14 @@ For this example, we will call the program every time `fork()` is called by a
userspace process. Underneath the hood, fork translates to the `clone` syscall, userspace process. Underneath the hood, fork translates to the `clone` syscall,
so we will attach our program to the kernel symbol `sys_clone`. so we will attach our program to the kernel symbol `sys_clone`.
```python ```python
fn = b.load_func("hello", BPF.KPROBE) b.attach_kprobe(event="sys_clone", fn_name="hello")
BPF.attach_kprobe(fn, "sys_clone")
``` ```
The python process will then print the trace printk circular buffer until ctrl-c The python process will then print the trace printk circular buffer until ctrl-c
is pressed. The BPF program is removed from the kernel when the userspace is pressed. The BPF program is removed from the kernel when the userspace
process that loaded it closes the fd (or exits). process that loaded it closes the fd (or exits).
```python ```python
from subprocess import call b.trace_print()
try:
call(["cat", "/sys/kernel/debug/tracing/trace_pipe"])
except KeyboardInterrupt:
pass
``` ```
Output: Output:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment