STAPRUN(8)
β¨ STAPRUN(8) β the systemtap runtime, explained by your fave π
okay bestie, welcome to staprun from the System Manager's Manual. this is the back half of the whole Systemtap situation and honestly? it's giving quietly essential. let's get into it π«Ά
πΈ NAME πΈ
staprun β the systemtap runtime, periodt.
π SYNOPSIS π
staprun [ OPTIONS ] MODULE [ MODULE-OPTIONS ]
π DESCRIPTION π
so the way this works: staprun is the back-end of the Systemtap tool. it's expecting a kernel module that was produced by the front-end stap tool. that's the whole vibe. π«
and why is systemtap split into a front-end and a back-end, you ask? iconic question. because splitting it means you can compile a systemtap script on a development machine (one that has the kernel development tools, which you literally need to compile the script), and then just carry the resulting kernel module over to a production machine that has zero development tools installed. no cap, that's the entire point. π₯
if you wanna know the version number, go check stappaths (7), or just run rpm -q systemtap (that's the fedora/red hat route) or apt-get -v systemtap (that's the ubuntu route). β¨
π OPTIONS π
staprun supports the options below, and that's the list. any other option you throw at it will just print out the supported options at you. respectfully. π
-vβ verbose mode, bestie. the level of verbosity is also set in theSYSTEMTAP_VERBOSEenvironment variable. π-Vβ print the version number and dip. bye! βοΈ-wβ suppress warnings from the script. shhh. π€«-uβ load theuprobes.komodule.-c CMDβ run command CMD, andstaprunwill exit when CMD does. the'_stp_target'variable will contain the pid for CMD.-x PIDβ the'_stp_target'variable gets set to PID.-N PIDβ sets the'_stp_namespaces_pid'variable to PID.-o FILEβ send output to FILE. if the module uses bulk mode, the output will be in percpu filesFILE_x(FILE_cpuxin background and bulk mode) where'x'is the cpu number. this supportsstrftime(3)formats for FILE. ποΈ-b BUFFER_SIZEβ the systemtap module will specify a buffer size, and setting one here will override that value. the value should be an integer between1and4095, which is assumed to be the buffer size in MB. that value will be per-cpu if bulk mode is used.-Lβ load the module and start probes, then detach from the module leaving the probes running. you can attach back to the module later with the-Aoption. π¦-Aβ attach to an already-loaded systemtap module.-C WHENβ control the coloring of error messages. WHEN must be either"never","always", or"auto"(which means: only enable if you're at a terminal). if the option is missing, then"auto"is assumed. colors can be modified using theSYSTEMTAP_COLORSenvironment variable. see thestap(1)manual page for more info on the syntax and behaviour. π-M INTERVALβ enable monitor mode, with INTERVAL seconds between updates.-dβ delete a module. only detached or unused modules that the user has permission to access will be deleted. use"*"(quoted!) to delete all unused modules. π-Dβ runstaprunin the background as a daemon and show its pid.-Rβ rename the module to a unique name before inserting it.-r N:URIβ pass the given number and URI data to the tapset functionsremote_id()andremote_uri().-S size[,N]β sets the maximum size of the output file and the maximum number of output files. if the size of the output file will exceed size megabytes, systemtap switches the output file to the next file. and if the number of output files exceeds N, systemtap removes the oldest output file. you can omit the second argument. β¨-T timeoutβ sets the maximum time the reader thread will wait before dumping the trace buffer. value is in ms, and the default is200ms. setting this to a high value decreases the number ofstapiowake-ups, allowing deeper sleep for embedded platforms. but it impacts interactivity on the terminal, since traces are dumped less often in cases of low throughput. there is no interactivity or performance impact for high throughput, because the trace is dumped when the buffer is full, before this timeout expires. π§var1=valβ sets the value of global variable var1 to val. global variables contained within a module are treated as module options and can be set from thestapruncommand line. π
π ARGUMENTS π
MODULE is either a module path or a module name. if it's a module name, the module will be looked for in the following directory (where 'VERSION' is the output of "uname -r"):
/lib/modules/VERSION/systemtap
any additional arguments on the command line are passed straight to the module. one use of these additional module arguments is setting the value of global variables declared within the module. π
$ stap -p4 -m mod1 -e 'global var1="foo"; probe begin{printf("%s\n",
var1); exit()}'
running that with an additional module argument:
$ staprun mod1.ko var1="HelloWorld"
HelloWorld
heads up bestie: spaces and exclamation marks currently cannot be passed into global variables this way. π
π EXAMPLES π
if you want a whole collection of sample scripts, see the stapex(3stap) manual page. π
here's a very basic example of how to use staprun. first, use stap to compile a script. the stap program will report the pathname to the resulting module.
$ stap -p4 -e 'probe begin { printf("Hello World!\n"); exit() }'
/home/user/.systemtap/cache/85/stap_8553d83f78c_265.ko
then run staprun with the pathname to the module as an argument.
$ staprun /home/user/.systemtap/cache/85/stap_8553d83f78c_265.ko
Hello World!
ate. that's the whole flow. π
π¦ MODULE DETACHING AND ATTACHING π¦
once staprun installs a Systemtap kernel module, users can detach from the kernel module and reattach to it later. the -L option loads the module and automatically detaches. users can also detach from the kernel module interactively by sending the SIGQUIT signal from the keyboard (typically by typing Ctrl-\). β¨οΈ
to reattach to a kernel module, you'd use the staprun -A option.
β FILE SWITCHING BY SIGNAL β
after staprun has launched the stapio program, users can command it to switch the output file to the next file when it's outputting to file(s) (that's staprun running with the -o option) by sending a SIGUSR2 signal to the stapio process. when it receives SIGUSR2, it will switch the output file to a new file with suffix .N where N is the sequential number. for example, π
$ staprun -o foo ...
this outputs trace logs to foo, and if it receives a SIGUSR2 signal, it switches output to the foo.1 file. and receiving SIGUSR2 again, it switches to the foo.2 file. slay. π₯
π SAFETY AND SECURITY π
Systemtap, in the default kernel-module runtime mode, is an administrative tool. it exposes kernel internal data structures and potentially private user information. see the stap(1) manual page for additional info on safety and security. β οΈ
to increase system security, users of systemtap must be root, or in the stapusr group, in order to execute this setuid staprun program. a user may select a particular privilege level with the stap --privilege= option, which staprun will later enforce.
stapdevβ members of thestapdevgroup can write and load script modules with root-equivalent privileges, without particular security constraints. (many safety constraints remain, tho.)stapsysβ members of thestapsysgroup have almost all the privileges ofstapdev, except for guru mode constructs.stapusrβ members only of thestapusrgroup may any-privileged modules placed into the/lib/modules/VERSION/systemtapby the system administrator.stapusrβ members only of thestapusrgroup may also write and load low-privilege script modules, which are normally limited to manipulating their own processes (and not the kernel, nor other users' processes).
part of the privilege enforcement mechanism may require using a stap-server and administrative trust in its cryptographic signer; see the stap-server(8) manual page for more information. π
on a kernel with FIPS mode enabled, staprun normally refuses to attempt to load systemtap-generated kernel modules. this is because on some kernels, this results in a panic. π if your kernel includes corrections such as linux commit #002c77a48b47, then you can force staprun to attempt module loads anyway, by setting the STAP_FIPS_OVERRIDE environment variable to any value.
π FILES π
/lib/modules/VERSION/systemtapβ if MODULE is a module name, the module will be looked for in this directory. users who are only in the'stapusr'group can install modules located in this directory. this directory must be owned by therootuser and must not be world writable. ποΈ
π SEE ALSO π
stap(1), stapprobes(3stap), stap-server(8), stapdyn(8), stapex(3stap)
π BUGS π
use the Bugzilla link of the project web page or our mailing list, bestie:
http://sourceware.org/systemtap/, <systemtap@sourceware.org>
and that's the page!! πΈ written from the System Manager's Manual, filed under STAPRUN(8) β go forth and instrument responsibly, my love πβ¨π«Ά
π¦ where this page comes from
- arch rolling: systemtap 5.6-1 Β· GPL-2.0-or-later
- centos-stream 10: systemtap-runtime 5.6-3.el10 Β· GPL-2.0-or-later
- centos-stream 9: systemtap-runtime 5.6-3.el9 Β· GPL-2.0-or-later
- debian trixie: systemtap-runtime 5.1-5
- fedora 43: systemtap-runtime 5.3-4.fc43 Β· GPL-2.0-or-later
- fedora 43: systemtap-runtime 5.6-1.fc43 Β· GPL-2.0-or-later
- fedora 44: systemtap-runtime 5.4-3.fc44 Β· GPL-2.0-or-later
- fedora 44: systemtap-runtime 5.6-1.fc44 Β· GPL-2.0-or-later
- nixos 26.05: systemtap 5.4
- nixpkgs unstable: systemtap 5.5
- opensuse-leap 16.0: systemtap-runtime 5.2-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: systemtap-runtime 5.2-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: systemtap-runtime 5.2-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: systemtap-runtime 5.2-160000.2.2 Β· GPL-2.0-or-later
- ubuntu noble: systemtap-runtime 5.0-2ubuntu1
- ubuntu questing: systemtap-runtime 5.1-5
- ubuntu resolute: systemtap-runtime 5.3-2
- ubuntu stonking: systemtap-runtime 5.5-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms