Important
The host system must be the same architecture and running the same distribution of Linux
as the target system in order for the built instrumentation module to work.
2.3. Running SystemTap Scripts
SystemTap scripts are run through the command stap. stap can run SystemTap scripts from
standard input or from file.
Running stap and staprun requires elevated privileges to the system. However, not all users can be
granted root access just to run SystemTap. In some cases, for instance, you may want to allow a non-
privileged user to run SystemTap instrumentation on his machine.
To allow ordinary users to run SystemTap without root access, add them to one of these user groups:
stapdev
Members of this group can use stap to run SystemTap scripts, or staprun to run SystemTap
instrumentation modules.
Running stap involves compiling SystemTap scripts into kernel modules and loading them
into the kernel. This requires elevated privileges to the system, which are granted to stapdev
members. Unfortunately, such privileges also grant effective root access to stapdev members.
As such, you should only grant stapdev group membership to users whom you can trust root
access.
stapusr
Members of this group can only run staprun to run SystemTap instrumentation modules.
In addition, they can only run those modules from /lib/modules/kernel_version/
systemtap/. Note that this directory must be owned only by the root user, and must only be
writable by the root user.
Below is a list of commonly used stap options:
-v
Makes the output of the SystemTap session more verbose. You can repeat this option (for
example, stap -vvv script.stp) to provide more details on the script's execution. This option
is particularly useful if you encounter any errors in running the script.
For more information about common SystemTap script errors, refer to
SystemTap
Errors.
-o filename
Sends the standard output to file (filename).
-x process ID
Sets the SystemTap handler function target() to the specified process ID. For more information
about target(), refer to
-c command
Sets the SystemTap handler function target() to the specified command. Note that you must
use the full path to the specified command; for example, instead of specifying cp, use /bin/cp
SystemTap
Functions.
Running SystemTap Scripts
Chapter 5, Understanding
7
Need help?
Do you have a question about the ENTERPRISE LINUX 5.4 - SYSTEMTAP BEGINNERS GUIDE and is the answer not in the manual?
Questions and answers