From 5baa8cc9eb2ba16be3e1ee5d04290df8466a8050 Mon Sep 17 00:00:00 2001 From: mark Date: Thu, 7 Aug 2008 14:57:52 +0000 Subject: [PATCH] Add generated examples and index files. --- examples/disktop.stp | 69 +++++ examples/functioncallcount.stp | 17 ++ examples/futexes.stp | 36 +++ examples/graphs.stp | 60 ++++ examples/helloworld.stp | 2 + examples/index.html | 154 ++++++++++ examples/index.txt | 238 ++++++++++++++++ examples/io_submit.stp | 71 +++++ examples/iotime.stp | 113 ++++++++ examples/iotop.stp | 25 ++ examples/keyword-index.html | 299 ++++++++++++++++++++ examples/keyword-index.txt | 500 +++++++++++++++++++++++++++++++++ examples/nettop.stp | 42 +++ examples/para-callgraph.stp | 20 ++ examples/pf2.stp | 16 ++ examples/sig_by_pid.stp | 42 +++ examples/sig_by_proc.stp | 36 +++ examples/sigkill.stp | 23 ++ examples/sleepingBeauties.stp | 58 ++++ examples/sleeptime.stp | 62 ++++ examples/socket-trace.stp | 8 + examples/subsystem-index.html | 186 ++++++++++++ examples/subsystem-index.txt | 267 ++++++++++++++++++ examples/syscalls_by_pid.stp | 28 ++ examples/syscalls_by_proc.stp | 28 ++ examples/systemtap.css | 164 +++++++++++ examples/systemtapcorner.gif | Bin 0 -> 970 bytes examples/systemtaplogo.png | Bin 0 -> 1860 bytes examples/thread-times.stp | 32 +++ examples/traceio.stp | 32 +++ examples/traceio2.stp | 20 ++ examples/wait4time.stp | 59 ++++ 32 files changed, 2707 insertions(+) create mode 100644 examples/disktop.stp create mode 100644 examples/functioncallcount.stp create mode 100644 examples/futexes.stp create mode 100644 examples/graphs.stp create mode 100644 examples/helloworld.stp create mode 100644 examples/index.html create mode 100644 examples/index.txt create mode 100644 examples/io_submit.stp create mode 100644 examples/iotime.stp create mode 100644 examples/iotop.stp create mode 100644 examples/keyword-index.html create mode 100644 examples/keyword-index.txt create mode 100644 examples/nettop.stp create mode 100644 examples/para-callgraph.stp create mode 100644 examples/pf2.stp create mode 100644 examples/sig_by_pid.stp create mode 100644 examples/sig_by_proc.stp create mode 100644 examples/sigkill.stp create mode 100644 examples/sleepingBeauties.stp create mode 100644 examples/sleeptime.stp create mode 100644 examples/socket-trace.stp create mode 100644 examples/subsystem-index.html create mode 100644 examples/subsystem-index.txt create mode 100644 examples/syscalls_by_pid.stp create mode 100644 examples/syscalls_by_proc.stp create mode 100644 examples/systemtap.css create mode 100644 examples/systemtapcorner.gif create mode 100644 examples/systemtaplogo.png create mode 100644 examples/thread-times.stp create mode 100644 examples/traceio.stp create mode 100644 examples/traceio2.stp create mode 100644 examples/wait4time.stp diff --git a/examples/disktop.stp b/examples/disktop.stp new file mode 100644 index 00000000..2637d735 --- /dev/null +++ b/examples/disktop.stp @@ -0,0 +1,69 @@ +#!/usr/bin/env stap +# +# Copyright (C) 2007 Oracle Corp. +# +# Get the status of reading/writing disk every 5 seconds, output top ten entries +# +# This is free software,GNU General Public License (GPL); either version 2, or (at your option) any +# later version. +# +# Usage: +# ./disktop.stp +# + +global io_stat,device +global read_bytes,write_bytes + +probe kernel.function("vfs_read").return { + if ($return>0) { + dev = __file_dev($file) + devname = __find_bdevname(dev,__file_bdev($file)) + + if (devname!="N/A") {/*skip read from cache*/ + io_stat[pid(),execname(),uid(),ppid(),"R"] += $return + device[pid(),execname(),uid(),ppid(),"R"] = devname + read_bytes += $return + } + } +} + +probe kernel.function("vfs_write").return { + if ($return>0) { + dev = __file_dev($file) + devname = __find_bdevname(dev,__file_bdev($file)) + + if (devname!="N/A") { /*skip update cache*/ + io_stat[pid(),execname(),uid(),ppid(),"W"] += $return + device[pid(),execname(),uid(),ppid(),"W"] = devname + write_bytes += $return + } + } +} + +probe timer.ms(5000) { + /* skip non-read/write disk */ + if (read_bytes+write_bytes) { + + printf("\n%-25s, %-8s%4dKb/sec, %-7s%6dKb, %-7s%6dKb\n\n",ctime(gettimeofday_s()),"Average:", + ((read_bytes+write_bytes)/1024)/5,"Read:",read_bytes/1024,"Write:",write_bytes/1024) + + /* print header */ + printf("%8s %8s %8s %25s %8s %4s %12s\n","UID","PID","PPID","CMD","DEVICE","T","BYTES") + } + /* print top ten I/O */ + foreach ([process,cmd,userid,parent,action] in io_stat- limit 10) + printf("%8d %8d %8d %25s %8s %4s %12d\n",userid,process,parent,cmd,device[process,cmd,userid,parent,action],action,io_stat[process,cmd,userid,parent,action]) + + /* clear data */ + delete io_stat + delete device + read_bytes = 0 + write_bytes = 0 +} + +probe end{ + delete io_stat + delete device + delete read_bytes + delete write_bytes +} diff --git a/examples/functioncallcount.stp b/examples/functioncallcount.stp new file mode 100644 index 00000000..e393b612 --- /dev/null +++ b/examples/functioncallcount.stp @@ -0,0 +1,17 @@ +# The following line command will probe all the functions +# in kernel's memory management code: +# +# stap functioncallcount.stp "*@mm/*.c" + +probe kernel.function(@1) { # probe functions listed on commandline + called[probefunc()] <<< 1 # add a count efficiently +} + +global called + +probe end { + foreach (fn in called-) # Sort by call count (in decreasing order) + # (fn+ in called) # Sort by function name + printf("%s %d\n", fn, @count(called[fn])) + exit() +} diff --git a/examples/futexes.stp b/examples/futexes.stp new file mode 100644 index 00000000..16c62937 --- /dev/null +++ b/examples/futexes.stp @@ -0,0 +1,36 @@ +#! /usr/bin/env stap + +# This script tries to identify contended user-space locks by hooking +# into the futex system call. + +global thread_thislock # short +global thread_blocktime # +global FUTEX_WAIT = 0 /*, FUTEX_WAKE = 1 */ + +global lock_waits # long-lived stats on (tid,lock) blockage elapsed time +global process_names # long-lived pid-to-execname mapping + +probe syscall.futex { + if (op != FUTEX_WAIT) next # we don't care about originators of WAKE events + t = tid () + process_names[pid()] = execname() + thread_thislock[t] = $uaddr + thread_blocktime[t] = gettimeofday_us() +} + +probe syscall.futex.return { + t = tid() + ts = thread_blocktime[t] + if (ts) { + elapsed = gettimeofday_us() - ts + lock_waits[pid(), thread_thislock[t]] <<< elapsed + delete thread_blocktime[t] + delete thread_thislock[t] + } +} + +probe end { + foreach ([pid+, lock] in lock_waits) + printf ("%s[%d] lock %p contended %d times, %d avg us\n", + process_names[pid], pid, lock, @count(lock_waits[pid,lock]), @avg(lock_waits[pid,lock])) +} diff --git a/examples/graphs.stp b/examples/graphs.stp new file mode 100644 index 00000000..0c8e3796 --- /dev/null +++ b/examples/graphs.stp @@ -0,0 +1,60 @@ +#! stap + +# ------------------------------------------------------------------------ +# data collection + +# disk I/O stats +probe begin { qnames["ioblock"] ++; qsq_start ("ioblock") } +probe ioblock.request { qs_wait ("ioblock") qs_run("ioblock") } +probe ioblock.end { qs_done ("ioblock") } + +# CPU utilization +probe begin { qnames["cpu"] ++; qsq_start ("cpu") } +probe scheduler.cpu_on { if (!idle) {qs_wait ("cpu") qs_run ("cpu") }} +probe scheduler.cpu_off { if (!idle) qs_done ("cpu") } + + +# ------------------------------------------------------------------------ +# utilization history tracking + +global N +probe begin { N = 50 } + +global qnames, util, histidx + +function qsq_util_reset(q) { + u=qsq_utilization (q, 100) + qsq_start (q) + return u +} + +probe timer.ms(100) { # collect utilization percentages frequently + histidx = (histidx + 1) % N # into circular buffer + foreach (q in qnames) + util[histidx,q] = qsq_util_reset(q) +} + + +# ------------------------------------------------------------------------ +# general gnuplot graphical report generation + +probe timer.ms(1000) { + # emit gnuplot command to display recent history + + printf ("set yrange [0:100]\n") + printf ("plot ") + foreach (q in qnames+) + { + if (++nq >= 2) printf (", ") + printf ("'-' title \"%s\" with lines", q) + } + printf ("\n") + + foreach (q in qnames+) { + for (i = (histidx + 1) % N; i != histidx; i = (i + 1) % N) + printf("%d\n", util[i,q]) + printf ("e\n") + } + + printf ("pause 1\n") +} diff --git a/examples/helloworld.stp b/examples/helloworld.stp new file mode 100644 index 00000000..efe45b79 --- /dev/null +++ b/examples/helloworld.stp @@ -0,0 +1,2 @@ +#! /usr/bin/env stap +probe begin { println("hello world") exit () } diff --git a/examples/index.html b/examples/index.html new file mode 100644 index 00000000..12a712c9 --- /dev/null +++ b/examples/index.html @@ -0,0 +1,154 @@ + + + + + SystemTap Examples + + + + + + + + + + + +
SystemTap logo + SystemTap |  +
+ +
+
+ + + + + + + + + + +
 

Examples

  + +

Example Indexes

+ + +

All Examples

+
    +
  • disktop.stp - Summarize Disk Read/Write Traffic
    +output: timed, exits: user-controlled, status: production
    +subsystem: disk, keywords: disk
    +

    Get the status of reading/writing disk every 5 seconds, output top ten entries during that period.

  • +
  • functioncallcount.stp - Count Times Functions Called
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling functions
    +

    The functioncallcount.stp script takes one argument, a list of functions to probe. The script will run and count the number of times that each of the functions on the list is called. On exit the script will print a sorted list from most frequently to least frequently called function.

  • +
  • futexes.stp - System-Wide Futex Contention
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: locking, keywords: syscall locking futex
    +

    The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.

  • +
  • graphs.stp - Graphing Disk and CPU Utilization
    +output: plot data, exits: user-controlled, status: production
    +subsystem: disk cpu, keywords: disk cpu use graph
    +

    The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.

  • +
  • helloworld.stp - SystemTap "Hello World" Program
    +output: text, exits: fixed, status: production
    +subsystem: none, keywords: simple
    +

    A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.

  • +
  • io_submit.stp - Tally Reschedule Reason During AIO io_submit Call
    +output: sorted on-exit, exits: user-controlled, status: production
    +subsystem: io, keywords: io backtrace
    +

    When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.

  • +
  • iotime.stp - Trace Time Spent in Read and Write for Files
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall read write time io
    +

    The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.

  • +
  • iotop.stp - Periodically Print I/O Activity by Process Name
    +output: timed, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Every five seconds print out the top ten executables generating I/O traffic during that interval sorted in descending order.

  • +
  • nettop.stp - Periodic Listing of Processes Using Network Interfaces
    +output: timed, exits: user-controlled, status: production
    +subsystem: network, keywords: network traffic per-process
    +

    Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.

  • +
  • para-callgraph.stp - Tracing Calls for Sections of Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: kernel, keywords: trace callgraph
    +

    The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

  • +
  • pf2.stp - Profile kernel functions
    +output: sorted-list, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling
    +

    The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples.

  • +
  • sig_by_pid.stp - Signal Counts by Process ID
    +output: sorted-list on-exit, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    Print signal counts by process ID in descending order.

  • +
  • sig_by_proc.stp - Signal Counts by Process Name
    +output: sorted-list on-exit, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    Print signal counts by process name in descending order.

  • +
  • sigkill.stp - Track SIGKILL Signals
    +output: trace, exits: user-controlled, status: production
    +subsystem: signals, keywords: signals
    +

    The script traces any SIGKILL signals. When that SIGKILL signal is sent to a process, the script prints out the signal name, the desination executable and process ID, the executable name user ID that sent the signal.

  • +
  • syscalls_by_pid.stp - System-Wide Count of Syscalls by PID
    +output: trace, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name.

  • +
  • sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations
    +output: trace, exits: user-controlled, status: production
    +subsystem: scheduler, keywords: io scheduler
    +

    The script monitor time threads spend waiting for IO operations (in "D" state) in the wait_for_completion function. If a thread spends over 10ms wall-clock time waiting, information is printed out describing the thread number and executable name. When slow the wait_for_completion function complete, backtraces for the long duration calls are printed out.

  • +
  • sleeptime.stp - Trace Time Spent in nanosleep Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall sleep
    +

    The script watches each nanosleep syscall on the system. At the end of each nanosleep syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "nanosleep:" key, and the duration of the sleep in microseconds.

  • +
  • socket-trace.stp - Trace Functions called in Network Socket Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: network, keywords: network socket
    +

    The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

  • +
  • syscalls_by_pid.stp - System-Wide Count of Syscalls by PID
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall
    +

    The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each PID ordered from greatest to least number of syscalls.

  • +
  • syscalls_by_proc.stp - System-Wide Count of Syscalls by Executable
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall
    +

    The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each executable ordered from greates to least number of syscalls.

  • +
  • thread-times.stp - Profile kernel functions
    +output: sorted-list, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling
    +

    The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty processes with samples broken down into percentage total time spent in user-space and kernel-space.

  • +
  • traceio.stp - Track Cumulative I/O Activity by Process Name
    +output: timed, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Every second print out the top ten executables sorted in descending order based on cumulative I/O traffic observed.

  • +
  • traceio2.stp - Watch I/O Activity on a Particular Device
    +output: trace, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Print out the executable name and process number as reads and writes to the specified device occur.

  • +
  • wait4time.stp - Trace Time Spent in wait4 Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall wait4
    +

    The script watches each wait4 syscall on the system. At the end of each wait4 syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "wait4:" key, the duration of the wait and the PID that the wait4 was waiting for. If the waited for PID is not specified , it is "-1".

  • +
+
+
+
+ + + + + +
+ + diff --git a/examples/index.txt b/examples/index.txt new file mode 100644 index 00000000..6bc54183 --- /dev/null +++ b/examples/index.txt @@ -0,0 +1,238 @@ +SYSTEMTAP EXAMPLES INDEX +(see also subsystem-index.txt, keyword-index.txt) + +disktop.stp - Summarize Disk Read/Write Traffic +output: timed, exits: user-controlled, status: production +subsystem: disk, keywords: disk + + Get the status of reading/writing disk every 5 seconds, output top + ten entries during that period. + + +functioncallcount.stp - Count Times Functions Called +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling functions + + The functioncallcount.stp script takes one argument, a list of + functions to probe. The script will run and count the number of times + that each of the functions on the list is called. On exit the script + will print a sorted list from most frequently to least frequently + called function. + + +futexes.stp - System-Wide Futex Contention +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: locking, keywords: syscall locking futex + + The script watches the futex syscall on the system. On exit the + futexes address, the number of contentions, and the average time for + each contention on the futex are printed from lowest pid number to + highest. + + +graphs.stp - Graphing Disk and CPU Utilization +output: plot data, exits: user-controlled, status: production +subsystem: disk cpu, keywords: disk cpu use graph + + The script tracks the disk and CPU utilization. The resulting output + of the script can be piped into gnuplot to generate a graph of disk + and CPU USE. + + +helloworld.stp - SystemTap "Hello World" Program +output: text, exits: fixed, status: production +subsystem: none, keywords: simple + + A basic "Hello World" program implemented in SystemTap script. It + prints out "hello world" message and then immediately exits. + + +io_submit.stp - Tally Reschedule Reason During AIO io_submit Call +output: sorted on-exit, exits: user-controlled, status: production +subsystem: io, keywords: io backtrace + + When a reschedule occurs during an AIO io_submit call, accumulate the + traceback in a histogram. When the script exits prints out a sorted + list from most common to least common backtrace. + + +iotime.stp - Trace Time Spent in Read and Write for Files +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall read write time io + + The script watches each open, close, read, and write syscalls on the + system. For each file the scripts observes opened it accumulates the + amount of wall clock time spend in read and write operations and the + number of bytes read and written. When a file is closed the script + prints out a pair of lines for the file. Both lines begin with a + timestamp in microseconds, the PID number, and the executable name in + parenthesese. The first line with the "access" keyword lists the file + name, the attempted number of bytes for the read and write + operations. The second line with the "iotime" keyword list the file + name and the number of microseconds accumulated in the read and write + syscalls. + + +iotop.stp - Periodically Print I/O Activity by Process Name +output: timed, exits: user-controlled, status: production +subsystem: io, keywords: io + + Every five seconds print out the top ten executables generating I/O + traffic during that interval sorted in descending order. + + +nettop.stp - Periodic Listing of Processes Using Network Interfaces +output: timed, exits: user-controlled, status: production +subsystem: network, keywords: network traffic per-process + + Every five seconds the nettop.stp script prints out a list of + processed (PID and command) with the number of packets sent/received + and the amount of data sent/received by the process during that + interval. + + +para-callgraph.stp - Tracing Calls for Sections of Code +output: trace, exits: user-controlled, status: production +subsystem: kernel, keywords: trace callgraph + + The script takes two arguments: the first argument is the function to + starts/stops the per thread call graph traces and the second argument + is the list of functions to generate trace information on. The script + prints out a timestap for the thread, the function name and pid, + followed by entry or exit symboly and function name. + + +pf2.stp - Profile kernel functions +output: sorted-list, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling + + The pf2.stp script sets up time-based sampling. Every five seconds it + prints out a sorted list with the top ten kernel functions with + samples. + + +sig_by_pid.stp - Signal Counts by Process ID +output: sorted-list on-exit, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + Print signal counts by process ID in descending order. + + +sig_by_proc.stp - Signal Counts by Process Name +output: sorted-list on-exit, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + Print signal counts by process name in descending order. + + +sigkill.stp - Track SIGKILL Signals +output: trace, exits: user-controlled, status: production +subsystem: signals, keywords: signals + + The script traces any SIGKILL signals. When that SIGKILL signal is + sent to a process, the script prints out the signal name, the + desination executable and process ID, the executable name user ID + that sent the signal. + + +syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +output: trace, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + The script watches for a particular signal sent to a specific + process. When that signal is sent to the specified process, the + script prints out the PID and executable of the process sending the + signal, the PID and executable name of the process receiving the + signal, and the signal number and name. + + +sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations +output: trace, exits: user-controlled, status: production +subsystem: scheduler, keywords: io scheduler + + The script monitor time threads spend waiting for IO operations (in + "D" state) in the wait_for_completion function. If a thread spends + over 10ms wall-clock time waiting, information is printed out + describing the thread number and executable name. When slow the + wait_for_completion function complete, backtraces for the long + duration calls are printed out. + + +sleeptime.stp - Trace Time Spent in nanosleep Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall sleep + + The script watches each nanosleep syscall on the system. At the end + of each nanosleep syscall the script prints out a line with a + timestamp in microseconds, the pid, the executable name in + paretheses, the "nanosleep:" key, and the duration of the sleep in + microseconds. + + +socket-trace.stp - Trace Functions called in Network Socket Code +output: trace, exits: user-controlled, status: production +subsystem: network, keywords: network socket + + The script instrument each of the functions inn the Linux kernel's + net/socket.c file. The script prints out trace. The first element of + a line is time delta in microseconds from the previous entry. This + is followed by the command name and the PID. The "->" and "<-" + indicates function entry and function exit, respectively. The last + element of the line is the function name. + + +syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall + + The script watches all syscall on the system. On exit the script + prints a list showing the number of systemcalls executed by each PID + ordered from greatest to least number of syscalls. + + +syscalls_by_proc.stp - System-Wide Count of Syscalls by Executable +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall + + The script watches all syscall on the system. On exit the script + prints a list showing the number of systemcalls executed by each + executable ordered from greates to least number of syscalls. + + +thread-times.stp - Profile kernel functions +output: sorted-list, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling + + The thread-times.stp script sets up time-based sampling. Every five + seconds it prints out a sorted list with the top twenty processes + with samples broken down into percentage total time spent in + user-space and kernel-space. + + +traceio.stp - Track Cumulative I/O Activity by Process Name +output: timed, exits: user-controlled, status: production +subsystem: io, keywords: io + + Every second print out the top ten executables sorted in descending + order based on cumulative I/O traffic observed. + + +traceio2.stp - Watch I/O Activity on a Particular Device +output: trace, exits: user-controlled, status: production +subsystem: io, keywords: io + + Print out the executable name and process number as reads and writes + to the specified device occur. + + +wait4time.stp - Trace Time Spent in wait4 Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall wait4 + + The script watches each wait4 syscall on the system. At the end of + each wait4 syscall the script prints out a line with a timestamp in + microseconds, the pid, the executable name in paretheses, the + "wait4:" key, the duration of the wait and the PID that the wait4 was + waiting for. If the waited for PID is not specified , it is "-1". + + diff --git a/examples/io_submit.stp b/examples/io_submit.stp new file mode 100644 index 00000000..735dd6f9 --- /dev/null +++ b/examples/io_submit.stp @@ -0,0 +1,71 @@ +#!/bin/env stap +# +# Copyright (C) 2007 Oracle Corp. Chris Mason +# +# This was implemented to find the most common causes of schedule during +# the AIO io_submit call. It does this by recording which pids are inside +# AIO, and recording the current stack trace if one of those pids is +# inside schedule. +# When the probe exits, it prints out the 30 most common call stacks for +# schedule(). +# +# This file is free software. You can redistribute it and/or modify it under +# the terms of the GNU General Public License (GPL); either version 2, or (at +# your option) any later version. + +global in_iosubmit +global traces + +/* + * add a probe to sys_io_submit, on entry, record in the in_iosubmit + * hash table that this proc is in io_submit + */ +probe syscall.io_submit { + in_iosubmit[tid()] = 1 +} + +/* + * when we return from sys_io_submit, record that we're no longer there + */ +probe syscall.io_submit.return { + /* this assumes a given proc will do lots of io_submit calls, and + * so doesn't do the more expensive "delete in_iosubmit[p]". If + * there are lots of procs doing small number of io_submit calls, + * the hash may grow pretty big, so using delete may be better + */ + in_iosubmit[tid()] = 0 +} + +/* + * every time we call schedule, check to see if we started off in + * io_submit. If so, record our backtrace into the traces histogram + */ +probe kernel.function("schedule") { + if (tid() in in_iosubmit) { + traces[backtrace()]++ + + /* + * change this to if (1) if you want a backtrace every time + * you go into schedule from io_submit. Unfortunately, the traces + * saved into the traces histogram above are truncated to just a + * few lines. so the only way to see the full trace is via the + * more verbose print_backtrace() right here. + */ + if (0) { + printf("schedule in io_submit!\n") + print_backtrace() + } + } +} + +/* + * when stap is done (via ctrl-c) go through the record of all the + * trace paths and print the 30 most common. + */ +probe end { + foreach (stack in traces- limit 30) { + printf("%d:", traces[stack]) + print_stack(stack); + } +} + diff --git a/examples/iotime.stp b/examples/iotime.stp new file mode 100644 index 00000000..4fbd6b6e --- /dev/null +++ b/examples/iotime.stp @@ -0,0 +1,113 @@ +#! /usr/bin/env stap + +/* + * Copyright (C) 2006-2007 Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Print out the amount of time spent in the read and write systemcall + * when a process closes each file is closed. Note that the systemtap + * script needs to be running before the open operations occur for + * the script to record data. + * + * This script could be used to to find out which files are slow to load + * on a machine. e.g. + * + * stap iotime.stp -c 'firefox' + * + * Output format is: + * timestamp pid (executabable) info_type path ... + * + * 200283135 2573 (cupsd) access /etc/printcap read: 0 write: 7063 + * 200283143 2573 (cupsd) iotime /etc/printcap time: 69 + * + */ + +global start +global entry_io +global fd_io +global time_io + +function timestamp:long() { + return gettimeofday_us() - start +} + +function proc:string() { + return sprintf("%d (%s)", pid(), execname()) +} + +probe begin { + start = gettimeofday_us() +} + +global filenames +global filehandles +global fileread +global filewrite + +probe syscall.open { + filenames[pid()] = user_string($filename) +} + +probe syscall.open.return { + if ($return != -1) { + filehandles[pid(), $return] = filenames[pid()] + fileread[pid(), $return] = 0 + filewrite[pid(), $return] = 0 + } else { + printf("%d %s access %s fail\n", timestamp(), proc(), filenames[pid()]) + } + delete filenames[pid()] +} + +probe syscall.read { + if ($count > 0) { + fileread[pid(), $fd] += $count + } + t = gettimeofday_us(); p = pid() + entry_io[p] = t + fd_io[p] = $fd +} + +probe syscall.read.return { + t = gettimeofday_us(); p = pid() + fd = fd_io[p] + time_io[p,fd] <<< t - entry_io[p] +} + +probe syscall.write { + if ($count > 0) { + filewrite[pid(), $fd] += $count + } + t = gettimeofday_us(); p = pid() + entry_io[p] = t + fd_io[p] = $fd +} + +probe syscall.write.return { + t = gettimeofday_us(); p = pid() + fd = fd_io[p] + time_io[p,fd] <<< t - entry_io[p] +} + +probe syscall.close { + if (filehandles[pid(), $fd] != "") { + printf("%d %s access %s read: %d write: %d\n", timestamp(), proc(), + filehandles[pid(), $fd], fileread[pid(), $fd], filewrite[pid(), $fd]) + if (@count(time_io[pid(), $fd])) + printf("%d %s iotime %s time: %d\n", timestamp(), proc(), + filehandles[pid(), $fd], @sum(time_io[pid(), $fd])) + } + delete fileread[pid(), $fd] + delete filewrite[pid(), $fd] + delete filehandles[pid(), $fd] + delete fd_io[pid()] + delete entry_io[pid()] + delete time_io[pid(),$fd] +} diff --git a/examples/iotop.stp b/examples/iotop.stp new file mode 100644 index 00000000..6050343c --- /dev/null +++ b/examples/iotop.stp @@ -0,0 +1,25 @@ +global reads, writes, total_io + +probe kernel.function("vfs_read") { + reads[execname()] += $count +} + +probe kernel.function("vfs_write") { + writes[execname()] += $count +} + +# print top 10 IO processes every 5 seconds +probe timer.s(5) { + foreach (name in writes) + total_io[name] += writes[name] + foreach (name in reads) + total_io[name] += reads[name] + printf ("%16s\t%10s\t%10s\n", "Process", "KB Read", "KB Written") + foreach (name in total_io- limit 10) + printf("%16s\t%10d\t%10d\n", name, + reads[name]/1024, writes[name]/1024) + delete reads + delete writes + delete total_io + print("\n") +} diff --git a/examples/keyword-index.html b/examples/keyword-index.html new file mode 100644 index 00000000..00be2912 --- /dev/null +++ b/examples/keyword-index.html @@ -0,0 +1,299 @@ + + + + + SystemTap Examples + + + + + + + + + + + +
SystemTap logo + SystemTap |  +
+ +
+
+ + + + + + + + + + +
 

Examples

  + +

Example Indexes

+ + +

Examples by Keyword

+

BACKTRACE

+
    +
  • io_submit.stp - Tally Reschedule Reason During AIO io_submit Call
    +output: sorted on-exit, exits: user-controlled, status: production
    +subsystem: io, keywords: io backtrace
    +

    When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.

  • +
+

CALLGRAPH

+
    +
  • para-callgraph.stp - Tracing Calls for Sections of Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: kernel, keywords: trace callgraph
    +

    The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

  • +
+

CPU

+
    +
  • graphs.stp - Graphing Disk and CPU Utilization
    +output: plot data, exits: user-controlled, status: production
    +subsystem: disk cpu, keywords: disk cpu use graph
    +

    The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.

  • +
+

DISK

+
    +
  • disktop.stp - Summarize Disk Read/Write Traffic
    +output: timed, exits: user-controlled, status: production
    +subsystem: disk, keywords: disk
    +

    Get the status of reading/writing disk every 5 seconds, output top ten entries during that period.

  • +
  • graphs.stp - Graphing Disk and CPU Utilization
    +output: plot data, exits: user-controlled, status: production
    +subsystem: disk cpu, keywords: disk cpu use graph
    +

    The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.

  • +
+

FUNCTIONS

+
    +
  • functioncallcount.stp - Count Times Functions Called
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling functions
    +

    The functioncallcount.stp script takes one argument, a list of functions to probe. The script will run and count the number of times that each of the functions on the list is called. On exit the script will print a sorted list from most frequently to least frequently called function.

  • +
+

FUTEX

+
    +
  • futexes.stp - System-Wide Futex Contention
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: locking, keywords: syscall locking futex
    +

    The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.

  • +
+

GRAPH

+
    +
  • graphs.stp - Graphing Disk and CPU Utilization
    +output: plot data, exits: user-controlled, status: production
    +subsystem: disk cpu, keywords: disk cpu use graph
    +

    The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.

  • +
+

IO

+
    +
  • io_submit.stp - Tally Reschedule Reason During AIO io_submit Call
    +output: sorted on-exit, exits: user-controlled, status: production
    +subsystem: io, keywords: io backtrace
    +

    When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.

  • +
  • iotime.stp - Trace Time Spent in Read and Write for Files
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall read write time io
    +

    The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.

  • +
  • iotop.stp - Periodically Print I/O Activity by Process Name
    +output: timed, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Every five seconds print out the top ten executables generating I/O traffic during that interval sorted in descending order.

  • +
  • sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations
    +output: trace, exits: user-controlled, status: production
    +subsystem: scheduler, keywords: io scheduler
    +

    The script monitor time threads spend waiting for IO operations (in "D" state) in the wait_for_completion function. If a thread spends over 10ms wall-clock time waiting, information is printed out describing the thread number and executable name. When slow the wait_for_completion function complete, backtraces for the long duration calls are printed out.

  • +
  • traceio.stp - Track Cumulative I/O Activity by Process Name
    +output: timed, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Every second print out the top ten executables sorted in descending order based on cumulative I/O traffic observed.

  • +
  • traceio2.stp - Watch I/O Activity on a Particular Device
    +output: trace, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Print out the executable name and process number as reads and writes to the specified device occur.

  • +
+

LOCKING

+
    +
  • futexes.stp - System-Wide Futex Contention
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: locking, keywords: syscall locking futex
    +

    The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.

  • +
+

NETWORK

+
    +
  • nettop.stp - Periodic Listing of Processes Using Network Interfaces
    +output: timed, exits: user-controlled, status: production
    +subsystem: network, keywords: network traffic per-process
    +

    Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.

  • +
  • socket-trace.stp - Trace Functions called in Network Socket Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: network, keywords: network socket
    +

    The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

  • +
+

PER-PROCESS

+
    +
  • nettop.stp - Periodic Listing of Processes Using Network Interfaces
    +output: timed, exits: user-controlled, status: production
    +subsystem: network, keywords: network traffic per-process
    +

    Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.

  • +
+

PROFILING

+
    +
  • functioncallcount.stp - Count Times Functions Called
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling functions
    +

    The functioncallcount.stp script takes one argument, a list of functions to probe. The script will run and count the number of times that each of the functions on the list is called. On exit the script will print a sorted list from most frequently to least frequently called function.

  • +
  • pf2.stp - Profile kernel functions
    +output: sorted-list, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling
    +

    The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples.

  • +
  • thread-times.stp - Profile kernel functions
    +output: sorted-list, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling
    +

    The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty processes with samples broken down into percentage total time spent in user-space and kernel-space.

  • +
+

READ

+
    +
  • iotime.stp - Trace Time Spent in Read and Write for Files
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall read write time io
    +

    The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.

  • +
+

SCHEDULER

+
    +
  • sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations
    +output: trace, exits: user-controlled, status: production
    +subsystem: scheduler, keywords: io scheduler
    +

    The script monitor time threads spend waiting for IO operations (in "D" state) in the wait_for_completion function. If a thread spends over 10ms wall-clock time waiting, information is printed out describing the thread number and executable name. When slow the wait_for_completion function complete, backtraces for the long duration calls are printed out.

  • +
+

SIGNALS

+
    +
  • sig_by_pid.stp - Signal Counts by Process ID
    +output: sorted-list on-exit, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    Print signal counts by process ID in descending order.

  • +
  • sig_by_proc.stp - Signal Counts by Process Name
    +output: sorted-list on-exit, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    Print signal counts by process name in descending order.

  • +
  • sigkill.stp - Track SIGKILL Signals
    +output: trace, exits: user-controlled, status: production
    +subsystem: signals, keywords: signals
    +

    The script traces any SIGKILL signals. When that SIGKILL signal is sent to a process, the script prints out the signal name, the desination executable and process ID, the executable name user ID that sent the signal.

  • +
  • syscalls_by_pid.stp - System-Wide Count of Syscalls by PID
    +output: trace, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name.

  • +
+

SIMPLE

+
    +
  • helloworld.stp - SystemTap "Hello World" Program
    +output: text, exits: fixed, status: production
    +subsystem: none, keywords: simple
    +

    A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.

  • +
+

SLEEP

+
    +
  • sleeptime.stp - Trace Time Spent in nanosleep Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall sleep
    +

    The script watches each nanosleep syscall on the system. At the end of each nanosleep syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "nanosleep:" key, and the duration of the sleep in microseconds.

  • +
+

SOCKET

+
    +
  • socket-trace.stp - Trace Functions called in Network Socket Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: network, keywords: network socket
    +

    The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

  • +
+

SYSCALL

+
    +
  • futexes.stp - System-Wide Futex Contention
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: locking, keywords: syscall locking futex
    +

    The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.

  • +
  • iotime.stp - Trace Time Spent in Read and Write for Files
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall read write time io
    +

    The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.

  • +
  • sleeptime.stp - Trace Time Spent in nanosleep Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall sleep
    +

    The script watches each nanosleep syscall on the system. At the end of each nanosleep syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "nanosleep:" key, and the duration of the sleep in microseconds.

  • +
  • syscalls_by_pid.stp - System-Wide Count of Syscalls by PID
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall
    +

    The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each PID ordered from greatest to least number of syscalls.

  • +
  • syscalls_by_proc.stp - System-Wide Count of Syscalls by Executable
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall
    +

    The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each executable ordered from greates to least number of syscalls.

  • +
  • wait4time.stp - Trace Time Spent in wait4 Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall wait4
    +

    The script watches each wait4 syscall on the system. At the end of each wait4 syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "wait4:" key, the duration of the wait and the PID that the wait4 was waiting for. If the waited for PID is not specified , it is "-1".

  • +
+

TIME

+
    +
  • iotime.stp - Trace Time Spent in Read and Write for Files
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall read write time io
    +

    The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.

  • +
+

TRACE

+
    +
  • para-callgraph.stp - Tracing Calls for Sections of Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: kernel, keywords: trace callgraph
    +

    The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

  • +
+

TRAFFIC

+
    +
  • nettop.stp - Periodic Listing of Processes Using Network Interfaces
    +output: timed, exits: user-controlled, status: production
    +subsystem: network, keywords: network traffic per-process
    +

    Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.

  • +
+

USE

+
    +
  • graphs.stp - Graphing Disk and CPU Utilization
    +output: plot data, exits: user-controlled, status: production
    +subsystem: disk cpu, keywords: disk cpu use graph
    +

    The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.

  • +
+

WAIT4

+
    +
  • wait4time.stp - Trace Time Spent in wait4 Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall wait4
    +

    The script watches each wait4 syscall on the system. At the end of each wait4 syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "wait4:" key, the duration of the wait and the PID that the wait4 was waiting for. If the waited for PID is not specified , it is "-1".

  • +
+

WRITE

+
    +
  • iotime.stp - Trace Time Spent in Read and Write for Files
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall read write time io
    +

    The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.

  • +
+
+
+
+ + + + + +
+ + diff --git a/examples/keyword-index.txt b/examples/keyword-index.txt new file mode 100644 index 00000000..01762456 --- /dev/null +++ b/examples/keyword-index.txt @@ -0,0 +1,500 @@ +SYSTEMTAP EXAMPLES INDEX BY KEYWORD +(see also index.txt, subsystem-index.txt) + += BACKTRACE = + +io_submit.stp - Tally Reschedule Reason During AIO io_submit Call +output: sorted on-exit, exits: user-controlled, status: production +subsystem: io, keywords: io backtrace + + When a reschedule occurs during an AIO io_submit call, accumulate the + traceback in a histogram. When the script exits prints out a sorted + list from most common to least common backtrace. + + += CALLGRAPH = + +para-callgraph.stp - Tracing Calls for Sections of Code +output: trace, exits: user-controlled, status: production +subsystem: kernel, keywords: trace callgraph + + The script takes two arguments: the first argument is the function to + starts/stops the per thread call graph traces and the second argument + is the list of functions to generate trace information on. The script + prints out a timestap for the thread, the function name and pid, + followed by entry or exit symboly and function name. + + += CPU = + +graphs.stp - Graphing Disk and CPU Utilization +output: plot data, exits: user-controlled, status: production +subsystem: disk cpu, keywords: disk cpu use graph + + The script tracks the disk and CPU utilization. The resulting output + of the script can be piped into gnuplot to generate a graph of disk + and CPU USE. + + += DISK = + +disktop.stp - Summarize Disk Read/Write Traffic +output: timed, exits: user-controlled, status: production +subsystem: disk, keywords: disk + + Get the status of reading/writing disk every 5 seconds, output top + ten entries during that period. + + +graphs.stp - Graphing Disk and CPU Utilization +output: plot data, exits: user-controlled, status: production +subsystem: disk cpu, keywords: disk cpu use graph + + The script tracks the disk and CPU utilization. The resulting output + of the script can be piped into gnuplot to generate a graph of disk + and CPU USE. + + += FUNCTIONS = + +functioncallcount.stp - Count Times Functions Called +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling functions + + The functioncallcount.stp script takes one argument, a list of + functions to probe. The script will run and count the number of times + that each of the functions on the list is called. On exit the script + will print a sorted list from most frequently to least frequently + called function. + + += FUTEX = + +futexes.stp - System-Wide Futex Contention +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: locking, keywords: syscall locking futex + + The script watches the futex syscall on the system. On exit the + futexes address, the number of contentions, and the average time for + each contention on the futex are printed from lowest pid number to + highest. + + += GRAPH = + +graphs.stp - Graphing Disk and CPU Utilization +output: plot data, exits: user-controlled, status: production +subsystem: disk cpu, keywords: disk cpu use graph + + The script tracks the disk and CPU utilization. The resulting output + of the script can be piped into gnuplot to generate a graph of disk + and CPU USE. + + += IO = + +io_submit.stp - Tally Reschedule Reason During AIO io_submit Call +output: sorted on-exit, exits: user-controlled, status: production +subsystem: io, keywords: io backtrace + + When a reschedule occurs during an AIO io_submit call, accumulate the + traceback in a histogram. When the script exits prints out a sorted + list from most common to least common backtrace. + + +iotime.stp - Trace Time Spent in Read and Write for Files +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall read write time io + + The script watches each open, close, read, and write syscalls on the + system. For each file the scripts observes opened it accumulates the + amount of wall clock time spend in read and write operations and the + number of bytes read and written. When a file is closed the script + prints out a pair of lines for the file. Both lines begin with a + timestamp in microseconds, the PID number, and the executable name in + parenthesese. The first line with the "access" keyword lists the file + name, the attempted number of bytes for the read and write + operations. The second line with the "iotime" keyword list the file + name and the number of microseconds accumulated in the read and write + syscalls. + + +iotop.stp - Periodically Print I/O Activity by Process Name +output: timed, exits: user-controlled, status: production +subsystem: io, keywords: io + + Every five seconds print out the top ten executables generating I/O + traffic during that interval sorted in descending order. + + +sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations +output: trace, exits: user-controlled, status: production +subsystem: scheduler, keywords: io scheduler + + The script monitor time threads spend waiting for IO operations (in + "D" state) in the wait_for_completion function. If a thread spends + over 10ms wall-clock time waiting, information is printed out + describing the thread number and executable name. When slow the + wait_for_completion function complete, backtraces for the long + duration calls are printed out. + + +traceio.stp - Track Cumulative I/O Activity by Process Name +output: timed, exits: user-controlled, status: production +subsystem: io, keywords: io + + Every second print out the top ten executables sorted in descending + order based on cumulative I/O traffic observed. + + +traceio2.stp - Watch I/O Activity on a Particular Device +output: trace, exits: user-controlled, status: production +subsystem: io, keywords: io + + Print out the executable name and process number as reads and writes + to the specified device occur. + + += LOCKING = + +futexes.stp - System-Wide Futex Contention +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: locking, keywords: syscall locking futex + + The script watches the futex syscall on the system. On exit the + futexes address, the number of contentions, and the average time for + each contention on the futex are printed from lowest pid number to + highest. + + += NETWORK = + +nettop.stp - Periodic Listing of Processes Using Network Interfaces +output: timed, exits: user-controlled, status: production +subsystem: network, keywords: network traffic per-process + + Every five seconds the nettop.stp script prints out a list of + processed (PID and command) with the number of packets sent/received + and the amount of data sent/received by the process during that + interval. + + +socket-trace.stp - Trace Functions called in Network Socket Code +output: trace, exits: user-controlled, status: production +subsystem: network, keywords: network socket + + The script instrument each of the functions inn the Linux kernel's + net/socket.c file. The script prints out trace. The first element of + a line is time delta in microseconds from the previous entry. This + is followed by the command name and the PID. The "->" and "<-" + indicates function entry and function exit, respectively. The last + element of the line is the function name. + + += PER-PROCESS = + +nettop.stp - Periodic Listing of Processes Using Network Interfaces +output: timed, exits: user-controlled, status: production +subsystem: network, keywords: network traffic per-process + + Every five seconds the nettop.stp script prints out a list of + processed (PID and command) with the number of packets sent/received + and the amount of data sent/received by the process during that + interval. + + += PROFILING = + +functioncallcount.stp - Count Times Functions Called +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling functions + + The functioncallcount.stp script takes one argument, a list of + functions to probe. The script will run and count the number of times + that each of the functions on the list is called. On exit the script + will print a sorted list from most frequently to least frequently + called function. + + +pf2.stp - Profile kernel functions +output: sorted-list, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling + + The pf2.stp script sets up time-based sampling. Every five seconds it + prints out a sorted list with the top ten kernel functions with + samples. + + +thread-times.stp - Profile kernel functions +output: sorted-list, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling + + The thread-times.stp script sets up time-based sampling. Every five + seconds it prints out a sorted list with the top twenty processes + with samples broken down into percentage total time spent in + user-space and kernel-space. + + += READ = + +iotime.stp - Trace Time Spent in Read and Write for Files +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall read write time io + + The script watches each open, close, read, and write syscalls on the + system. For each file the scripts observes opened it accumulates the + amount of wall clock time spend in read and write operations and the + number of bytes read and written. When a file is closed the script + prints out a pair of lines for the file. Both lines begin with a + timestamp in microseconds, the PID number, and the executable name in + parenthesese. The first line with the "access" keyword lists the file + name, the attempted number of bytes for the read and write + operations. The second line with the "iotime" keyword list the file + name and the number of microseconds accumulated in the read and write + syscalls. + + += SCHEDULER = + +sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations +output: trace, exits: user-controlled, status: production +subsystem: scheduler, keywords: io scheduler + + The script monitor time threads spend waiting for IO operations (in + "D" state) in the wait_for_completion function. If a thread spends + over 10ms wall-clock time waiting, information is printed out + describing the thread number and executable name. When slow the + wait_for_completion function complete, backtraces for the long + duration calls are printed out. + + += SIGNALS = + +sig_by_pid.stp - Signal Counts by Process ID +output: sorted-list on-exit, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + Print signal counts by process ID in descending order. + + +sig_by_proc.stp - Signal Counts by Process Name +output: sorted-list on-exit, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + Print signal counts by process name in descending order. + + +sigkill.stp - Track SIGKILL Signals +output: trace, exits: user-controlled, status: production +subsystem: signals, keywords: signals + + The script traces any SIGKILL signals. When that SIGKILL signal is + sent to a process, the script prints out the signal name, the + desination executable and process ID, the executable name user ID + that sent the signal. + + +syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +output: trace, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + The script watches for a particular signal sent to a specific + process. When that signal is sent to the specified process, the + script prints out the PID and executable of the process sending the + signal, the PID and executable name of the process receiving the + signal, and the signal number and name. + + += SIMPLE = + +helloworld.stp - SystemTap "Hello World" Program +output: text, exits: fixed, status: production +subsystem: none, keywords: simple + + A basic "Hello World" program implemented in SystemTap script. It + prints out "hello world" message and then immediately exits. + + += SLEEP = + +sleeptime.stp - Trace Time Spent in nanosleep Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall sleep + + The script watches each nanosleep syscall on the system. At the end + of each nanosleep syscall the script prints out a line with a + timestamp in microseconds, the pid, the executable name in + paretheses, the "nanosleep:" key, and the duration of the sleep in + microseconds. + + += SOCKET = + +socket-trace.stp - Trace Functions called in Network Socket Code +output: trace, exits: user-controlled, status: production +subsystem: network, keywords: network socket + + The script instrument each of the functions inn the Linux kernel's + net/socket.c file. The script prints out trace. The first element of + a line is time delta in microseconds from the previous entry. This + is followed by the command name and the PID. The "->" and "<-" + indicates function entry and function exit, respectively. The last + element of the line is the function name. + + += SYSCALL = + +futexes.stp - System-Wide Futex Contention +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: locking, keywords: syscall locking futex + + The script watches the futex syscall on the system. On exit the + futexes address, the number of contentions, and the average time for + each contention on the futex are printed from lowest pid number to + highest. + + +iotime.stp - Trace Time Spent in Read and Write for Files +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall read write time io + + The script watches each open, close, read, and write syscalls on the + system. For each file the scripts observes opened it accumulates the + amount of wall clock time spend in read and write operations and the + number of bytes read and written. When a file is closed the script + prints out a pair of lines for the file. Both lines begin with a + timestamp in microseconds, the PID number, and the executable name in + parenthesese. The first line with the "access" keyword lists the file + name, the attempted number of bytes for the read and write + operations. The second line with the "iotime" keyword list the file + name and the number of microseconds accumulated in the read and write + syscalls. + + +sleeptime.stp - Trace Time Spent in nanosleep Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall sleep + + The script watches each nanosleep syscall on the system. At the end + of each nanosleep syscall the script prints out a line with a + timestamp in microseconds, the pid, the executable name in + paretheses, the "nanosleep:" key, and the duration of the sleep in + microseconds. + + +syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall + + The script watches all syscall on the system. On exit the script + prints a list showing the number of systemcalls executed by each PID + ordered from greatest to least number of syscalls. + + +syscalls_by_proc.stp - System-Wide Count of Syscalls by Executable +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall + + The script watches all syscall on the system. On exit the script + prints a list showing the number of systemcalls executed by each + executable ordered from greates to least number of syscalls. + + +wait4time.stp - Trace Time Spent in wait4 Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall wait4 + + The script watches each wait4 syscall on the system. At the end of + each wait4 syscall the script prints out a line with a timestamp in + microseconds, the pid, the executable name in paretheses, the + "wait4:" key, the duration of the wait and the PID that the wait4 was + waiting for. If the waited for PID is not specified , it is "-1". + + += TIME = + +iotime.stp - Trace Time Spent in Read and Write for Files +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall read write time io + + The script watches each open, close, read, and write syscalls on the + system. For each file the scripts observes opened it accumulates the + amount of wall clock time spend in read and write operations and the + number of bytes read and written. When a file is closed the script + prints out a pair of lines for the file. Both lines begin with a + timestamp in microseconds, the PID number, and the executable name in + parenthesese. The first line with the "access" keyword lists the file + name, the attempted number of bytes for the read and write + operations. The second line with the "iotime" keyword list the file + name and the number of microseconds accumulated in the read and write + syscalls. + + += TRACE = + +para-callgraph.stp - Tracing Calls for Sections of Code +output: trace, exits: user-controlled, status: production +subsystem: kernel, keywords: trace callgraph + + The script takes two arguments: the first argument is the function to + starts/stops the per thread call graph traces and the second argument + is the list of functions to generate trace information on. The script + prints out a timestap for the thread, the function name and pid, + followed by entry or exit symboly and function name. + + += TRAFFIC = + +nettop.stp - Periodic Listing of Processes Using Network Interfaces +output: timed, exits: user-controlled, status: production +subsystem: network, keywords: network traffic per-process + + Every five seconds the nettop.stp script prints out a list of + processed (PID and command) with the number of packets sent/received + and the amount of data sent/received by the process during that + interval. + + += USE = + +graphs.stp - Graphing Disk and CPU Utilization +output: plot data, exits: user-controlled, status: production +subsystem: disk cpu, keywords: disk cpu use graph + + The script tracks the disk and CPU utilization. The resulting output + of the script can be piped into gnuplot to generate a graph of disk + and CPU USE. + + += WAIT4 = + +wait4time.stp - Trace Time Spent in wait4 Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall wait4 + + The script watches each wait4 syscall on the system. At the end of + each wait4 syscall the script prints out a line with a timestamp in + microseconds, the pid, the executable name in paretheses, the + "wait4:" key, the duration of the wait and the PID that the wait4 was + waiting for. If the waited for PID is not specified , it is "-1". + + += WRITE = + +iotime.stp - Trace Time Spent in Read and Write for Files +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall read write time io + + The script watches each open, close, read, and write syscalls on the + system. For each file the scripts observes opened it accumulates the + amount of wall clock time spend in read and write operations and the + number of bytes read and written. When a file is closed the script + prints out a pair of lines for the file. Both lines begin with a + timestamp in microseconds, the PID number, and the executable name in + parenthesese. The first line with the "access" keyword lists the file + name, the attempted number of bytes for the read and write + operations. The second line with the "iotime" keyword list the file + name and the number of microseconds accumulated in the read and write + syscalls. + + diff --git a/examples/nettop.stp b/examples/nettop.stp new file mode 100644 index 00000000..96db413a --- /dev/null +++ b/examples/nettop.stp @@ -0,0 +1,42 @@ +#! /usr/bin/env stap + +global ifxmit, ifrecv + +probe netdev.transmit +{ + ifxmit[pid(), dev_name, execname(), uid()] <<< length +} + +probe netdev.receive +{ + ifrecv[pid(), dev_name, execname(), uid()] <<< length +} + + +function print_activity() +{ + printf("%5s %5s %-7s %7s %7s %7s %7s %-15s\n", + "PID", "UID", "DEV", "XMIT_PK", "RECV_PK", + "XMIT_KB", "RECV_KB", "COMMAND") + + foreach ([pid, dev, exec, uid] in ifrecv-) { + n_xmit = @count(ifxmit[pid, dev, exec, uid]) + n_recv = @count(ifrecv[pid, dev, exec, uid]) + printf("%5d %5d %-7s %7d %7d %7d %7d %-15s\n", + pid, uid, dev, n_xmit, n_recv, + n_xmit ? @sum(ifxmit[pid, dev, exec, uid])/1024 : 0, + n_recv ? @sum(ifrecv[pid, dev, exec, uid])/1024 : 0, + exec) + } + + print("\n") + + delete ifxmit + delete ifrecv +} + +probe timer.ms(5000), end, error +{ + print_activity() +} + diff --git a/examples/para-callgraph.stp b/examples/para-callgraph.stp new file mode 100644 index 00000000..1afb8837 --- /dev/null +++ b/examples/para-callgraph.stp @@ -0,0 +1,20 @@ +function trace(entry_p) { + if(tid() in trace) + printf("%s%s%s\n",thread_indent(entry_p), + (entry_p>0?"->":"<-"), + probefunc()) +} + +global trace +probe kernel.function(@1).call { + if (execname() == "stapio") next # skip our own helper process + trace[tid()] = 1 + trace(1) +} +probe kernel.function(@1).return { + trace(-1) + delete trace[tid()] +} + +probe kernel.function(@2).call { trace(1) } +probe kernel.function(@2).return { trace(-1) } diff --git a/examples/pf2.stp b/examples/pf2.stp new file mode 100644 index 00000000..a804c3ff --- /dev/null +++ b/examples/pf2.stp @@ -0,0 +1,16 @@ +#! /usr/bin/env stap + +global profile, pcount +probe timer.profile { + pcount <<< 1 + fn = probefunc () + if (fn != "") profile[fn] <<< 1 +} +probe timer.ms(5000) { + printf ("\n--- %d samples recorded:\n", @count(pcount)) + foreach (f in profile- limit 10) { + printf ("%-30s\t%6d\n", f, @count(profile[f])) + } + delete profile + delete pcount +} diff --git a/examples/sig_by_pid.stp b/examples/sig_by_pid.stp new file mode 100644 index 00000000..9c1493f5 --- /dev/null +++ b/examples/sig_by_pid.stp @@ -0,0 +1,42 @@ +#! /usr/bin/env stap + +# Copyright (C) 2006 IBM Corp. +# +# This file is part of systemtap, and is free software. You can +# redistribute it and/or modify it under the terms of the GNU General +# Public License (GPL); either version 2, or (at your option) any +# later version. + +# +# Print signal counts by process IDs in descending order. +# + +global sigcnt, pid2name, sig2name + +probe begin { + print("Collecting data... Type Ctrl-C to exit and display results\n") +} + +probe signal.send +{ + snd_pid = pid() + rcv_pid = sig_pid + + sigcnt[snd_pid, rcv_pid, sig]++ + + if (!(snd_pid in pid2name)) pid2name[snd_pid] = execname() + if (!(rcv_pid in pid2name)) pid2name[rcv_pid] = pid_name + if (!(sig in sig2name)) sig2name[sig] = sig_name +} + +probe end +{ + printf("%-8s %-16s %-5s %-16s %-16s %s\n", + "SPID", "SENDER", "RPID", "RECEIVER", "SIGNAME", "COUNT") + + foreach ([snd_pid, rcv_pid, sig_num] in sigcnt-) { + printf("%-8d %-16s %-5d %-16s %-16s %d\n", + snd_pid, pid2name[snd_pid], rcv_pid, pid2name[rcv_pid], + sig2name[sig_num], sigcnt[snd_pid, rcv_pid, sig_num]) + } +} diff --git a/examples/sig_by_proc.stp b/examples/sig_by_proc.stp new file mode 100644 index 00000000..ce845aed --- /dev/null +++ b/examples/sig_by_proc.stp @@ -0,0 +1,36 @@ +#! /usr/bin/env stap + +# Copyright (C) 2006 IBM Corp. +# +# This file is part of systemtap, and is free software. You can +# redistribute it and/or modify it under the terms of the GNU General +# Public License (GPL); either version 2, or (at your option) any +# later version. + +# +# Print signal counts by process name in descending order. +# + +global sigcnt, sig2name + +probe begin { + print("Collecting data... Type Ctrl-C to exit and display results\n") +} + +probe signal.send +{ + sigcnt[execname(), pid_name, sig]++ + + if (!(sig in sig2name)) sig2name[sig] = sig_name +} + +probe end +{ + printf("%-16s %-16s %-16s %s\n", + "SENDER", "RECEIVER", "SIGNAL", "COUNT") + + foreach ([snd_name, rcv_name, sig_num] in sigcnt-) + printf("%-16s %-16s %-16s %d\n", + snd_name, rcv_name, sig2name[sig_num], + sigcnt[snd_name, rcv_name, sig_num]) +} diff --git a/examples/sigkill.stp b/examples/sigkill.stp new file mode 100644 index 00000000..8f754219 --- /dev/null +++ b/examples/sigkill.stp @@ -0,0 +1,23 @@ +#!/usr/bin/env stap +# sigkill.stp +# Copyright (C) 2007 Red Hat, Inc., Eugene Teo +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# /usr/share/systemtap/tapset/signal.stp: +# [...] +# probe signal.send = _signal.send.* +# { +# sig=$sig +# sig_name = _signal_name($sig) +# sig_pid = task_pid(task) +# pid_name = task_execname(task) +# [...] + +probe signal.send { + if (sig_name == "SIGKILL") + printf("%s was sent to %s (pid:%d) by %s uid:%d\n", + sig_name, pid_name, sig_pid, execname(), uid()) +} diff --git a/examples/sleepingBeauties.stp b/examples/sleepingBeauties.stp new file mode 100644 index 00000000..64c563a3 --- /dev/null +++ b/examples/sleepingBeauties.stp @@ -0,0 +1,58 @@ +#! /usr/bin/stap + +function time () { return gettimeofday_ms() } +global time_name = "ms" +global boredom = 10 # in time units +global name, back, backtime, bored + +/* Note: the order that the probes are listed should not matter. + However, the following order for + probe kernel.function("wait_for_completion").return and + probe kernel.function("wait_for_completion").call + avoids have the kretprobe stuff in the backtrace. + for more information see: + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6436 +*/ + + +probe kernel.function("wait_for_completion").return +{ + t=tid() + + if ([t] in bored) { + patience = time() - backtime[t] + printf ("thread %d (%s) bored for %d %s\n", + t, name[t], patience, time_name) + } + + delete bored[t] + delete back[t] + delete name[t] + delete backtime[t] +} + + +probe kernel.function("wait_for_completion").call +{ + t=tid() + back[t]=backtrace() + name[t]=execname() + backtime[t]=time() + delete bored[t] +} + + +probe timer.profile { + foreach (tid+ in back) { + if ([tid] in bored) continue + + patience = time() - backtime[tid] + if (patience >= boredom) { + printf ("thread %d (%s) impatient after %d %s\n", + tid, name[tid], patience, time_name) + print_stack (back[tid]) + printf ("\n") + bored[tid] = 1 # defer further reports to wakeup + } + } +} diff --git a/examples/sleeptime.stp b/examples/sleeptime.stp new file mode 100644 index 00000000..b5729ceb --- /dev/null +++ b/examples/sleeptime.stp @@ -0,0 +1,62 @@ +#! /usr/bin/env stap + +/* + * Copyright (C) 2006-2007 Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Print out the amount of time spent in the nanosleep and compat_nanosleep + * systemcalls. This can help find which processes are waking based on time + * rather than some real event than needs to be handled. + * + * Format is: + * 12799538 3389 (xchat) nanosleep: 9547 + * 12846944 2805 (NetworkManager) nanosleep: 100964 + * 12947924 2805 (NetworkManager) nanosleep: 100946 + * 13002925 4757 (sleep) nanosleep: 13000717 + */ + +global start +global entry_nanosleep + +function timestamp:long() { + return gettimeofday_us() - start +} + +function proc:string() { + return sprintf("%d (%s)", pid(), execname()) +} + +probe begin { + start = gettimeofday_us() +} + +probe syscall.nanosleep { + t = gettimeofday_us(); p = pid() + entry_nanosleep[p] = t +} + +probe syscall.nanosleep.return { + t = gettimeofday_us(); p = pid() + elapsed_time = t - entry_nanosleep[p] + printf("%d %s nanosleep: %d\n", timestamp(), proc(), elapsed_time) + delete entry_nanosleep[p] +} + +probe syscall.compat_nanosleep ? { + t = gettimeofday_us(); p = pid() + entry_nanosleep[p] = t +} + +probe syscall.compat_nanosleep.return ? { + t = gettimeofday_us(); p = pid() + elapsed_time = t - entry_nanosleep[p] + printf("%d %s compat_nanosleep: %d\n", timestamp(), proc(), elapsed_time) + delete entry_nanosleep[p] +} diff --git a/examples/socket-trace.stp b/examples/socket-trace.stp new file mode 100644 index 00000000..13ab8e06 --- /dev/null +++ b/examples/socket-trace.stp @@ -0,0 +1,8 @@ +#! /usr/bin/env stap + +probe kernel.function("*@net/socket.c").call { + printf ("%s -> %s\n", thread_indent(1), probefunc()) +} +probe kernel.function("*@net/socket.c").return { + printf ("%s <- %s\n", thread_indent(-1), probefunc()) +} diff --git a/examples/subsystem-index.html b/examples/subsystem-index.html new file mode 100644 index 00000000..d48ece1e --- /dev/null +++ b/examples/subsystem-index.html @@ -0,0 +1,186 @@ + + + + + SystemTap Examples + + + + + + + + + + + +
SystemTap logo + SystemTap |  +
+ +
+
+ + + + + + + + + + +
 

Examples

  + +

Example Indexes

+ + +

Examples by Subsystem

+

CPU

+
    +
  • graphs.stp - Graphing Disk and CPU Utilization
    +output: plot data, exits: user-controlled, status: production
    +subsystem: disk cpu, keywords: disk cpu use graph
    +

    The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.

  • +
+

DISK

+
    +
  • disktop.stp - Summarize Disk Read/Write Traffic
    +output: timed, exits: user-controlled, status: production
    +subsystem: disk, keywords: disk
    +

    Get the status of reading/writing disk every 5 seconds, output top ten entries during that period.

  • +
  • graphs.stp - Graphing Disk and CPU Utilization
    +output: plot data, exits: user-controlled, status: production
    +subsystem: disk cpu, keywords: disk cpu use graph
    +

    The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.

  • +
+

IO

+
    +
  • io_submit.stp - Tally Reschedule Reason During AIO io_submit Call
    +output: sorted on-exit, exits: user-controlled, status: production
    +subsystem: io, keywords: io backtrace
    +

    When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.

  • +
  • iotop.stp - Periodically Print I/O Activity by Process Name
    +output: timed, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Every five seconds print out the top ten executables generating I/O traffic during that interval sorted in descending order.

  • +
  • traceio.stp - Track Cumulative I/O Activity by Process Name
    +output: timed, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Every second print out the top ten executables sorted in descending order based on cumulative I/O traffic observed.

  • +
  • traceio2.stp - Watch I/O Activity on a Particular Device
    +output: trace, exits: user-controlled, status: production
    +subsystem: io, keywords: io
    +

    Print out the executable name and process number as reads and writes to the specified device occur.

  • +
+

KERNEL

+
    +
  • functioncallcount.stp - Count Times Functions Called
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling functions
    +

    The functioncallcount.stp script takes one argument, a list of functions to probe. The script will run and count the number of times that each of the functions on the list is called. On exit the script will print a sorted list from most frequently to least frequently called function.

  • +
  • para-callgraph.stp - Tracing Calls for Sections of Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: kernel, keywords: trace callgraph
    +

    The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

  • +
  • pf2.stp - Profile kernel functions
    +output: sorted-list, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling
    +

    The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples.

  • +
  • thread-times.stp - Profile kernel functions
    +output: sorted-list, exits: user-controlled, status: production
    +subsystem: kernel, keywords: profiling
    +

    The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty processes with samples broken down into percentage total time spent in user-space and kernel-space.

  • +
+

LOCKING

+
    +
  • futexes.stp - System-Wide Futex Contention
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: locking, keywords: syscall locking futex
    +

    The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.

  • +
+

NETWORK

+
    +
  • nettop.stp - Periodic Listing of Processes Using Network Interfaces
    +output: timed, exits: user-controlled, status: production
    +subsystem: network, keywords: network traffic per-process
    +

    Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.

  • +
  • socket-trace.stp - Trace Functions called in Network Socket Code
    +output: trace, exits: user-controlled, status: production
    +subsystem: network, keywords: network socket
    +

    The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

  • +
+

NONE

+
    +
  • helloworld.stp - SystemTap "Hello World" Program
    +output: text, exits: fixed, status: production
    +subsystem: none, keywords: simple
    +

    A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.

  • +
+

SCHEDULER

+
    +
  • sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations
    +output: trace, exits: user-controlled, status: production
    +subsystem: scheduler, keywords: io scheduler
    +

    The script monitor time threads spend waiting for IO operations (in "D" state) in the wait_for_completion function. If a thread spends over 10ms wall-clock time waiting, information is printed out describing the thread number and executable name. When slow the wait_for_completion function complete, backtraces for the long duration calls are printed out.

  • +
+

SIGNALS

+
    +
  • sig_by_pid.stp - Signal Counts by Process ID
    +output: sorted-list on-exit, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    Print signal counts by process ID in descending order.

  • +
  • sig_by_proc.stp - Signal Counts by Process Name
    +output: sorted-list on-exit, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    Print signal counts by process name in descending order.

  • +
  • sigkill.stp - Track SIGKILL Signals
    +output: trace, exits: user-controlled, status: production
    +subsystem: signals, keywords: signals
    +

    The script traces any SIGKILL signals. When that SIGKILL signal is sent to a process, the script prints out the signal name, the desination executable and process ID, the executable name user ID that sent the signal.

  • +
  • syscalls_by_pid.stp - System-Wide Count of Syscalls by PID
    +output: trace, exits: user-controlled, status: experimental
    +subsystem: signals, keywords: signals
    +

    The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name.

  • +
+

SYSCALL

+
    +
  • iotime.stp - Trace Time Spent in Read and Write for Files
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall read write time io
    +

    The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.

  • +
  • sleeptime.stp - Trace Time Spent in nanosleep Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall sleep
    +

    The script watches each nanosleep syscall on the system. At the end of each nanosleep syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "nanosleep:" key, and the duration of the sleep in microseconds.

  • +
  • syscalls_by_pid.stp - System-Wide Count of Syscalls by PID
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall
    +

    The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each PID ordered from greatest to least number of syscalls.

  • +
  • syscalls_by_proc.stp - System-Wide Count of Syscalls by Executable
    +output: sorted-list on-exit, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall
    +

    The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each executable ordered from greates to least number of syscalls.

  • +
  • wait4time.stp - Trace Time Spent in wait4 Syscalls
    +output: trace, exits: user-controlled, status: production
    +subsystem: syscall, keywords: syscall wait4
    +

    The script watches each wait4 syscall on the system. At the end of each wait4 syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "wait4:" key, the duration of the wait and the PID that the wait4 was waiting for. If the waited for PID is not specified , it is "-1".

  • +
+
+
+
+ + + + + +
+ + diff --git a/examples/subsystem-index.txt b/examples/subsystem-index.txt new file mode 100644 index 00000000..d6780598 --- /dev/null +++ b/examples/subsystem-index.txt @@ -0,0 +1,267 @@ +SYSTEMTAP EXAMPLES INDEX BY SUBSYSTEM +(see also index.txt, keyword-index.txt) + += CPU = + +graphs.stp - Graphing Disk and CPU Utilization +output: plot data, exits: user-controlled, status: production +subsystem: disk cpu, keywords: disk cpu use graph + + The script tracks the disk and CPU utilization. The resulting output + of the script can be piped into gnuplot to generate a graph of disk + and CPU USE. + + += DISK = + +disktop.stp - Summarize Disk Read/Write Traffic +output: timed, exits: user-controlled, status: production +subsystem: disk, keywords: disk + + Get the status of reading/writing disk every 5 seconds, output top + ten entries during that period. + + +graphs.stp - Graphing Disk and CPU Utilization +output: plot data, exits: user-controlled, status: production +subsystem: disk cpu, keywords: disk cpu use graph + + The script tracks the disk and CPU utilization. The resulting output + of the script can be piped into gnuplot to generate a graph of disk + and CPU USE. + + += IO = + +io_submit.stp - Tally Reschedule Reason During AIO io_submit Call +output: sorted on-exit, exits: user-controlled, status: production +subsystem: io, keywords: io backtrace + + When a reschedule occurs during an AIO io_submit call, accumulate the + traceback in a histogram. When the script exits prints out a sorted + list from most common to least common backtrace. + + +iotop.stp - Periodically Print I/O Activity by Process Name +output: timed, exits: user-controlled, status: production +subsystem: io, keywords: io + + Every five seconds print out the top ten executables generating I/O + traffic during that interval sorted in descending order. + + +traceio.stp - Track Cumulative I/O Activity by Process Name +output: timed, exits: user-controlled, status: production +subsystem: io, keywords: io + + Every second print out the top ten executables sorted in descending + order based on cumulative I/O traffic observed. + + +traceio2.stp - Watch I/O Activity on a Particular Device +output: trace, exits: user-controlled, status: production +subsystem: io, keywords: io + + Print out the executable name and process number as reads and writes + to the specified device occur. + + += KERNEL = + +functioncallcount.stp - Count Times Functions Called +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling functions + + The functioncallcount.stp script takes one argument, a list of + functions to probe. The script will run and count the number of times + that each of the functions on the list is called. On exit the script + will print a sorted list from most frequently to least frequently + called function. + + +para-callgraph.stp - Tracing Calls for Sections of Code +output: trace, exits: user-controlled, status: production +subsystem: kernel, keywords: trace callgraph + + The script takes two arguments: the first argument is the function to + starts/stops the per thread call graph traces and the second argument + is the list of functions to generate trace information on. The script + prints out a timestap for the thread, the function name and pid, + followed by entry or exit symboly and function name. + + +pf2.stp - Profile kernel functions +output: sorted-list, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling + + The pf2.stp script sets up time-based sampling. Every five seconds it + prints out a sorted list with the top ten kernel functions with + samples. + + +thread-times.stp - Profile kernel functions +output: sorted-list, exits: user-controlled, status: production +subsystem: kernel, keywords: profiling + + The thread-times.stp script sets up time-based sampling. Every five + seconds it prints out a sorted list with the top twenty processes + with samples broken down into percentage total time spent in + user-space and kernel-space. + + += LOCKING = + +futexes.stp - System-Wide Futex Contention +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: locking, keywords: syscall locking futex + + The script watches the futex syscall on the system. On exit the + futexes address, the number of contentions, and the average time for + each contention on the futex are printed from lowest pid number to + highest. + + += NETWORK = + +nettop.stp - Periodic Listing of Processes Using Network Interfaces +output: timed, exits: user-controlled, status: production +subsystem: network, keywords: network traffic per-process + + Every five seconds the nettop.stp script prints out a list of + processed (PID and command) with the number of packets sent/received + and the amount of data sent/received by the process during that + interval. + + +socket-trace.stp - Trace Functions called in Network Socket Code +output: trace, exits: user-controlled, status: production +subsystem: network, keywords: network socket + + The script instrument each of the functions inn the Linux kernel's + net/socket.c file. The script prints out trace. The first element of + a line is time delta in microseconds from the previous entry. This + is followed by the command name and the PID. The "->" and "<-" + indicates function entry and function exit, respectively. The last + element of the line is the function name. + + += NONE = + +helloworld.stp - SystemTap "Hello World" Program +output: text, exits: fixed, status: production +subsystem: none, keywords: simple + + A basic "Hello World" program implemented in SystemTap script. It + prints out "hello world" message and then immediately exits. + + += SCHEDULER = + +sleepingBeauties.stp - Generating Backtraces of Threads Waiting for IO Operations +output: trace, exits: user-controlled, status: production +subsystem: scheduler, keywords: io scheduler + + The script monitor time threads spend waiting for IO operations (in + "D" state) in the wait_for_completion function. If a thread spends + over 10ms wall-clock time waiting, information is printed out + describing the thread number and executable name. When slow the + wait_for_completion function complete, backtraces for the long + duration calls are printed out. + + += SIGNALS = + +sig_by_pid.stp - Signal Counts by Process ID +output: sorted-list on-exit, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + Print signal counts by process ID in descending order. + + +sig_by_proc.stp - Signal Counts by Process Name +output: sorted-list on-exit, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + Print signal counts by process name in descending order. + + +sigkill.stp - Track SIGKILL Signals +output: trace, exits: user-controlled, status: production +subsystem: signals, keywords: signals + + The script traces any SIGKILL signals. When that SIGKILL signal is + sent to a process, the script prints out the signal name, the + desination executable and process ID, the executable name user ID + that sent the signal. + + +syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +output: trace, exits: user-controlled, status: experimental +subsystem: signals, keywords: signals + + The script watches for a particular signal sent to a specific + process. When that signal is sent to the specified process, the + script prints out the PID and executable of the process sending the + signal, the PID and executable name of the process receiving the + signal, and the signal number and name. + + += SYSCALL = + +iotime.stp - Trace Time Spent in Read and Write for Files +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall read write time io + + The script watches each open, close, read, and write syscalls on the + system. For each file the scripts observes opened it accumulates the + amount of wall clock time spend in read and write operations and the + number of bytes read and written. When a file is closed the script + prints out a pair of lines for the file. Both lines begin with a + timestamp in microseconds, the PID number, and the executable name in + parenthesese. The first line with the "access" keyword lists the file + name, the attempted number of bytes for the read and write + operations. The second line with the "iotime" keyword list the file + name and the number of microseconds accumulated in the read and write + syscalls. + + +sleeptime.stp - Trace Time Spent in nanosleep Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall sleep + + The script watches each nanosleep syscall on the system. At the end + of each nanosleep syscall the script prints out a line with a + timestamp in microseconds, the pid, the executable name in + paretheses, the "nanosleep:" key, and the duration of the sleep in + microseconds. + + +syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall + + The script watches all syscall on the system. On exit the script + prints a list showing the number of systemcalls executed by each PID + ordered from greatest to least number of syscalls. + + +syscalls_by_proc.stp - System-Wide Count of Syscalls by Executable +output: sorted-list on-exit, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall + + The script watches all syscall on the system. On exit the script + prints a list showing the number of systemcalls executed by each + executable ordered from greates to least number of syscalls. + + +wait4time.stp - Trace Time Spent in wait4 Syscalls +output: trace, exits: user-controlled, status: production +subsystem: syscall, keywords: syscall wait4 + + The script watches each wait4 syscall on the system. At the end of + each wait4 syscall the script prints out a line with a timestamp in + microseconds, the pid, the executable name in paretheses, the + "wait4:" key, the duration of the wait and the PID that the wait4 was + waiting for. If the waited for PID is not specified , it is "-1". + + diff --git a/examples/syscalls_by_pid.stp b/examples/syscalls_by_pid.stp new file mode 100644 index 00000000..47aa4955 --- /dev/null +++ b/examples/syscalls_by_pid.stp @@ -0,0 +1,28 @@ +#! /usr/bin/env stap + +# Copyright (C) 2006 IBM Corp. +# +# This file is part of systemtap, and is free software. You can +# redistribute it and/or modify it under the terms of the GNU General +# Public License (GPL); either version 2, or (at your option) any +# later version. + +# +# Print the system call count by process ID in descending order. +# + +global syscalls + +probe begin { + print ("Collecting data... Type Ctrl-C to exit and display results\n") +} + +probe syscall.* { + syscalls[pid()]++ +} + +probe end { + printf ("%-10s %-s\n", "#SysCalls", "PID") + foreach (pid in syscalls-) + printf("%-10d %-d\n", syscalls[pid], pid) +} diff --git a/examples/syscalls_by_proc.stp b/examples/syscalls_by_proc.stp new file mode 100644 index 00000000..af7d6932 --- /dev/null +++ b/examples/syscalls_by_proc.stp @@ -0,0 +1,28 @@ +#! /usr/bin/env stap + +# Copyright (C) 2006 IBM Corp. +# +# This file is part of systemtap, and is free software. You can +# redistribute it and/or modify it under the terms of the GNU General +# Public License (GPL); either version 2, or (at your option) any +# later version. + +# +# Print the system call count by process name in descending order. +# + +global syscalls + +probe begin { + print ("Collecting data... Type Ctrl-C to exit and display results\n") +} + +probe syscall.* { + syscalls[execname()]++ +} + +probe end { + printf ("%-10s %-s\n", "#SysCalls", "Process Name") + foreach (proc in syscalls-) + printf("%-10d %-s\n", syscalls[proc], proc) +} diff --git a/examples/systemtap.css b/examples/systemtap.css new file mode 100644 index 00000000..445d95f4 --- /dev/null +++ b/examples/systemtap.css @@ -0,0 +1,164 @@ +body { + background-color: #cccccc; +} + +.topnavright { + color: #787878; + text-align: right; + font-family: verdana, Geneva, Arial, Helvetica, sans-serif; + font-size: 14px; + margin-right: 10px; +} + +.topnavright a:link { + text-decoration: none; + color: #944E0F; +} + +.topnavright a:visited { + text-decoration: none; + color: #944E0F; +} + +div.mainbackground { + background-color: #ffffff; + padding: 17 17 17 17; +} + +div.maintextregion { + background-color: #5b5b5b; + color: #ffffff; +} + +div.maintextregion h1 { + color: #F38019; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size: 28px +} + +div.maintextregion h2 { + color: #F38019; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + margin-bottom: 2px; + font-size: 18px; + margin-top: 28px; +} + +div.maintextregion h4 { + color: #ffffff; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + font-weight: bold; +} + +div.maintextregion p { + color: #ffffff; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size: 14px; + line-height: 150%; + text-align: justify; +} + +div.maintextregion ul { + color: #ffffff; + list-style-type: square; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size: 14px; + line-height: 150%; + text-align: justify; +} + +div.maintextregion td ul ul { + color: #ffffff; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; +} + +div.maintextregion dt { + color: #ffffff; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + margin-top: 10px; +} + +div.maintextregion pre { + color: #ffffff; + font-size: 14px; +} + +div.maintextregion td pre { + color: #ffffff; + font-size: 14px; +} + +div.maintextregion dd { + color: #ffffff; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size: 14px; + line-height: 150%; + text-align: justify; + margin-left: 10px; +} + +div.maintextregion table { + margin-top: 20; +} + +div.maintextregion th { + color: #ffffff; + background-color: #494949; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + text-align: left; +} + +div.maintextregion tr.odd { + color: #ffffff; + background-color: #393939; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; +} + +div.maintextregion tr.even { + color: #ffffff; + background-color: #4d4d4d; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; +} + +div.maintextregion form { + color: #ffffff; + background-color: #4d4d4d; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + border: thin solid #424242; + padding: 6; +} + +div.maintextregion dd.left { + color: #ffffff; + margin-left: 0; +} + +a:link { + color: #ff9600; + text-decoration: none; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; +} + +a:visited { + color: #ff9600; + text-decoration: none; + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; +} + +.imgholder { + text-align: center; + padding: 8; +} +.footer a:link { + text-decoration: none; + color: #944E0F; + font-size: 12px; + font-weight: bold; +} +.footer a:visited { + text-decoration: none; + color: #944E0F; + font-size: 12px; + font-weight: bold; +} + diff --git a/examples/systemtapcorner.gif b/examples/systemtapcorner.gif new file mode 100644 index 0000000000000000000000000000000000000000..c44f2c75e9d9b57ccf184d9c3759bf967ce8b2ed GIT binary patch literal 970 zcmZ?wbhEHb)L_tH_|CvEXU?3xORN7+Vfa4^Mnhoag@EEu7Dfgj&;b#kJi)-RoPm`? z#$&^RgUuZ5Y#t{zC>~;9knt+vFnn~Rn@v0F$cezmZhgYGbu2dno_I{+XIv3eDU|9s zSu0kpMKUt2nx}tV*k#(`w+LVl5%BE*vcT* z%B`=Cu8UJ`;*Abk9XZ$he3t0yYdS}_X1^@s6P$TZt00004XF*Lt007q5 z)K6G40000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU&)=5M`RCwC# zTitQuNDv+qt-n2u5&tBoIhjLRm;~!aYxL7};y!{5%kBuLOFu0o<3f^L^?^ ztlXYKne*%Eo}J@*m*H3**!}M%=Mgu^(6OPhFE{6GAgE^yhc(pEQ5LXlUx%>HSqXq( z|6kyqhYH~G^$pkTKm@bleX_T8l}UJV01|D6lMUBJ;`ccw>ibkTVr_@umu*}L=329JTPV-;`JMr!Pk1B_UGSjR$K^2h*-J8DJ8A2gVVitR_vcA*Af+m1Z%VzGmxE^XHvPn%=t z-=Ydz(i~ZGh#cO6TSRMP$F*0+6lzmeC-x()2taKfdxG?=R~dW)C3C-;3r?*oVZiM3 zi9t6A*WB83@cDteMmE`z0RM!`0j44Cgmxze6>CAsEmU0^G5 zt!CGP?IsoKm;Ep z?7Ng4JpxRv24GzZ4|!`pbRGAolK=o%5_4sa^BDz0wvM$j*)vA%MS%L|XeXzBJebS0 z-kI7`UjL&dE!iV^B;EbAiS`JXpXRLV&{v5P%veAa>7xZ3P)yp0Yej1-M_v54kxS%X zcv?t;GMFtDmTZ$L`DR$Lwdj*PXwo7Llv@TS1j3UGm_8$S%NcNu^`ORNZY_7Q9Dyxm z9sMsv*)r9o1s6#LU}$onEtZt-HEF2LPh@n(!2}aJp_Gt~ir(P2JD0om022d}jOws% zJa%YLOZE?m7xgYaL{+RIp^qvIT{axL`>eLB}>gZ1~{?*NrK-R%|N; z;3PDr7}>H+uCoA;5yRR^CZj9C1cy7e!!1))0mFpVGcu<+$t-|v2O^z-l44gjXgDKK z*#(rx0#^H*++Zl%Btizgw854Hkg0IpydQ?82205psQW=FNK$WXOebl zXzN5NW7ghror#&<(Kk!GEX7WJE2Hno-Ewfx%eWxCmQp?wg}uiOF4CShPf^(@_wq=2 zPvZ??%S2(PylGG>EV&R7a%lg{+JOjX0BxK|psNC=n#1D1n2$$-77#Zj!1ZiSpEQ&< zWDU}&PpmEspbko&vldX+p-D;QB95WUbGP_rSA!fyljYp zky5;X?gj!P7r=~vN1BG|%$!Z)?1Iukks}>sgtna8YdtI}Qzf;}H$ADTA`6;$QKK9v z88G>7AN`JnCt%*OpKdRRCHq>6gY|o>Y^KDe=L9I500D0sgAK2l)BN$QaZuupg|aTV zK5Kz(diZ{(&n=TH&znw_R4~puzm)SFbW`!Rl*W=L;I1?4AXqXB%s-x!9x4Y)dP#Rj zB778>?q~v#W6EERjCgMD0l?uxL76!=6K9)s0ZU47*E#=5K-)${;(Io(Mqbq5Ot}}q zgNuEpid(5W74xq=aHW0VcOEfj7X-?09!;qMfJePsPXue~^a=o`Q3aON`kyp0iC3&4 z+fkeLnOk>4ZX*eBHRtNZ4BARrbcY)RQy~j_4BDfO!S&3l3C0V2iY4cv=ZKt7*iww~ zI0jFOjsJdK)A*)U=MMo4pw0*jN4A9D(%L~u3w~!#U!GliG-i|UFwV`#OT>l%h<~xr zu3eUWE?>e8hp<3qPMTWYRmtG$ zd~VtIf^XevpQ6cHg#1CRWs9`PyFgp60v<#h6wTV2mQ>hs%Wx9c{aV|VlJ>bFEq5z4 z4?fvRE4- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# + +global reads, writes, total_io + +probe kernel.function("vfs_read").return { + reads[execname()] += $return +} + +probe kernel.function("vfs_write").return { + writes[execname()] += $return +} + +probe timer.s(1) { + foreach (p in reads) + total_io[p] += reads[p] + foreach (p in writes) + total_io[p] += writes[p] + foreach(p in total_io- limit 10) + printf("%15s r: %8d KiB w: %8d KiB\n", + p, reads[p]/1024, + writes[p]/1024) + printf("\n") + # Note we don't zero out reads, writes and total_io, + # so the values are cumulative since the script started. +} diff --git a/examples/traceio2.stp b/examples/traceio2.stp new file mode 100644 index 00000000..656c38b3 --- /dev/null +++ b/examples/traceio2.stp @@ -0,0 +1,20 @@ +global device_of_interest + +probe begin { + /* The following is not the most efficient way to do this. + One could directly put the result of usrdev2kerndev() + into device_of_interest. However, want to test out + the other device functions */ + dev = usrdev2kerndev($1) + device_of_interest = MKDEV(MAJOR(dev), MINOR(dev)) +} + +probe kernel.function ("vfs_write"), + kernel.function ("vfs_read") +{ + dev_nr = $file->f_path->dentry->d_inode->i_sb->s_dev + + if (dev_nr == device_of_interest) + printf ("%s(%d) %s 0x%x\n", + execname(), pid(), probefunc(), dev_nr) +} diff --git a/examples/wait4time.stp b/examples/wait4time.stp new file mode 100644 index 00000000..ba300ea7 --- /dev/null +++ b/examples/wait4time.stp @@ -0,0 +1,59 @@ +#! /usr/bin/env stap + +/* + * Copyright (C) 2006-2007 Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Print out the amount of time spent in the read and write systemcall + * when a process closes each file is closed. Note that the script needs + * to be running before the open operations occur for the script + * to record data. + * + * Format is: + * timestamp pid (executabable) wait4: time_us pid + * + * 155789807 4196 (ssh) wait4: 12 4197 + * 158270531 3215 (bash) wait4: 5410460 -1 + * 158270659 3215 (bash) wait4: 9 -1 + * 158557461 2614 (sendmail) wait4: 27 -1 + * 158557487 2614 (sendmail) wait4: 5 -1 + * + */ + +global start +global entry_wait4 +global wait4_pid + +function timestamp:long() { + return gettimeofday_us() - start +} + +function proc:string() { + return sprintf("%d (%s)", pid(), execname()) +} + +probe begin { + start = gettimeofday_us() +} + +probe syscall.wait4 { + t = gettimeofday_us(); p = pid() + entry_wait4[p] = t + wait4_pid[p]=pid +} + +probe syscall.wait4.return { + t = gettimeofday_us(); p = pid() + elapsed_time = t - entry_wait4[p] + printf("%d %s wait4: %d %d\n", timestamp(), proc(), elapsed_time, + wait4_pid[p]) + delete entry_wait4[p] + delete wait4_pid[p] +} -- 2.43.5