.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Podwrapper::Man 1.49.4 (Pod::Simple 3.48) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "nbdkit-tracing 3" .TH nbdkit-tracing 3 2026-10-17 nbdkit-1.49.4 NBDKIT .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME nbdkit\-tracing \- adding user statically defined tracing (USDT) probes .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& perf buildid\-cache \-\-add server/nbdkit .Ve .PP .Vb 1 \& perf list sdt_nbdkit:* .Ve .PP .Vb 1 \& perf probe sdt_nbdkit:* .Ve .PP .Vb 2 \& perf record \-e sdt_nbdkit:* \-a \-R \e \& ./nbdkit memory 1G \-\-run \*(Aqnbdinfo "$uri"\*(Aq .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" You can add user statically defined tracing (USDT) a.k.a DTrace probes to nbdkit and use them to trace significant events in the server. Note this almost certainly requires you to recompile nbdkit from source, since only a very minimal set of probes is included in nbdkit itself and you will want to add your own. .SS "ADDING PROBES" .IX Subsection "ADDING PROBES" To enable probing at all you will need the \fI\fR header file installed (eg. from the package \f(CW\*(C`systemtap\-sdt\-devel\*(C'\fR on Fedora, but available from different places in other Linux distros and BSD). When configuring nbdkit you should see: .PP .Vb 3 \& Optional server features: \& ... \& USDT probes ............................ yes .Ve .PP Add probes by inserting \f(CW\*(C`DTRACE_PROBE\*(C'\fR or \f(CW\*(C`DTRACE_PROBE\*(C'\fR macros into the server source code: .PP .Vb 1 \& DTRACE_PROBE (nbdkit, my_probe); .Ve .PP or with up to 12 parameters: .PP .Vb 1 \& DTRACE_PROBE2 (nbdkit, my_probe, arg1, arg2); .Ve .PP After compiling nbdkit, you should see a \f(CW\*(C`.note.stapsdt\*(C'\fR ELF section in the binary. This section contains the probes: .PP .Vb 8 \& $ readelf \-x .note.stapsdt server/nbdkit \& Hex dump of section \*(Aq.note.stapsdt\*(Aq: \& 0x00000000 08000000 39000000 03000000 73746170 ....9.......stap \& 0x00000010 73647400 42c70000 00000000 40400200 sdt.B.......@@.. \& 0x00000020 00000000 00000000 00000000 6e62646b ............nbdk \& 0x00000030 69740068 616e646c 655f7369 6e676c65 it.handle_single \& 0x00000040 5f636f6e 6e656374 696f6e00 00000000 _connection..... \& ... .Ve .SS "USING PERF TO TRACE NBDKIT" .IX Subsection "USING PERF TO TRACE NBDKIT" \&\fBperf\fR\|(1) requires that you scan the binary to detect the probes: .PP .Vb 5 \& # perf buildid\-cache \-\-add server/nbdkit \& # perf list sdt_nbdkit:* \& List of pre\-defined events (to be used in \-e or \-M): \& sdt_nbdkit:handle_single_connection [SDT event] \& sdt_nbdkit:preconnect [SDT event] .Ve .PP To enable all probes (costly) use: .PP .Vb 1 \& # perf probe sdt_nbdkit:* .Ve .PP You can also enable just the probes you are interested in. .PP To disable probes, use \f(CW\*(C`perf probe \-\-del \fR\f(CIpattern\fR\f(CW\*(C'\fR. .PP Then run perf to record information in the usual way, for example: .PP .Vb 2 \& # perf record \-e sdt_nbdkit:* \-a \-R \e \& ./nbdkit memory 1G \-\-run \*(Aqnbdinfo "$uri"\*(Aq \& \& # perf script \& nbdkit 1620084 [007] 2415654.254236: \& sdt_nbdkit:handle_single_connection: (55e582694742) \& nbdkit 1620084 [007] 2415654.254247: \& sdt_nbdkit:preconnect: (55e582698724) arg1=94444748021888 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBnbdkit\fR\|(1), \&\fBperf\fR\|(1), https://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps, https://blog.vmsplice.net/2017/07/tracing\-userspace\-static\-probes\-with.html, https://jvns.ca/blog/2017/07/05/linux\-tracing\-systems/, https://docs.openvswitch.org/en/latest/topics/usdt\-probes/. .SH AUTHORS .IX Header "AUTHORS" Eric Blake .PP Richard W.M. Jones .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright Red Hat .SH LICENSE .IX Header "LICENSE" Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: .IP \(bu 4 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. .IP \(bu 4 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. .IP \(bu 4 Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS \*(Aq\*(AqAS IS\*(Aq\*(Aq AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.