Giter Site home page Giter Site logo

udzura / rbbcc Goto Github PK

View Code? Open in Web Editor NEW
47.0 9.0 1.0 2.31 MB

BCC port for MRI - this is unofficial bonsai project.

Home Page: https://github.com/iovisor/bcc

License: Apache License 2.0

Ruby 95.06% Shell 3.78% Dockerfile 0.90% Roff 0.26%
bcc ebpf tracing ruby dl

rbbcc's Introduction

RbBCC

Gem Version CI Status

RbBCC is a port of BCC in MRI. See iovisor project page.

Movie

This gem requires libbcc.so. Please install it following BCC's instruction.

Installation

Add this line to your application's Gemfile:

gem 'rbbcc'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rbbcc

Usage

require 'rbbcc' 

code = <<CLANG
int kprobe__sys_clone(void *ctx)
{
  bpf_trace_printk("Hello, World!\\n");
  return 0;
}
CLANG
RbBCC::BCC.new(text: code).trace_print

See examples (both in rbbcc and BCC)

Trying with docker

udzura/rbbcc:${version} is available.

  • On generic linux:
$ docker run --privileged \
    -v/lib/modules:/lib/modules \
    -v/sys:/sys \
    -v/usr/src:/usr/src \
    -v`pwd`:/opt \
    -ti \
    udzura/rbbcc:0.0.2 /opt/hello_world.rb
Found fnc: kprobe__sys_clone
Attach: p_sys_clone

            bash-20113 [000] ....   377.602655: 0x00000001: Hello, World!
            bash-20113 [000] ....   385.367309: 0x00000001: Hello, World!
            bash-20113 [000] ....   391.203779: 0x00000001: Hello, World!
            curl-20316 [001] ....   391.218226: 0x00000001: Hello, World!
            bash-20113 [000] ....   402.528271: 0x00000001: Hello, World!
 docker-containe-20236 [000] ....   403.090058: 0x00000001: Hello, World!
...
  • On Docker for Mac:
    • Docker for Mac host does not have heders file in /usr/src, so you should extract headers in each container inside.
### I have prepared an example Dockerfile
$ docker build -t udzura/rbbcc:0.0.2-dfm -f Dockerfile.dfm-example .
$ docker run --privileged \
    -v/lib/modules:/lib/modules \
    -v`pwd`/examples:/opt \
    -ti \
    udzura/rbbcc:0.0.2-dfm /opt/hello_world.rb
...
 containerd-shim-4932  [002] d...  1237.795421: : Hello, World!
           httpd-4958  [000] d...  1237.795666: : Hello, World!
           httpd-4958  [000] d...  1237.795794: : Hello, World!
           httpd-4967  [000] d...  1237.795988: : Hello, World!
           httpd-4967  [000] d...  1237.796211: : Hello, World!
           httpd-4967  [000] d...  1237.796289: : Hello, World!
           httpd-4967  [000] d...  1237.796325: : Hello, World!
           <...>-5025  [003] d...  1237.796956: : Hello, World!
            runc-5025  [003] d...  1237.797133: : Hello, World!
           httpd-4967  [000] d...  1237.797156: : Hello, World!
           httpd-4967  [000] d...  1237.797198: : Hello, World!
           httpd-4967  [000] d...  1237.797340: : Hello, World!
            runc-5025  [003] d...  1237.797464: : Hello, World!

Documents

See docs/ for getting started and tutorial.

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/udzura/rbbcc.

rbbcc's People

Contributors

dependabot[bot] avatar udzura avatar yfractal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

yfractal

rbbcc's Issues

Supported version

  • rbbcc now supports libbcc 0.10.0, which is installed as stable from official repo in many distributions.
  • But Ubuntu Focal will install libbpfcc 0.11.0:
  • It may be desirable to support both 0.10.0 and 0.11.0 in one gem version.

( Also I don't think current edge 0.12.0~ should be supported before rbbcc 1.0. )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.