bind9/dtrace/delegdb-trace.stp
Ondřej Surý 6c1e1e8e9a
Add dtrace/ with example SystemTap trace scripts
Introduces a top-level dtrace/ directory for user-contributed trace
scripts that consume the USDT probes exported by libdns, libns, and
libisc.  Ships with delegdb-trace.stp, which streams every insertion,
eviction, and rndc flush-delegation removal in the delegation cache,
and a README pointing at the provider files and explaining how to list
and run the probes on Linux (SystemTap) and on FreeBSD/macOS (DTrace).
2026-04-20 13:14:19 +02:00

46 lines
1.2 KiB
Text
Executable file

#!/usr/bin/env stap
#
# delegdb-trace.stp - trace delegation cache mutations
#
# Prints every insertion and every removal (both explicit deletes via
# rndc flush-delegation and implicit SIEVE-LRU evictions under memory
# pressure) from the delegdb.
#
# Usage:
# sudo stap delegdb-trace.stp /path/to/named
# sudo stap delegdb-trace.stp /path/to/named -x <pid>
#
# Output columns: elapsed milliseconds, operation, isc_result_t code (or
# "-" for evict), and the zonecut name. Trees deleted via
# rndc flush-delegation -tree are labelled DELTREE.
global start_time
probe begin {
start_time = gettimeofday_ms()
printf("%-10s %-8s %-7s %s\n", "ms", "op", "result", "zonecut")
}
probe process(@1).mark("delegdb_insert_done") {
printf("%-10d %-8s %-7d %s\n",
gettimeofday_ms() - start_time,
"INSERT",
$arg3,
user_string($arg2))
}
probe process(@1).mark("delegdb_delete") {
printf("%-10d %-8s %-7d %s\n",
gettimeofday_ms() - start_time,
$arg3 ? "DELTREE" : "DELETE",
$arg4,
user_string($arg2))
}
probe process(@1).mark("delegdb_evict") {
printf("%-10d %-8s %-7s %s\n",
gettimeofday_ms() - start_time,
"EVICT",
"-",
user_string($arg3))
}