4 systemtap-service \- SystemTap initscript and systemd service
25 .IR COMMAND " [" OPTIONS "] [" SCRIPT ...]
28 .IR COMMAND " [" OPTIONS "] [" SCRIPT ...]
31 The SystemTap initscript aims to provide a way to run scripts as a service and
32 easily control them individually. Scripts can be configured to start upon manual
33 request, or during system startup. On dracut-based systems, it is also possible
34 to integrate scripts in the initramfs and have them start during early-boot.
36 The SystemTap initscript can be invoked manually using the
38 command. On systemd-based systems, the initscript is controlled by
41 \fBsystemtap.service\fR.
43 There are various parameters and options available to modify global behaviour,
44 as well as script behaviour. Dependencies between scripts can be established so
45 that starting one starts others.
47 The configuration file of the initscript is located at
48 \fB@sysconfdir@/systemtap/config\fR. Acceptable parameters are detailed in the
49 GLOBAL PARAMETERS section.
51 Scripts must be placed in the \fB@sysconfdir@/systemtap/script.d\fR directory
52 and must have a \fB.stp\fR extension. When referring to them on the
53 command-line however, there in no need to include the \fB.stp\fR extension.
54 Script names can only contain alphanumeric characters (and '_') and must not
55 start with a number. The scripts directory may be changed by setting the
56 SCRIPT_PATH parameter in the configuration file.
59 One of the commands below must be specified:
63 Start \fISCRIPT\fRs. If no scripts are specified, start the scripts specified by
64 the DEFAULT_START configuration. If DEFAULT_START is not set, start all scripts
65 in the script directory. For scripts already started, the command is ignored.
66 The command will fail if the scripts fail to start (see also the PASSALL
69 If the AUTOCOMPILE configuration is on, the command will try to compile or
70 update the specified scripts when one of the below conditions is true:
73 The compiled cache file does not exist.
75 The mtime (modified timestamp) of the original script file is newer than the
76 time of the compiled script cache.
78 The specified stap options used to compile the script has been changed (see
79 also the SCRIPT PARAMETERS section).
81 The result of `uname -a` has been changed.
86 Stop \fISCRIPT\fRs. If no scripts are specified, stop all running scripts. For
87 scripts already stopped, the command is ignored. The command will fail if the
88 scripts fail to stop (see also the PASSALL configuration).
92 Stop and start \fISCRIPT\fRs.
96 Show the state of \fISCRIPT\fRs and their dependencies.
100 Compile \fISCRIPT\fRs but do not start them. If the scripts have already been
101 compiled, prompt for confirmation before overwriting cache. Compile for the
102 current kernel, or the kernel release specified by the \fB-r\fR option.
106 Make \fISCRIPT\fRs part of the initramfs so that they are started earlier during
107 the boot process. This command is only available on dracut-based systems. If no
108 scripts are specified, create a normal initramfs devoid of any SystemTap files.
110 The initramfs is created for the current kernel, or the kernel release specified
111 by the \fB-r\fR option. The path of the created initramfs defaults to
112 \fB/boot/initramfs-KVER.img\fR, where KVER is the output of `uname -r`. The
113 bootloader is also updated (using \fInew-kernel-pkg\fR(8)) to make the kernel
114 entry use the new initramfs file. Use the \fB-o\fR option to specify a different
115 path (the bootloader will not be updated).
117 If the output file already exists, it is overwritten, unless the \fB-b\fR switch
118 is given, in which case the file is appended \fB.bak\fR rather than overwritten.
119 However, if there is already a \fB.bak\fR version of the file, the backup will
122 WARNING: do not use the \fB-o\fR option of \fIstap\fR(1) with onboot scripts
123 because the script is started before the root filesystem is even mounted.
124 Increase the buffer size if more space is needed.
128 Delete the compiled \fISCRIPT\fRs from cache. If no scripts are specified, then
129 all compiled scripts are deleted. Only the cache for the current kernel is
130 deleted, or the kernel release specified by the \fB-r\fR option. Prompt for
131 confirmation before deleting.
134 Many of the commands can also take options. However, since users can't pass
135 these options on boot, they are only meant for managing scripts after boot and
136 for testing. Available options are:
139 .BI "-c " CONFIG_FILE
140 Specify a different configuration file in place of the default one.
144 When using the \fBstart\fR and \fBstop\fR commands, also include the scripts'
145 dependencies (recursively).
148 .BI "-r " KERNEL_RELEASE
149 When using the \fBcompile\fR, \fBonboot\fR, and \fBcleanup\fR commands, specify
150 the target kernel version rather than using the current one. Must be in the same
151 format as `uname -r`.
155 Answer yes for all prompts.
159 When using the \fBonboot\fR command, specify the output path of the created
160 initramfs. When specified, the bootloader configuration is not updated.
164 When using the \fBonboot\fR command, backup an existing initramfs image by
165 adding a \fB.bak\fR extension rather than overwriting it. Without this option,
166 the initramfs is overwritten.
168 .SH GLOBAL PARAMETERS
169 These parameters affect the general behaviour of the SystemTap initscript
170 service. They can be specified in the configuration file.
174 Specify the absolute path of the script directory. These are the scripts on
175 which the initscript can operate. Scripts must have the \fB.stp\fR extension.
176 The default path is \fB@sysconfdir@/systemtap/script.d\fR.
180 Specify the absolute path of the script configuration directory. These
181 configuration files contain options for specific scripts. They must have the
182 \fB.conf\fR extension. The default path is \fB@sysconfdir@/systemtap/conf.d\fR.
186 Specify the absolute path of the cache directory. The default path is
187 \fB@localstatedir@/cache/systemtap\fR.
191 Specify the absolute path of the temporary directory in which SystemTap
192 makes temporary directories to compile scripts. The default path is \fB/tmp\fR.
196 Specify the absolute path of the directory containing PID files used to track
197 the status of SystemTap scripts. The default path is
198 \fB@localstatedir@/run/systemtap\fR.
202 Specify the absolute path of the log file. All messages are sent to this file,
203 including compilation and runtime errors. The default path is
204 \fB@localstatedir@/log/systemtap.log\fR.
208 If this is set \fByes\fR, initscript commands that operate on multiple scripts
209 will report as failed when the action could not be performed on at least one
210 script. If set to \fBno\fR, only a warning is emitted. The default is \fByes\fR.
214 If this is set \fByes\fR, the initscript will always follow script dependencies
215 recursively. This means that there is no need to specify the \fB-R\fR option.
216 This flag is effective only if you specify script(s) from the command-line. The
221 If this is set \fByes\fR, the initscript automatically tries to compile
222 specified scripts when needed if there is no valid cache. Otherwise, the related
223 command simply fails. The default is \fByes\fR.
227 Specify scripts which will be started by default. If omitted (or empty), all
228 scripts in the script directory will be started. The default is \fB""\fR.
232 If this is set \fByes\fR, the initscript will also allow operating on scripts
233 that are located in the cache directory, but not in the script directory. The
236 WARNING: the initscript may load unexpected obsolete caches with this option.
237 The cache directory should be checked before enabling this option.
241 Because boot-time scripts are run before the root filesystem is mounted,
242 staprun's stderr cannot be logged to the LOG_FILE as usual. However, the log
243 can instead be output to /var/run/systemtap/$script.log by setting LOG_BOOT_ERR
244 to \fByes\fR. If STAT_PATH is different from the default, the log files will be
245 moved there upon executing any of the initscript commands. The default is
249 Here is a global configuration file example:
251 SCRIPT_PATH=/var/systemtap/script.d/
256 .SH SCRIPT PARAMETERS
257 These parameters affect the compilation or runtime behaviour of specific
258 SystemTap scripts. They must be placed in config files located in the
259 CONFIG_PATH directory.
263 Specify options passed to the \fIstap\fR(1) command for the SCRIPT. Here, SCRIPT
264 is the name of the script file without the \fB.stp\fR extension. Note that the
265 \fB-F\fR option is always added.
267 The following options are ignored when compiling scripts: -p, -m, -r, -c, -x,
268 -e, -s, -o, -h, -V, -k.
270 The following options are ignored when running starting scripts: -h, -V, -v, -t,
271 -p, -I, -e, -R, -r, -m, -k, -g, -P, -D, -b, -u, -q, -w, -l, -d, -L, -F, and all
276 Specify script dependencies (i.e. which script this script requires). For
277 example, if foo.stp requires (or needs to run after) bar.stp, set
281 Specify multiple scripts by separating their names by spaces.
284 Here is a script configuration file example:
286 script1_OPT="-o /var/log/script1.out"
287 script2_OPT="-o /var/log/script2.out"
288 script2_REQ="script1"
294 .B INSTALLING SCRIPTS
295 We first copy a SystemTap script (e.g. "script1.stp") into the script directory:
297 \fB#\fR cp script1.stp /etc/systemtap/script.d/
299 We can then set any script options, for example:
301 \fB#\fR vi /etc/systemtap/conf.d/group1.conf
302 script1_OPT="-o /var/log/group1.out"
304 We then install a script (e.g. "script2.stp") which needs to run after
305 script1. In this case, we can do the following:
307 \fB#\fR cp script2.stp /etc/systemtap/script.d/
308 \fB#\fR vi /etc/systemtap/conf.d/group1.conf
309 script2_OPT="-o /var/log/group2.out"
310 script2_REQ="script1"
312 This way, if \fIstap\fR(1) fails to run script1, the initscript will not even
317 After installing scripts, we can test that they work by simply doing:
319 \fB#\fR systemtap-service start
320 \fB#\fR systemtap-service stop
322 We could be more specific as well, for example:
324 \fB#\fR systemtap-service start script1
325 \fB#\fR systemtap-service stop script1
327 If there were no errors, we are ready to use it.
331 After we're satisfied with the scripts and their tests, we can enable the
332 SystemTap initscript service:
334 \fB#\fR chkconfig systemtap on
339 Scripts are deleted by simply removing them from the script directory and
340 removing any configuration lines specific to them:
342 \fB#\fR rm /etc/systemtap/script.d/script2.stp
343 \fB#\fR vi /etc/systemtap/conf.d/group1.conf
345 If the script is still running, we also need to stop it:
347 \fB#\fR systemtap-service stop script2
349 We can then also remove the cache associated with the script:
351 \fB#\fR systemtap-service cleanup script2
355 .B PREPARING FOR KERNEL UPDATES
356 Usually, there is nothing to do when booting into a new kernel. The initscript
357 will see that the kernel version is different and will compile the scripts. The
358 compilation can be done beforehand as well to avoid having to compile during
359 boot by using the \fB-r\fR option:
361 \fB#\fR systemtap-service compile myscript -r <NEW_KERNEL_VERSION>
365 .B IMPORTING COMPILED SCRIPTS
366 For environments which lack compilation infrastructure (e.g. no compilers or
367 debuginfo), such as a production system, the scripts can be compiled on another
368 (development) machine and then transferred over to the production system:
370 \fB#\fR systemtap-service compile myscript -r \\
372 > <KERNEL_VERSION_OF_TARGET_MACHINE>
373 \fB#\fR tar czf stap-scripts-<kernel-version>.tar.gz \\
375 > /var/cache/systemtap/<kernel-version> \\
377 > /etc/systemtap/conf.d/<configfile>
379 And then copy this package to the target machine and extract it.
382 .B STARTING SCRIPTS DURING EARLY-BOOT
383 The initscript also allows us to start scripts earlier during the boot process
384 by creating an initramfs containing the script's module. The system must be
385 dracut-based for this to work. Starting a script at this stage gives access to
386 information otherwise very hard to obtain.
388 We first install the script by copying it into the script directory as usual and
389 setting whatever options we'd like:
391 \fB#\fR cp myscript.stp /etc/systemtap/script.d
392 \fB#\fR vi /etc/systemtap/conf.d/myscript.conf
394 To add the script to the initramfs, we use the \fBonboot\fR command:
396 \fB#\fR systemtap-service onboot myscript
398 If the script is not already compiled and cached, it will be done at this point.
399 A new initramfs will then be created at the default location. We can use the
400 \fB-b\fR option to ensure that the existing initramfs is backed up. We can then
404 .B USING A DIFFERENT INITRAMFS
405 If we would prefer to only start the script for one boot and not others, it
406 might be easier to instead use the \fB-o\fR option to specify a different
407 initramfs output file:
409 \fB#\fR systemtap-service onboot myscript \\
410 > -o /boot/special_initramfs.img
412 Once the initramfs is created, it's simply a matter of changing the command-line
413 options at boot-time so that the new image is used rather than the usual one.
416 .B CREATING AN INITRAMFS FOR A DIFFERENT KERNEL
417 Just like the compile command, we can use the \fB-r\fR option to specify the
418 kernel for which we want to create the initramfs. This is useful when we are
419 about to upgrade and would like to prepare in advance. For example:
421 \fB#\fR systemtap-service onboot myscript \\
422 > -r 3.12.6-200.fc19.x86_64
426 .B REMOVING SCRIPTS FROM THE INITRAMFS
427 Finally, to remove all script from the initramfs, we simple run the \fBonboot\fR
428 command without specifying any scripts:
430 \fB#\fR systemtap-service onboot
432 This will simply create a standard initramfs without any SystemTap modules
436 .B TROUBLESHOOTING EARLY-BOOT ISSUES
437 There can be many reasons for which the module didn't insert or did not work as
438 expected. It may be useful to turn on dracut debugging by adding 'rdinitdebug'
439 to the kernel command-line and checking dmesg/journalctl -ae. Also, the stderr
440 output of staprun can be captured by setting the LOG_BOOT_ERR option to
446 .IR new-kernel-pkg (8)
449 Use the Bugzilla link of the project web page or our mailing list.
451 .BR http://sourceware.org/systemtap/ ", " <systemtap@sourceware.org> .