Creating re-usable SystemTap modules

I have been heavily delving into SystemTap lately. One of the draw-backs most people run into is having to install the kernel devel, kernel debugging, and gcc stuff on any system you want run your SystemTap scripts. You can get around this by building the SystemTap module once, and re-using it on any system with the same kernel.

Building the module

When you run a SystemTap script, it compiles a module from your script and loads it into the kernel. When you stop the script, the compiled module is unloaded and destroyed. To preserve this built module, simply use the “-m” flag and specify a name of your choice:

stap myscript.stp -m mymodule

Once the stap finishes running, you’ll have a file called “mymodule.ko” in your working directory.

Running the module

Now that you have your freshly compiled systemtap kernel module, you can run it using “stap-run”:

stap-run mymodule.ko

You can use this module on any machine that has an identical kernel to the machine you compiled it on, without the need for devel, debugging, or GCC packages!

Gotcha!

One interesting thing I ran into is if you change the filename of the module, stap-run will not work. Hope this saves someone some troubleshooting time 🙂

Happy hacking!

Share and Enjoy:
  • StumbleUpon
  • Facebook
  • Twitter
  • Reddit
Creating re-usable SystemTap modules

Leave a Reply

Your email address will not be published.