Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Linux Tools Project/Systemtap/User Guide/ide/lesson2.html

IDE Tutorial, Lesson Two: Writing Your First Script

In this tutorial we will guide you through the process of writing your first Systemtap script. It is strongly recommended that you review the Systemtap website's tutorial - for up-to-date information on the latest version of Systemtap.

Start by selecting File->New. Specify a file name of your choosing, but be sure that it ends with an .stp extension. Click ok. Your blank script should be present in the editor pane.


Now type/copy the following:

	global read, write, start

	probe begin {
		start = gettimeofday_s()
	probe syscall.write {
		write += count

	probe {
		printf("%d\t%d\t%d\n", (gettimeofday_s()-start), read, write)

Now to demonstrate the functionality of the Probe Alias browser we will have you complete the read probe yourself. Start by opening the syscall folder in the Probe Alias browser. If you do not have any content in the browser you are experiencing a problem with Systemtap installation and should refer to our Installation help page. Ensure your cursor is located at the end of the file. Now scroll down and double click the read probe alias. Systemtap GUI will insert the skeleton probe at the point at which your cursor is at, and should look similar to the following:

	 * available variables on this probe:
	 * argstr, buf_uaddr, count, fd, name


Now insert the following line into the probe:

read += count

You may remove the comment (/* ... */) if you wish.

This will count the number of bytes read and written each second and print it out. The begin probe executes first, by getting the time of day. The read and write probes increment each time the function is called. The timer probe prints the information every second. If you typed the script in manually you may have noticed that the editor provides code completion for probe aliasi. If you did not, type "syscall.". You'll see a box come up that you may use to select an item to complete your probe alias.

In Lesson 3 you will learn how to run Systemtap scripts in the IDE Perspective.

Back to Tutorial Contents

Copyright © Eclipse Foundation, Inc. All Rights Reserved.