Skip to content
Snippets Groups Projects
Commit 748edbf3 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

scripts: add probe_dump.py

parent 9bf810a2
Branches
Tags
No related merge requests found
Pipeline #91219 passed with stages
in 11 minutes and 6 seconds
#!/usr/bin/env python3
#
# A simple Knot DNS probe client
#
import argparse
import libknot
import libknot.probe
import sys
def probe_loop(args):
try:
libknot.Knot(args.libknot_path)
except:
print("Cannot find shared library libknot.so")
sys.exit(1)
probe = libknot.probe.KnotProbe(args.probe_dir, args.channel)
data = libknot.probe.KnotProbeDataArray(8)
try:
while (True):
if probe.consume(data, 1000) > 0:
for item in data:
print(item.str(color=not args.no_color, timestamp=not args.no_timestamp))
except KeyboardInterrupt:
sys.exit(0)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"--libknot-path",
help="path to the libknot shared library"
)
parser.add_argument(
"--probe-dir",
default="/run/knot",
help="path to the probe directory"
)
parser.add_argument(
"--channel",
type=int,
default=1,
help="the probe channel"
)
parser.add_argument(
"--no-color",
action='store_true',
help="don't colorize the output"
)
parser.add_argument(
"--no-timestamp",
action='store_true',
help="don't print the current timestamp"
)
args = parser.parse_args()
probe_loop(args)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment