* What's new in version 4.2, PRERELEASE
+- The stapbpf backend now supports stap-exporter extensions.
+
- The stapbpf backend now supports procfs probes. The implementation
uses FIFO special files in /var/tmp/systemtap-$EFFUSER/MODNAME instead
of the proc filesystem files.
FN(set_procfs_value), \
FN(append_procfs_value), \
FN(get_procfs_value), \
- FN(str_concat),
+ FN(str_concat), \
+ FN(text_str), \
+ FN(string_quoted),
const bpf_func_id BPF_FUNC_map_get_next_key = (bpf_func_id) -1;
const bpf_func_id BPF_FUNC_sprintf = (bpf_func_id) -2;
const bpf_func_id BPF_FUNC_append_procfs_value = (bpf_func_id) -7;
const bpf_func_id BPF_FUNC_get_procfs_value = (bpf_func_id) -8;
const bpf_func_id BPF_FUNC_str_concat = (bpf_func_id) -9;
+const bpf_func_id BPF_FUNC_text_str = (bpf_func_id) -10;
+const bpf_func_id BPF_FUNC_string_quoted = (bpf_func_id) -11;
struct insn
{
--- /dev/null
+#! /bin/sh
+
+# link to this generic shell script to invoke a non-guru stap example
+exec stap --bpf -v --example $@ `basename $0 | sed -e s,autostart-,,`
--- /dev/null
+EXAMPLE-BPF
\ No newline at end of file
script_dir = "%sysconfdir%/stap-exporter"
proc_basename = "__stap_exporter_" + str(os.getpid()) # permit concurrent exporters
-proc_path = "/proc/systemtap"
sessmgr = None
-
+proc_path_lkm = "/proc/systemtap"
+proc_path_bpf = "/var/tmp/systemtap-root"
class Session:
"""Represent a single systemtap script found $script_dir, whether or not
if self.keepalive is not None:
self.killafter = time() + self.keepalive
- path = proc_path + "/" + self.proc_subdirname + "/__prometheus"
- with open(path) as metrics:
- return bytes(metrics.read(), 'utf-8')
+ path_lkm = proc_path_lkm + "/" + self.proc_subdirname + "/__prometheus"
+ path_bpf = proc_path_bpf + "/" + self.proc_subdirname + "/__prometheus"
+
+ try:
+ with open(path_lkm) as metrics:
+ return bytes(metrics.read(), 'utf-8')
+ except FileNotFoundError:
+ pass
+
+ try:
+ with open(path_bpf) as metrics:
+ return bytes(metrics.read(), 'utf-8')
+ except FileNotFoundError:
+ raise Exception("[Error] Unable to find procfs files under search paths. "
+ "Try again once the script has created the procfs files.")
class SessionMgr:
"""Represent the set of possible systemtap scripts that can be exported. Searches the $script_dir
httpd.timeout = 5 # parametrize?
print("listening on port %d" % port)
+ print("procfs files will be searched under: %s and %s" % (proc_path_lkm, proc_path_bpf))
+
try:
while True:
sessmgr.poll()
return reinterpret_cast<uint64_t>(strings.back().c_str());
}
+uint64_t
+bpf_text_str(std::vector<std::string> &strings, char* input, bool quoted)
+{
+ std::string str(input);
+ std::stringstream stream;
+
+ for (std::string::iterator it = str.begin(); it != str.end(); ++it)
+ {
+ unsigned char c = *it;
+ unsigned int i = c;
+
+ if (std::isprint(c) && i < 128 && c != '\\' && c != '"')
+ stream << c;
+ else
+ {
+ stream << '\\';
+ switch (c) {
+ case '\0': stream << '0'; break; // Not handled by translate_escapes
+ case '\a': stream << 'a'; break; // Not handled by translate_escapes
+ case '\b': stream << 'b'; break; // Not handled by translate_escapes
+ case '\f': stream << 'f'; break;
+ case '\n': stream << 'n'; break;
+ case '\r': stream << 'r'; break;
+ case '\t': stream << 't'; break;
+ case '\v': stream << 'v'; break;
+ case '"': stream << '"'; break;
+ case '\\': stream << '\\'; break;
+ default:
+ stream << "x" << std::setfill('0') << std::setw(2) << std::hex << i;
+ break;
+ }
+ }
+ }
+
+ if (quoted)
+ strings.push_back("\"" + stream.str() + "\"");
+ else
+ strings.push_back(stream.str());
+
+ return reinterpret_cast<uint64_t>(strings.back().c_str());
+}
+
uint64_t
bpf_str_concat(std::vector<std::string> &strings, char* left, char* right)
{
dr = bpf_sprintf(strings, as_str(regs[1]),
regs[3], regs[4], regs[5]);
break;
+ case bpf::BPF_FUNC_text_str:
+ dr = bpf_text_str(strings, as_str(regs[1]), false);
+ break;
+ case bpf::BPF_FUNC_string_quoted:
+ dr = bpf_text_str(strings, as_str(regs[1]), true);
+ break;
case bpf::BPF_FUNC_str_concat:
dr = bpf_str_concat(strings, as_str(regs[1]),
as_str(regs[2]));
case bpf::BPF_FUNC_gettimeofday_ns:
dr = bpf_gettimeofday_ns();
break;
- case bpf::BPF_FUNC_get_target:
+ case bpf::BPF_FUNC_get_target:
dr = bpf_get_target();
break;
case bpf::BPF_FUNC_set_procfs_value:
// Run the probe and collect the message.
bpf_interpret(prog->d_size / sizeof(bpf_insn), static_cast<bpf_insn *>(prog->d_buf), uctx);
- // Make a copy of the message.
+ // Make a copy of the message and reset it.
std::string msg = uctx->procfs_msg;
+ uctx->procfs_msg.clear();
procfs_lock.unlock();
-probe prometheus = procfs("__prometheus").read.maxsize(0x10000) { }
+probe prometheus =
+%( runtime != "bpf" %?
+ procfs("__prometheus").read.maxsize(0x10000)
+%:
+ procfs("__prometheus").read
+%)
+{ }
* printable are replaced by the corresponding escape sequence in the
* returned string.
*/
-function text_str:string(input:string)
-%{ /* pure */ /* unprivileged */ /* unmodified-fnargs */
- if (_stp_text_str(STAP_RETVALUE, STAP_ARG_input, 0, 0, 0, 0, 0) < 0) {
- STAP_RETVALUE[0] = '\0';
- }
-%}
+function text_str:string(input:string)
+%( runtime != "bpf" %?
+ %{ /* pure */ /* unprivileged */ /* unmodified-fnargs */
+ if (_stp_text_str(STAP_RETVALUE, STAP_ARG_input, 0, 0, 0, 0, 0) < 0) {
+ STAP_RETVALUE[0] = '\0';
+ }
+ %}
+%:
+ %{ /* bpf */
+ 0xbf, 1, $input, -, -; /* mov r1, $input */
+ 0x85, 0, 0, 0, -10; /* call BPF_FUNC_TEXT_STR */
+ 0xbf, $$, 0, -, -; /* return r0 */
+ %}
+%)
/**
* sfunction text_strn - Escape any non-printable chars in a string
* string. Note that the string will be surrounded by double quotes.
*/
function string_quoted:string (str:string)
-%{ /* pure */ /* unmodified-fnargs */
- /* This can't fail, since the input string is already in stap context space. */
- (void) _stp_text_str(STAP_RETVALUE,
- (char *)(uintptr_t)STAP_ARG_str,
- MAXSTRINGLEN, MAXSTRINGLEN, 1, 0, 0);
-%}
+%( runtime != "bpf" %?
+ %{ /* pure */ /* unmodified-fnargs */
+ /* This can't fail, since the input string is already in stap context space. */
+ (void) _stp_text_str(STAP_RETVALUE,
+ (char *)(uintptr_t)STAP_ARG_str,
+ MAXSTRINGLEN, MAXSTRINGLEN, 1, 0, 0);
+ %}
+%:
+ %{ /* bpf */
+ 0xbf, 1, $str, -, -; /* mov r1, $input */
+ 0x85, 0, 0, 0, -11; /* call BPF_FUNC_STRING_QUOTED */
+ 0xbf, $$, 0, -, -; /* return r0 */
+ %}
+%)
<li><a href="keyword-index.html">By Keyword</a></li>
</ul>
-<p><em>For systemtap version 4.1.</em></p><h2>Best Examples</h2>
+<p><em>For systemtap version 4.2.</em></p><h2>Best Examples</h2>
<ul>
<li><a href="#general/helloworld.stp">general/helloworld.stp - SystemTap "Hello World" Program</a></li>
<li><a href="#general/para-callgraph.stp">general/para-callgraph.stp - Callgraph Tracing with Arguments</a></li>
keywords: <a href="keyword-index.html#TRACE">TRACE</a> <br>
<p>The gmalloc_watch.stp script from Colin Walters' blog (https://blog.verbum.org/2011/03/19/analyzing-memory-use-with-systemtap/) traces the allocation of glib2 memory using the markers in glib2.</p><p><font size="-2"><pre># stap gmalloc_watch.stp -T 1</pre></font></p>
</li><li><a name="apps/libguestfs_log.stp"></a><a href="#apps/libguestfs_log.stp">¶</a> <a href="apps/libguestfs_log.stp">apps/libguestfs_log.stp</a> - Trace libguestfs startup<br>
-keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <br>
+keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The libguestfs_log.stp script prints a log of when various libgueststartup steps are encountered. The first column is microseconds since the script started. The second column is the time elapsed in microseconds between the previous and current events and the third column is the event name.</p><p><font size="-2"><pre># stap libguestfs_log.stp -T 1</pre></font></p>
</li><li><a name="apps/php-trace.stp"></a><a href="#apps/php-trace.stp">¶</a> <a href="apps/php-trace.stp">apps/php-trace.stp</a> - Tracing of PHP code execution<br>
-keywords: <a href="keyword-index.html#TRACE">TRACE</a> <br>
+keywords: <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#DYNINST">DYNINST</a> <br>
<p>Trace of executing PHP code using the enabled markers.</p><p><font size="-2"><pre># stap php-trace.stp -c 'php -f hello.php'</pre></font></p>
</li><li><a name="apps/stap_time.stp"></a><a href="#apps/stap_time.stp">¶</a> <a href="apps/stap_time.stp">apps/stap_time.stp</a> - Provide elapsed times for Passes of SystemTap script compilation<br>
keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <br>
keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <br>
<p>The also_ran.stp script tallies each time a executable is started or a shared library is loaded for execution. This information can be useful to determine what software is actually being used on the system. The script makes the information available via procfs in Prometheus readable format.</p><p><font size="-2"><pre># stap also_ran.stp -T 1</pre></font></p>
</li><li><a name="general/ansi_colors.stp"></a><a href="#general/ansi_colors.stp">¶</a> <a href="general/ansi_colors.stp">general/ansi_colors.stp</a> - Color Table for ansi_set_color()<br>
-keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br>
+keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The script prints a table showing the available color combinations for the ansi_set_color() function in the ansi.stp tapset.</p><p><font size="-2"><pre># stap ansi_colors.stp</pre></font></p>
</li><li><a name="general/ansi_colors2.stp"></a><a href="#general/ansi_colors2.stp">¶</a> <a href="general/ansi_colors2.stp">general/ansi_colors2.stp</a> - Show Attribues in Table for ansi_set_color()<br>
-keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br>
+keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The script prints a table showing the available attributes (bold, underline, and inverse) with color combinations for the ans_set_color() function in the ansi.stp tapset.</p><p><font size="-2"><pre># stap ansi_colors2.stp</pre></font></p>
</li><li><a name="general/badname.stp"></a><a href="#general/badname.stp">¶</a> <a href="general/badname.stp">general/badname.stp</a> - Bad Filename Filter<br>
keywords: <a href="keyword-index.html#FILESYSTEM">FILESYSTEM</a> <a href="keyword-index.html#GURU">GURU</a> <br>
keywords: <a href="keyword-index.html#MONITORING">MONITORING</a> <br>
<p>The script tracks the disk and CPU utilization. It prints a stream of data which, when piped directly into gnuplot, draws historical curves for each.</p><p><font size="-2"><pre># stap graphs.stp -T 1</pre></font></p>
</li><li><a name="general/helloworld.stp"></a><a href="#general/helloworld.stp">¶</a> <a href="general/helloworld.stp">general/helloworld.stp</a> - SystemTap "Hello World" Program<br>
-keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#SIMPLE">SIMPLE</a> <br>
+keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#SIMPLE">SIMPLE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.</p><p><font size="-2"><pre># stap helloworld.stp</pre></font></p>
</li><li><a name="general/key.stp"></a><a href="#general/key.stp">¶</a> <a href="general/key.stp">general/key.stp</a> - make keyboard noises<br>
keywords: <a href="keyword-index.html#SIMPLE">SIMPLE</a> <br>
keywords: <a href="keyword-index.html#IO">IO</a> <br>
<p>This traces syscalls system-wide, and produces a summary report showing their counts by process ID, process name, and syscall types.</p><p><font size="-2"><pre># stap syscallbypid-nd.stp -T 1</pre></font></p>
</li><li><a name="memory/cachestat.stp"></a><a href="#memory/cachestat.stp">¶</a> <a href="memory/cachestat.stp">memory/cachestat.stp</a> - Count Page Cache Hits and Misses<br>
-keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
-<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap cachestat.stp -T 1</pre></font></p>
-</li><li><a name="memory/cachestat.stp"></a><a href="#memory/cachestat.stp">¶</a> <a href="memory/cachestat.stp">memory/cachestat.stp</a> - Count Page Cache Hits and Misses<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
-<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap --bpf cachestat.stp -T 1</pre></font></p>
+<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap cachestat.stp -T 1</pre></font></p>
</li><li><a name="memory/glibc-malloc.stp"></a><a href="#memory/glibc-malloc.stp">¶</a> <a href="memory/glibc-malloc.stp">memory/glibc-malloc.stp</a> - Overview glibc malloc internal operations<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <br>
<p>This script reports on internal statistics of the glibc malloc implementation, as used by a process restricted by stap -x/-c</p><p><font size="-2"><pre># stap glibc-malloc.stp -c 'stap --dump-functions'</pre></font></p>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
<p>The mmanonpage.stp script uses the virtual memory tracepoints available in some kernels to track the number of faults, user space frees, page ins, copy on writes and unmaps for anonymous pages. When the script is terminated the counts are printed for each process that allocated pages while the script was running. This script displays the anonymous page statistics for each process that ran while the script is active. It's useful in debugging leaks in the anonymous regions of a process.</p><p><font size="-2"><pre># stap mmanonpage.stp -T 1</pre></font></p>
</li><li><a name="memory/mmfilepage.stp"></a><a href="#memory/mmfilepage.stp">¶</a> <a href="memory/mmfilepage.stp">memory/mmfilepage.stp</a> - Track Virtual Memory System Actions on File Backed Pages<br>
-keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The mmfilepage.stp script uses the virtual memory tracepoints available in some kernels to track the number of faults, copy on writes mapping, and unmapping operations for file backed pages. When the script is terminated the counts are printed for each process that allocated pages while the script was running. The mmfilepage.stp script is useful in debugging leaks in the mapped file regions of a process.</p><p><font size="-2"><pre># stap mmfilepage.stp -T 1</pre></font></p>
</li><li><a name="memory/mmreclaim.stp"></a><a href="#memory/mmreclaim.stp">¶</a> <a href="memory/mmreclaim.stp">memory/mmreclaim.stp</a> - Track Virtual Memory System Page Reclamation<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
<p>The mmreclaim.stp script uses the virtual memory tracepoints available in some kernels to track page reclaim activity that occurred while the script was running. It's useful in debugging performance problems that occur due to page reclamation.</p><p><font size="-2"><pre># stap mmreclaim.stp -T 1</pre></font></p>
</li><li><a name="memory/mmwriteback.stp"></a><a href="#memory/mmwriteback.stp">¶</a> <a href="memory/mmwriteback.stp">memory/mmwriteback.stp</a> - Track Virtual Memory System Writing to Disk<br>
-keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The mmwriteback.stp script uses the virtual memory tracepoints available in some kernels to report all of the file writebacks that occur form kupdate, pdflush and kjournald while the script is running. It's useful in determining where writes are coming from on a supposedly idle system that is experiencing unexpected IO.</p><p><font size="-2"><pre># stap mmwriteback.stp -T 1</pre></font></p>
</li><li><a name="memory/numa_faults.stp"></a><a href="#memory/numa_faults.stp">¶</a> <a href="memory/numa_faults.stp">memory/numa_faults.stp</a> - Summarize Process Misses across NUMA Nodes<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#NUMA">NUMA</a> <br>
keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <br>
<p>The packet_contents.stp script displays the length of each network packet and its contents in both hexadecimal and ASCII. Systemtap strings are MAXSTRINGLEN in length by default which may not be enough for larger packets. In order to print larger packets, this limit can be increased by passing in the "-DMAXSTRINGLEN=65536" command line option.</p><p><i><a href="network/packet_contents.txt">sample usage in network/packet_contents.txt</i></font></p>
</li><li><a name="network/sk_stream_wait_memory.stp"></a><a href="#network/sk_stream_wait_memory.stp">¶</a> <a href="network/sk_stream_wait_memory.stp">network/sk_stream_wait_memory.stp</a> - Track Start and Stop of Processes Due to Network Buffer Space<br>
-keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <br>
+keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The sk_stream-wait_memory.stp prints a time stamp, executable, and pid each time a process blocks due to the send buffer being full. A similar entry is printed each time a process continues because there is room in the buffer.</p><p><font size="-2"><pre># stap sk_stream_wait_memory.stp -T 1</pre></font></p>
</li><li><a name="network/socket-trace.stp"></a><a href="#network/socket-trace.stp">¶</a> <a href="network/socket-trace.stp">network/socket-trace.stp</a> - Trace Functions Called in Network Socket Code<br>
keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <br>
</li><li><a name="profiling/syscallsbypid.stp"></a><a href="#profiling/syscallsbypid.stp">¶</a> <a href="profiling/syscallsbypid.stp">profiling/syscallsbypid.stp</a> - Provide a per-process syscall tally on the system<br>
keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <br>
<p>The syscallsbypid.stp script tallies each syscall for each running process. This information can be useful to determine the activity of various processes on the system. The script makes the information available via procfs in Prometheus readable format. When a process exits its data will be eliminated from the prometheus output. To avoid exceeding the storage limitations of SystemTap older entries maybe overwritten by newer entries. This can lead to some active process syscall counts disappearing and/or later reappearing with a lower value. Also note that the script does not properly name syscalls for 32-bit applications running on 64-bit machines.</p><p><font size="-2"><pre># stap syscallsbypid.stp -T 1</pre></font></p>
+</li><li><a name="profiling/syscallsrw.stp"></a><a href="#profiling/syscallsrw.stp">¶</a> <a href="profiling/syscallsrw.stp">profiling/syscallsrw.stp</a> - Provide a tally of read and write syscalls run on the system <br>
+keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The syscall_read_write.stp script tallies the read and write syscalls. This is a demo script for stapbpf prometheus-exporter scripts.</p></p>
</li><li><a name="profiling/thread-times.stp"></a><a href="#profiling/thread-times.stp">¶</a> <a href="profiling/thread-times.stp">profiling/thread-times.stp</a> - Profile Kernel Functions<br>
keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br>
<p>The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty threads occupying the CPUs, broken down as a percentage of user and kernel time.</p><p><i><a href="profiling/thread-times.txt">sample usage in profiling/thread-times.txt</i></font></p>
(see also keyword-index.txt)
-For systemtap version 4.1.
+For systemtap version 4.2.
apps/gmalloc_watch.stp - Tracing glib2 memory allocations
keywords: trace
apps/libguestfs_log.stp - Trace libguestfs startup
-keywords: application trace
+keywords: application trace bpf
The libguestfs_log.stp script prints a log of when various
libgueststartup steps are encountered. The first column is
apps/php-trace.stp - Tracing of PHP code execution
-keywords: trace
+keywords: trace dyninst
Trace of executing PHP code using the enabled markers.
general/ansi_colors.stp - Color Table for ansi_set_color()
-keywords: format
+keywords: format bpf
The script prints a table showing the available color combinations
for the ansi_set_color() function in the ansi.stp tapset.
general/ansi_colors2.stp - Show Attribues in Table for ansi_set_color()
-keywords: format
+keywords: format bpf
The script prints a table showing the available attributes (bold,
underline, and inverse) with color combinations for the
general/helloworld.stp - SystemTap "Hello World" Program
-keywords: _best simple
+keywords: _best simple bpf
A basic "Hello World" program implemented in SystemTap script. It
prints out "hello world" message and then immediately exits.
# stap syscallbypid-nd.stp -T 1
-memory/cachestat.stp - Count Page Cache Hits and Misses
-keywords: memory
-
- Monitors hits and misses to the page cache and reports a count every
- 5 seconds. Based on a bpftrace tool by David Valin.
-
- # stap cachestat.stp -T 1
-
-
memory/cachestat.stp - Count Page Cache Hits and Misses
keywords: memory bpf
Monitors hits and misses to the page cache and reports a count every
5 seconds. Based on a bpftrace tool by David Valin.
- # stap --bpf cachestat.stp -T 1
+ # stap cachestat.stp -T 1
memory/glibc-malloc.stp - Overview glibc malloc internal operations
memory/mmfilepage.stp - Track Virtual Memory System Actions on File Backed Pages
-keywords: memory
+keywords: memory bpf
The mmfilepage.stp script uses the virtual memory tracepoints
available in some kernels to track the number of faults, copy on
memory/mmwriteback.stp - Track Virtual Memory System Writing to Disk
-keywords: memory
+keywords: memory bpf
The mmwriteback.stp script uses the virtual memory tracepoints
available in some kernels to report all of the file writebacks that
network/sk_stream_wait_memory.stp - Track Start and Stop of Processes Due to Network Buffer Space
-keywords: network tcp process
+keywords: network tcp process bpf
The sk_stream-wait_memory.stp prints a time stamp, executable, and
pid each time a process blocks due to the send buffer being full. A
# stap syscallsbypid.stp -T 1
+profiling/syscallsrw.stp - Provide a tally of read and write syscalls run on the system
+keywords: prometheus syscall bpf
+
+ The syscall_read_write.stp script tallies the read and write
+ syscalls. This is a demo script for stapbpf prometheus-exporter
+ scripts.
+
+
profiling/thread-times.stp - Profile Kernel Functions
keywords: _best profiling
<li><a href="keyword-index.html">By Keyword</a></li>
</ul>
-<p><em>For systemtap version 4.1.</em></p><h2>Examples by Keyword</h2>
-<p><tt><a href="#_BEST">_BEST(17)</a> <a href="#APPLICATION">APPLICATION(2)</a> <a href="#BACKTRACE">BACKTRACE(8)</a> <a href="#BPF">BPF(1)</a> <a href="#CALLGRAPH">CALLGRAPH(4)</a> <a href="#CONTAINER">CONTAINER(1)</a> <a href="#DIAGRAM">DIAGRAM(1)</a> <a href="#DISK">DISK(5)</a> <a href="#FILE">FILE(2)</a> <a href="#FILESYSTEM">FILESYSTEM(4)</a> <a href="#FORMAT">FORMAT(2)</a> <a href="#FUNCTION">FUNCTION(4)</a> <a href="#FUTEX">FUTEX(2)</a> <a href="#GURU">GURU(19)</a> <a href="#INTERACTIVE">INTERACTIVE(2)</a> <a href="#INTERRUPT">INTERRUPT(3)</a> <a href="#IO">IO(30)</a> <a href="#JSON">JSON(2)</a> <a href="#KVM">KVM(3)</a> <a href="#LIMITS">LIMITS(3)</a> <a href="#LOCKING">LOCKING(6)</a> <a href="#MEMORY">MEMORY(21)</a> <a href="#MONITORING">MONITORING(9)</a> <a href="#NANOSLEEP">NANOSLEEP(1)</a> <a href="#NETWORK">NETWORK(21)</a> <a href="#NFS">NFS(5)</a> <a href="#NUMA">NUMA(1)</a> <a href="#PACKETS">PACKETS(1)</a> <a href="#PROCESS">PROCESS(27)</a> <a href="#PROFILING">PROFILING(24)</a> <a href="#PROMETHEUS">PROMETHEUS(5)</a> <a href="#QEMU">QEMU(2)</a> <a href="#REGEX">REGEX(1)</a> <a href="#RETRANSMISSION">RETRANSMISSION(1)</a> <a href="#SCHEDULER">SCHEDULER(9)</a> <a href="#SCSI">SCSI(1)</a> <a href="#SECURITY">SECURITY(13)</a> <a href="#SIGNALS">SIGNALS(5)</a> <a href="#SIMPLE">SIMPLE(10)</a> <a href="#SOCKET">SOCKET(8)</a> <a href="#SPECULATION">SPECULATION(1)</a> <a href="#STAPGAMES">STAPGAMES(5)</a> <a href="#STATISTICS">STATISTICS(10)</a> <a href="#SYSCALL">SYSCALL(18)</a> <a href="#TCP">TCP(4)</a> <a href="#THREAD">THREAD(2)</a> <a href="#TIME">TIME(4)</a> <a href="#TRACE">TRACE(11)</a> <a href="#TRACEPOINT">TRACEPOINT(8)</a> <a href="#TRAFFIC">TRAFFIC(8)</a> <a href="#TTY">TTY(1)</a> <a href="#VIRTUALIZATION">VIRTUALIZATION(3)</a> <a href="#WATCHDOG">WATCHDOG(1)</a> <a href="#WATCHPOINT">WATCHPOINT(2)</a> </tt></p>
+<p><em>For systemtap version 4.2.</em></p><h2>Examples by Keyword</h2>
+<p><tt><a href="#_BEST">_BEST(17)</a> <a href="#APPLICATION">APPLICATION(2)</a> <a href="#BACKTRACE">BACKTRACE(8)</a> <a href="#BPF">BPF(9)</a> <a href="#CALLGRAPH">CALLGRAPH(4)</a> <a href="#CONTAINER">CONTAINER(1)</a> <a href="#DIAGRAM">DIAGRAM(1)</a> <a href="#DISK">DISK(5)</a> <a href="#DYNINST">DYNINST(1)</a> <a href="#FILE">FILE(2)</a> <a href="#FILESYSTEM">FILESYSTEM(4)</a> <a href="#FORMAT">FORMAT(2)</a> <a href="#FUNCTION">FUNCTION(4)</a> <a href="#FUTEX">FUTEX(2)</a> <a href="#GURU">GURU(19)</a> <a href="#INTERACTIVE">INTERACTIVE(2)</a> <a href="#INTERRUPT">INTERRUPT(3)</a> <a href="#IO">IO(30)</a> <a href="#JSON">JSON(2)</a> <a href="#KVM">KVM(3)</a> <a href="#LIMITS">LIMITS(3)</a> <a href="#LOCKING">LOCKING(6)</a> <a href="#MEMORY">MEMORY(20)</a> <a href="#MONITORING">MONITORING(9)</a> <a href="#NANOSLEEP">NANOSLEEP(1)</a> <a href="#NETWORK">NETWORK(21)</a> <a href="#NFS">NFS(5)</a> <a href="#NUMA">NUMA(1)</a> <a href="#PACKETS">PACKETS(1)</a> <a href="#PROCESS">PROCESS(27)</a> <a href="#PROFILING">PROFILING(24)</a> <a href="#PROMETHEUS">PROMETHEUS(6)</a> <a href="#QEMU">QEMU(2)</a> <a href="#REGEX">REGEX(1)</a> <a href="#RETRANSMISSION">RETRANSMISSION(1)</a> <a href="#SCHEDULER">SCHEDULER(9)</a> <a href="#SCSI">SCSI(1)</a> <a href="#SECURITY">SECURITY(13)</a> <a href="#SIGNALS">SIGNALS(5)</a> <a href="#SIMPLE">SIMPLE(10)</a> <a href="#SOCKET">SOCKET(8)</a> <a href="#SPECULATION">SPECULATION(1)</a> <a href="#STAPGAMES">STAPGAMES(5)</a> <a href="#STATISTICS">STATISTICS(10)</a> <a href="#SYSCALL">SYSCALL(19)</a> <a href="#TCP">TCP(4)</a> <a href="#THREAD">THREAD(2)</a> <a href="#TIME">TIME(4)</a> <a href="#TRACE">TRACE(11)</a> <a href="#TRACEPOINT">TRACEPOINT(8)</a> <a href="#TRAFFIC">TRAFFIC(8)</a> <a href="#TTY">TTY(1)</a> <a href="#VIRTUALIZATION">VIRTUALIZATION(3)</a> <a href="#WATCHDOG">WATCHDOG(1)</a> <a href="#WATCHPOINT">WATCHPOINT(2)</a> </tt></p>
<h3><a name="_BEST"><a href="#_BEST">¶</a> _BEST</a></h3>
<ul>
<li><a href="general/helloworld.stp">general/helloworld.stp</a> - SystemTap "Hello World" Program<br>
-keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#SIMPLE">SIMPLE</a> <br>
+keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#SIMPLE">SIMPLE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.</p><p><font size="-2"><pre># stap helloworld.stp</pre></font></p>
</li><li><a href="general/para-callgraph.stp">general/para-callgraph.stp</a> - Callgraph Tracing with Arguments<br>
keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#CALLGRAPH">CALLGRAPH</a> <br>
<h3><a name="APPLICATION"><a href="#APPLICATION">¶</a> APPLICATION</a></h3>
<ul>
<li><a href="apps/libguestfs_log.stp">apps/libguestfs_log.stp</a> - Trace libguestfs startup<br>
-keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <br>
+keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The libguestfs_log.stp script prints a log of when various libgueststartup steps are encountered. The first column is microseconds since the script started. The second column is the time elapsed in microseconds between the previous and current events and the third column is the event name.</p><p><font size="-2"><pre># stap libguestfs_log.stp -T 1</pre></font></p>
</li><li><a href="apps/stap_time.stp">apps/stap_time.stp</a> - Provide elapsed times for Passes of SystemTap script compilation<br>
keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <br>
</li></ul>
<h3><a name="BPF"><a href="#BPF">¶</a> BPF</a></h3>
<ul>
-<li><a href="memory/cachestat.stp">memory/cachestat.stp</a> - Count Page Cache Hits and Misses<br>
+<li><a href="apps/libguestfs_log.stp">apps/libguestfs_log.stp</a> - Trace libguestfs startup<br>
+keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The libguestfs_log.stp script prints a log of when various libgueststartup steps are encountered. The first column is microseconds since the script started. The second column is the time elapsed in microseconds between the previous and current events and the third column is the event name.</p><p><font size="-2"><pre># stap libguestfs_log.stp -T 1</pre></font></p>
+</li><li><a href="general/ansi_colors.stp">general/ansi_colors.stp</a> - Color Table for ansi_set_color()<br>
+keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The script prints a table showing the available color combinations for the ansi_set_color() function in the ansi.stp tapset.</p><p><font size="-2"><pre># stap ansi_colors.stp</pre></font></p>
+</li><li><a href="general/ansi_colors2.stp">general/ansi_colors2.stp</a> - Show Attribues in Table for ansi_set_color()<br>
+keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The script prints a table showing the available attributes (bold, underline, and inverse) with color combinations for the ans_set_color() function in the ansi.stp tapset.</p><p><font size="-2"><pre># stap ansi_colors2.stp</pre></font></p>
+</li><li><a href="general/helloworld.stp">general/helloworld.stp</a> - SystemTap "Hello World" Program<br>
+keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#SIMPLE">SIMPLE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.</p><p><font size="-2"><pre># stap helloworld.stp</pre></font></p>
+</li><li><a href="memory/cachestat.stp">memory/cachestat.stp</a> - Count Page Cache Hits and Misses<br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap cachestat.stp -T 1</pre></font></p>
+</li><li><a href="memory/mmfilepage.stp">memory/mmfilepage.stp</a> - Track Virtual Memory System Actions on File Backed Pages<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
-<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap --bpf cachestat.stp -T 1</pre></font></p>
+<p>The mmfilepage.stp script uses the virtual memory tracepoints available in some kernels to track the number of faults, copy on writes mapping, and unmapping operations for file backed pages. When the script is terminated the counts are printed for each process that allocated pages while the script was running. The mmfilepage.stp script is useful in debugging leaks in the mapped file regions of a process.</p><p><font size="-2"><pre># stap mmfilepage.stp -T 1</pre></font></p>
+</li><li><a href="memory/mmwriteback.stp">memory/mmwriteback.stp</a> - Track Virtual Memory System Writing to Disk<br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The mmwriteback.stp script uses the virtual memory tracepoints available in some kernels to report all of the file writebacks that occur form kupdate, pdflush and kjournald while the script is running. It's useful in determining where writes are coming from on a supposedly idle system that is experiencing unexpected IO.</p><p><font size="-2"><pre># stap mmwriteback.stp -T 1</pre></font></p>
+</li><li><a href="network/sk_stream_wait_memory.stp">network/sk_stream_wait_memory.stp</a> - Track Start and Stop of Processes Due to Network Buffer Space<br>
+keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The sk_stream-wait_memory.stp prints a time stamp, executable, and pid each time a process blocks due to the send buffer being full. A similar entry is printed each time a process continues because there is room in the buffer.</p><p><font size="-2"><pre># stap sk_stream_wait_memory.stp -T 1</pre></font></p>
+</li><li><a href="profiling/syscallsrw.stp">profiling/syscallsrw.stp</a> - Provide a tally of read and write syscalls run on the system <br>
+keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The syscall_read_write.stp script tallies the read and write syscalls. This is a demo script for stapbpf prometheus-exporter scripts.</p></p>
</li></ul>
<h3><a name="CALLGRAPH"><a href="#CALLGRAPH">¶</a> CALLGRAPH</a></h3>
<ul>
keywords: <a href="keyword-index.html#NFS">NFS</a> <a href="keyword-index.html#DISK">DISK</a> <br>
<p>The nfsd_unlink.stp script lists the ip address and file name each time time a file is being removed or unlinked by the nfsd. This script is run on the nfs server.</p><p><font size="-2"><pre># stap nfsd_unlink.stp -T 1</pre></font></p>
</li></ul>
+<h3><a name="DYNINST"><a href="#DYNINST">¶</a> DYNINST</a></h3>
+<ul>
+<li><a href="apps/php-trace.stp">apps/php-trace.stp</a> - Tracing of PHP code execution<br>
+keywords: <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#DYNINST">DYNINST</a> <br>
+<p>Trace of executing PHP code using the enabled markers.</p><p><font size="-2"><pre># stap php-trace.stp -c 'php -f hello.php'</pre></font></p>
+</li></ul>
<h3><a name="FILE"><a href="#FILE">¶</a> FILE</a></h3>
<ul>
<li><a href="io/iotime.stp">io/iotime.stp</a> - Trace Time Spent in Read and Write for Files <br>
<h3><a name="FORMAT"><a href="#FORMAT">¶</a> FORMAT</a></h3>
<ul>
<li><a href="general/ansi_colors.stp">general/ansi_colors.stp</a> - Color Table for ansi_set_color()<br>
-keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br>
+keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The script prints a table showing the available color combinations for the ansi_set_color() function in the ansi.stp tapset.</p><p><font size="-2"><pre># stap ansi_colors.stp</pre></font></p>
</li><li><a href="general/ansi_colors2.stp">general/ansi_colors2.stp</a> - Show Attribues in Table for ansi_set_color()<br>
-keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br>
+keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The script prints a table showing the available attributes (bold, underline, and inverse) with color combinations for the ans_set_color() function in the ansi.stp tapset.</p><p><font size="-2"><pre># stap ansi_colors2.stp</pre></font></p>
</li></ul>
<h3><a name="FUNCTION"><a href="#FUNCTION">¶</a> FUNCTION</a></h3>
keywords: <a href="keyword-index.html#STATISTICS">STATISTICS</a> <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#INTERACTIVE">INTERACTIVE</a> <br>
<p>This script prints the size of a type, based on dwarf debuginfo for any kernel or userspace module, or trial-compilation of a given header file name. Types and corresponding locations are provided to the script at runtime via keyboard input. The format of the input is identical to that of sizeof.stp (see script source for more information). Types and locations can be repeatedly given until the process is terminated. </p><p><i><a href="general/sizeof_interactive.txt">sample usage in general/sizeof_interactive.txt</i></font></p>
</li><li><a href="memory/cachestat.stp">memory/cachestat.stp</a> - Count Page Cache Hits and Misses<br>
-keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
-<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap cachestat.stp -T 1</pre></font></p>
-</li><li><a href="memory/cachestat.stp">memory/cachestat.stp</a> - Count Page Cache Hits and Misses<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
-<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap --bpf cachestat.stp -T 1</pre></font></p>
+<p>Monitors hits and misses to the page cache and reports a count every 5 seconds. Based on a bpftrace tool by David Valin.</p><p><font size="-2"><pre># stap cachestat.stp -T 1</pre></font></p>
</li><li><a href="memory/glibc-malloc.stp">memory/glibc-malloc.stp</a> - Overview glibc malloc internal operations<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <br>
<p>This script reports on internal statistics of the glibc malloc implementation, as used by a process restricted by stap -x/-c</p><p><font size="-2"><pre># stap glibc-malloc.stp -c 'stap --dump-functions'</pre></font></p>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
<p>The mmanonpage.stp script uses the virtual memory tracepoints available in some kernels to track the number of faults, user space frees, page ins, copy on writes and unmaps for anonymous pages. When the script is terminated the counts are printed for each process that allocated pages while the script was running. This script displays the anonymous page statistics for each process that ran while the script is active. It's useful in debugging leaks in the anonymous regions of a process.</p><p><font size="-2"><pre># stap mmanonpage.stp -T 1</pre></font></p>
</li><li><a href="memory/mmfilepage.stp">memory/mmfilepage.stp</a> - Track Virtual Memory System Actions on File Backed Pages<br>
-keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The mmfilepage.stp script uses the virtual memory tracepoints available in some kernels to track the number of faults, copy on writes mapping, and unmapping operations for file backed pages. When the script is terminated the counts are printed for each process that allocated pages while the script was running. The mmfilepage.stp script is useful in debugging leaks in the mapped file regions of a process.</p><p><font size="-2"><pre># stap mmfilepage.stp -T 1</pre></font></p>
</li><li><a href="memory/mmreclaim.stp">memory/mmreclaim.stp</a> - Track Virtual Memory System Page Reclamation<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
<p>The mmreclaim.stp script uses the virtual memory tracepoints available in some kernels to track page reclaim activity that occurred while the script was running. It's useful in debugging performance problems that occur due to page reclamation.</p><p><font size="-2"><pre># stap mmreclaim.stp -T 1</pre></font></p>
</li><li><a href="memory/mmwriteback.stp">memory/mmwriteback.stp</a> - Track Virtual Memory System Writing to Disk<br>
-keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The mmwriteback.stp script uses the virtual memory tracepoints available in some kernels to report all of the file writebacks that occur form kupdate, pdflush and kjournald while the script is running. It's useful in determining where writes are coming from on a supposedly idle system that is experiencing unexpected IO.</p><p><font size="-2"><pre># stap mmwriteback.stp -T 1</pre></font></p>
</li><li><a href="memory/numa_faults.stp">memory/numa_faults.stp</a> - Summarize Process Misses across NUMA Nodes<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <a href="keyword-index.html#NUMA">NUMA</a> <br>
keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <br>
<p>The packet_contents.stp script displays the length of each network packet and its contents in both hexadecimal and ASCII. Systemtap strings are MAXSTRINGLEN in length by default which may not be enough for larger packets. In order to print larger packets, this limit can be increased by passing in the "-DMAXSTRINGLEN=65536" command line option.</p><p><i><a href="network/packet_contents.txt">sample usage in network/packet_contents.txt</i></font></p>
</li><li><a href="network/sk_stream_wait_memory.stp">network/sk_stream_wait_memory.stp</a> - Track Start and Stop of Processes Due to Network Buffer Space<br>
-keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <br>
+keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The sk_stream-wait_memory.stp prints a time stamp, executable, and pid each time a process blocks due to the send buffer being full. A similar entry is printed each time a process continues because there is room in the buffer.</p><p><font size="-2"><pre># stap sk_stream_wait_memory.stp -T 1</pre></font></p>
</li><li><a href="network/socket-trace.stp">network/socket-trace.stp</a> - Trace Functions Called in Network Socket Code<br>
keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <br>
keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <br>
<p>The connect_stat.stp script prints a task's entire ancestry (parent process name/uid/gid) whenever it attempts an outgoing socket connection to a given IP address.</p><p><font size="-2"><pre># stap connect_stat.stp 127.0.0.1 -T 1</pre></font></p>
</li><li><a href="network/sk_stream_wait_memory.stp">network/sk_stream_wait_memory.stp</a> - Track Start and Stop of Processes Due to Network Buffer Space<br>
-keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <br>
+keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The sk_stream-wait_memory.stp prints a time stamp, executable, and pid each time a process blocks due to the send buffer being full. A similar entry is printed each time a process continues because there is room in the buffer.</p><p><font size="-2"><pre># stap sk_stream_wait_memory.stp -T 1</pre></font></p>
</li><li><a href="process/cycle_thief.stp">process/cycle_thief.stp</a> - Track IRQ's and Other Processes Stealing Cycles from a Task<br>
keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SCHEDULER">SCHEDULER</a> <a href="keyword-index.html#TIME">TIME</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#INTERRUPT">INTERRUPT</a> <br>
</li><li><a href="profiling/syscallsbypid.stp">profiling/syscallsbypid.stp</a> - Provide a per-process syscall tally on the system<br>
keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <br>
<p>The syscallsbypid.stp script tallies each syscall for each running process. This information can be useful to determine the activity of various processes on the system. The script makes the information available via procfs in Prometheus readable format. When a process exits its data will be eliminated from the prometheus output. To avoid exceeding the storage limitations of SystemTap older entries maybe overwritten by newer entries. This can lead to some active process syscall counts disappearing and/or later reappearing with a lower value. Also note that the script does not properly name syscalls for 32-bit applications running on 64-bit machines.</p><p><font size="-2"><pre># stap syscallsbypid.stp -T 1</pre></font></p>
+</li><li><a href="profiling/syscallsrw.stp">profiling/syscallsrw.stp</a> - Provide a tally of read and write syscalls run on the system <br>
+keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The syscall_read_write.stp script tallies the read and write syscalls. This is a demo script for stapbpf prometheus-exporter scripts.</p></p>
</li></ul>
<h3><a name="QEMU"><a href="#QEMU">¶</a> QEMU</a></h3>
<ul>
keywords: <a href="keyword-index.html#SIMPLE">SIMPLE</a> <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#CALLGRAPH">CALLGRAPH</a> <br>
<p>Print a timed per-thread microsecond-timed nested callgraph. The first parameter names the function probe points to trace.</p><p><i><a href="general/callgraph.txt">sample usage in general/callgraph.txt</i></font></p>
</li><li><a href="general/helloworld.stp">general/helloworld.stp</a> - SystemTap "Hello World" Program<br>
-keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#SIMPLE">SIMPLE</a> <br>
+keywords: <a href="keyword-index.html#_BEST">_BEST</a> <a href="keyword-index.html#SIMPLE">SIMPLE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.</p><p><font size="-2"><pre># stap helloworld.stp</pre></font></p>
</li><li><a href="general/key.stp">general/key.stp</a> - make keyboard noises<br>
keywords: <a href="keyword-index.html#SIMPLE">SIMPLE</a> <br>
</li><li><a href="profiling/syscallsbypid.stp">profiling/syscallsbypid.stp</a> - Provide a per-process syscall tally on the system<br>
keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <br>
<p>The syscallsbypid.stp script tallies each syscall for each running process. This information can be useful to determine the activity of various processes on the system. The script makes the information available via procfs in Prometheus readable format. When a process exits its data will be eliminated from the prometheus output. To avoid exceeding the storage limitations of SystemTap older entries maybe overwritten by newer entries. This can lead to some active process syscall counts disappearing and/or later reappearing with a lower value. Also note that the script does not properly name syscalls for 32-bit applications running on 64-bit machines.</p><p><font size="-2"><pre># stap syscallsbypid.stp -T 1</pre></font></p>
+</li><li><a href="profiling/syscallsrw.stp">profiling/syscallsrw.stp</a> - Provide a tally of read and write syscalls run on the system <br>
+keywords: <a href="keyword-index.html#PROMETHEUS">PROMETHEUS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#BPF">BPF</a> <br>
+<p>The syscall_read_write.stp script tallies the read and write syscalls. This is a demo script for stapbpf prometheus-exporter scripts.</p></p>
</li><li><a href="profiling/ucalls.stp">profiling/ucalls.stp</a> - Profile method invocations in Java, Perl, Php, Python, Ruby, and Tcl scripts<br>
keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <br>
<p>The ucalls.stp script is modeled after the BCC ucalls script (https://github.com/iovisor/bcc/blob/master/tools/lib/ucalls.py) by Sasha Goldshtein. The ucalls.stp script monitors the process indicated by the -x or -c option. When the scripts exits it prints out information about the number of times that each method is invoked for code written in Java, Perl, Php, Python, Ruby, and Tcl. Include the word "syscalls" on the command line to count syscalls invoked by the process. If you want latency information, include "latency" on the command line. Note that the latency option does not work for recursive functions</p><p><font size="-2"><pre># stap ucalls.stp syscalls latency -c "python -c 'print(\"hello world\")' \
<h3><a name="TCP"><a href="#TCP">¶</a> TCP</a></h3>
<ul>
<li><a href="network/sk_stream_wait_memory.stp">network/sk_stream_wait_memory.stp</a> - Track Start and Stop of Processes Due to Network Buffer Space<br>
-keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <br>
+keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The sk_stream-wait_memory.stp prints a time stamp, executable, and pid each time a process blocks due to the send buffer being full. A similar entry is printed each time a process continues because there is room in the buffer.</p><p><font size="-2"><pre># stap sk_stream_wait_memory.stp -T 1</pre></font></p>
</li><li><a href="network/tcp_connections.stp">network/tcp_connections.stp</a> - Track Creation of Incoming TCP Connections<br>
keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <br>
keywords: <a href="keyword-index.html#TRACE">TRACE</a> <br>
<p>The gmalloc_watch.stp script from Colin Walters' blog (https://blog.verbum.org/2011/03/19/analyzing-memory-use-with-systemtap/) traces the allocation of glib2 memory using the markers in glib2.</p><p><font size="-2"><pre># stap gmalloc_watch.stp -T 1</pre></font></p>
</li><li><a href="apps/libguestfs_log.stp">apps/libguestfs_log.stp</a> - Trace libguestfs startup<br>
-keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <br>
+keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#BPF">BPF</a> <br>
<p>The libguestfs_log.stp script prints a log of when various libgueststartup steps are encountered. The first column is microseconds since the script started. The second column is the time elapsed in microseconds between the previous and current events and the third column is the event name.</p><p><font size="-2"><pre># stap libguestfs_log.stp -T 1</pre></font></p>
</li><li><a href="apps/php-trace.stp">apps/php-trace.stp</a> - Tracing of PHP code execution<br>
-keywords: <a href="keyword-index.html#TRACE">TRACE</a> <br>
+keywords: <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#DYNINST">DYNINST</a> <br>
<p>Trace of executing PHP code using the enabled markers.</p><p><font size="-2"><pre># stap php-trace.stp -c 'php -f hello.php'</pre></font></p>
</li><li><a href="apps/stap_time.stp">apps/stap_time.stp</a> - Provide elapsed times for Passes of SystemTap script compilation<br>
keywords: <a href="keyword-index.html#APPLICATION">APPLICATION</a> <a href="keyword-index.html#TRACE">TRACE</a> <br>
(see also index.txt)
-For systemtap version 4.1.
+For systemtap version 4.2.
= _BEST =
general/helloworld.stp - SystemTap "Hello World" Program
-keywords: _best simple
+keywords: _best simple bpf
A basic "Hello World" program implemented in SystemTap script. It
prints out "hello world" message and then immediately exits.
= APPLICATION =
apps/libguestfs_log.stp - Trace libguestfs startup
-keywords: application trace
+keywords: application trace bpf
The libguestfs_log.stp script prints a log of when various
libgueststartup steps are encountered. The first column is
= BPF =
+apps/libguestfs_log.stp - Trace libguestfs startup
+keywords: application trace bpf
+
+ The libguestfs_log.stp script prints a log of when various
+ libgueststartup steps are encountered. The first column is
+ microseconds since the script started. The second column is the time
+ elapsed in microseconds between the previous and current events and
+ the third column is the event name.
+
+ # stap libguestfs_log.stp -T 1
+
+
+general/ansi_colors.stp - Color Table for ansi_set_color()
+keywords: format bpf
+
+ The script prints a table showing the available color combinations
+ for the ansi_set_color() function in the ansi.stp tapset.
+
+ # stap ansi_colors.stp
+
+
+general/ansi_colors2.stp - Show Attribues in Table for ansi_set_color()
+keywords: format bpf
+
+ The script prints a table showing the available attributes (bold,
+ underline, and inverse) with color combinations for the
+ ans_set_color() function in the ansi.stp tapset.
+
+ # stap ansi_colors2.stp
+
+
+general/helloworld.stp - SystemTap "Hello World" Program
+keywords: _best simple bpf
+
+ A basic "Hello World" program implemented in SystemTap script. It
+ prints out "hello world" message and then immediately exits.
+
+ # stap helloworld.stp
+
+
memory/cachestat.stp - Count Page Cache Hits and Misses
keywords: memory bpf
Monitors hits and misses to the page cache and reports a count every
5 seconds. Based on a bpftrace tool by David Valin.
- # stap --bpf cachestat.stp -T 1
+ # stap cachestat.stp -T 1
+
+
+memory/mmfilepage.stp - Track Virtual Memory System Actions on File Backed Pages
+keywords: memory bpf
+
+ The mmfilepage.stp script uses the virtual memory tracepoints
+ available in some kernels to track the number of faults, copy on
+ writes mapping, and unmapping operations for file backed pages. When
+ the script is terminated the counts are printed for each process that
+ allocated pages while the script was running. The mmfilepage.stp
+ script is useful in debugging leaks in the mapped file regions of a
+ process.
+
+ # stap mmfilepage.stp -T 1
+
+
+memory/mmwriteback.stp - Track Virtual Memory System Writing to Disk
+keywords: memory bpf
+
+ The mmwriteback.stp script uses the virtual memory tracepoints
+ available in some kernels to report all of the file writebacks that
+ occur form kupdate, pdflush and kjournald while the script is
+ running. It's useful in determining where writes are coming from on
+ a supposedly idle system that is experiencing unexpected IO.
+
+ # stap mmwriteback.stp -T 1
+
+
+network/sk_stream_wait_memory.stp - Track Start and Stop of Processes Due to Network Buffer Space
+keywords: network tcp process bpf
+
+ The sk_stream-wait_memory.stp prints a time stamp, executable, and
+ pid each time a process blocks due to the send buffer being full. A
+ similar entry is printed each time a process continues because there
+ is room in the buffer.
+
+ # stap sk_stream_wait_memory.stp -T 1
+
+
+profiling/syscallsrw.stp - Provide a tally of read and write syscalls run on the system
+keywords: prometheus syscall bpf
+
+ The syscall_read_write.stp script tallies the read and write
+ syscalls. This is a demo script for stapbpf prometheus-exporter
+ scripts.
= CALLGRAPH =
# stap nfsd_unlink.stp -T 1
+= DYNINST =
+
+apps/php-trace.stp - Tracing of PHP code execution
+keywords: trace dyninst
+
+ Trace of executing PHP code using the enabled markers.
+
+ # stap php-trace.stp -c 'php -f hello.php'
+
+
= FILE =
io/iotime.stp - Trace Time Spent in Read and Write for Files
= FORMAT =
general/ansi_colors.stp - Color Table for ansi_set_color()
-keywords: format
+keywords: format bpf
The script prints a table showing the available color combinations
for the ansi_set_color() function in the ansi.stp tapset.
general/ansi_colors2.stp - Show Attribues in Table for ansi_set_color()
-keywords: format
+keywords: format bpf
The script prints a table showing the available attributes (bold,
underline, and inverse) with color combinations for the
# echo "FILE '</usr/include/stdio.h>'" | stap sizeof_interactive.stp -T 1
-memory/cachestat.stp - Count Page Cache Hits and Misses
-keywords: memory
-
- Monitors hits and misses to the page cache and reports a count every
- 5 seconds. Based on a bpftrace tool by David Valin.
-
- # stap cachestat.stp -T 1
-
-
memory/cachestat.stp - Count Page Cache Hits and Misses
keywords: memory bpf
Monitors hits and misses to the page cache and reports a count every
5 seconds. Based on a bpftrace tool by David Valin.
- # stap --bpf cachestat.stp -T 1
+ # stap cachestat.stp -T 1
memory/glibc-malloc.stp - Overview glibc malloc internal operations
memory/mmfilepage.stp - Track Virtual Memory System Actions on File Backed Pages
-keywords: memory
+keywords: memory bpf
The mmfilepage.stp script uses the virtual memory tracepoints
available in some kernels to track the number of faults, copy on
memory/mmwriteback.stp - Track Virtual Memory System Writing to Disk
-keywords: memory
+keywords: memory bpf
The mmwriteback.stp script uses the virtual memory tracepoints
available in some kernels to report all of the file writebacks that
network/sk_stream_wait_memory.stp - Track Start and Stop of Processes Due to Network Buffer Space
-keywords: network tcp process
+keywords: network tcp process bpf
The sk_stream-wait_memory.stp prints a time stamp, executable, and
pid each time a process blocks due to the send buffer being full. A
network/sk_stream_wait_memory.stp - Track Start and Stop of Processes Due to Network Buffer Space
-keywords: network tcp process
+keywords: network tcp process bpf
The sk_stream-wait_memory.stp prints a time stamp, executable, and
pid each time a process blocks due to the send buffer being full. A
# stap syscallsbypid.stp -T 1
+profiling/syscallsrw.stp - Provide a tally of read and write syscalls run on the system
+keywords: prometheus syscall bpf
+
+ The syscall_read_write.stp script tallies the read and write
+ syscalls. This is a demo script for stapbpf prometheus-exporter
+ scripts.
+
+
= QEMU =
virtualization/qemu_count.stp - Tally the Number of User-Space QEMU Events
general/helloworld.stp - SystemTap "Hello World" Program
-keywords: _best simple
+keywords: _best simple bpf
A basic "Hello World" program implemented in SystemTap script. It
prints out "hello world" message and then immediately exits.
# stap syscallsbypid.stp -T 1
+profiling/syscallsrw.stp - Provide a tally of read and write syscalls run on the system
+keywords: prometheus syscall bpf
+
+ The syscall_read_write.stp script tallies the read and write
+ syscalls. This is a demo script for stapbpf prometheus-exporter
+ scripts.
+
+
profiling/ucalls.stp - Profile method invocations in Java, Perl, Php, Python, Ruby, and Tcl scripts
keywords: profiling syscall
= TCP =
network/sk_stream_wait_memory.stp - Track Start and Stop of Processes Due to Network Buffer Space
-keywords: network tcp process
+keywords: network tcp process bpf
The sk_stream-wait_memory.stp prints a time stamp, executable, and
pid each time a process blocks due to the send buffer being full. A
apps/libguestfs_log.stp - Trace libguestfs startup
-keywords: application trace
+keywords: application trace bpf
The libguestfs_log.stp script prints a log of when various
libgueststartup steps are encountered. The first column is
apps/php-trace.stp - Tracing of PHP code execution
-keywords: trace
+keywords: trace dyninst
Trace of executing PHP code using the enabled markers.
--- /dev/null
+title: Provide a tally of read and write syscalls run on the system
+name: syscallsrw.stp
+version: 1.0
+author: Sagar Patel
+keywords: prometheus syscall bpf
+subsystem: process
+status: experimental
+exit: user-controlled
+output: proc
+scope: system-wide
+description: The syscall_read_write.stp script tallies the read and write syscalls. This is a demo script for stapbpf prometheus-exporter scripts.
+test_check_bpf: stap --bpf -p4 syscallsrw.stp
+test_installcheck_bpf: stap --bpf syscallsrw.stp -T 1
--- /dev/null
+#! /usr/bin/stap --bpf
+
+global arr
+
+probe kernel.function("ksys_read") !, kernel.function("vfs_read") {
+ arr[0]++;
+}
+
+probe kernel.function("ksys_write") !, kernel.function("vfs_write") {
+ arr[1]++;
+}
+
+probe prometheus {
+
+ $value .= ("count{syscall=\"ksys_read\"} " . sprint(arr[0]) . "\n")
+ $value .= ("count{syscall=\"ksys_write\"} " . sprint(arr[1]) . "\n")
+
+}