SystemTap

From Infogalactic: the planetary knowledge core
Jump to: navigation, search
SystemTap
Smileytap.svg
Developer(s) Various
Initial release 2005 (2005)
Stable release 2.9 / October 8, 2015; 8 years ago (2015-10-08)
Written in C, C++, custom scripting
Operating system Linux kernel
Type Tracing programming language
License GNU General Public License
Website sourceware.org/systemtap/

In computing, SystemTap (stap) is a scripting language and tool for dynamically instrumenting running production Linux kernel-based operating systems. System administrators can use SystemTap to extract, filter and summarize data in order to enable diagnosis of complex performance or functional problems.

SystemTap consists of free and open-source software and includes contributions from Red Hat, IBM, Intel, Hitachi, Oracle, and other community members.[1]

History

SystemTap debuted in 2005 in Red Hat Enterprise Linux 4 Update 2 as a technology preview.[2]

After four years in development, SystemTap 1.0 was released in 2009.[3]

As of 2011 SystemTap runs fully supported in all Linux distributions including RHEL / CentOS 5[4] since update 2, SLES 10,[5] Fedora, Debian and Ubuntu.

Tracepoints in the CPython VM and JVM were added in SystemTap 1.2.[6]

Usage

SystemTap files written in the SystemTap language (based on the language reference.[7]) run with the stap command-line[8] and are saved as .stp files. The system carries out a number of passes on the script before allowing it to run, at which point the script is compiled into a loadable kernel module and loaded into the kernel. Listing modules shows each SystemTap script as 'stap_<UUID>'. The module is unloaded when the tap has finished running.

Scripts generally focus on events (such as starting or finishing a script), compiled-in probe points such as linux "tracepoints", or the execution of functions or statements in the kernel or user-space.

Some "guru mode" scripts may also have embedded C, which may run with the -g command-line option. However, use of guru mode is discouraged, and each SystemTap release includes more probe points designed to remove the need for guru-mode taps.

As of systemtap release 1.7 the software implements the new stapsys group and privilege level.[9]

Simple examples

The following script shows all applications setting TCP socket options on the system, what options are being set, and whether the option is set successfully or not:

# Show sockets setting options

# Return enabled or disabled based on value of optval
function getstatus(optval)
{
    if ( optval == 1 )
        return "enabling"
    else
        return "disabling"
}

probe begin
{
        print ("\nChecking for apps setting socket options\n")
}

# Set a socket option
probe tcp.setsockopt
{
    status = getstatus(user_int($optval))
        printf ("  App '%s' (PID %d) is %s socket option %s... ", execname(), pid(), status, optstr)
}

# Check setting the socket option worked
probe tcp.setsockopt.return
{
    if ( ret == 0 )
        printf ("success")
    else
        printf ("failed")
    printf ("\n")
}

probe end
{
        print ("\nClosing down\n")
}

Many other examples are shipped with SystemTap. There are also real-world examples of SystemTap use at the War Stories page .

Importing scripts from other tracing technologies

SystemTap can attach to DTrace markers when they are compiled into an application using macros from the sys/sdt.h header file.

See also

References

External links