How to use the libknot.control.KnotCtlType.END function in libknot

To help you get started, we’ve selected a few libknot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CZ-NIC / knot / samples / stats_http.py View on Github external
try:
            ctl.send_block(cmd="stats", flags=ctl_flags)
            global_stats = ctl.receive_stats()
        except:
            pass

        # Get zone metrics.
        zone_stats = dict()
        try:
            ctl.send_block(cmd="zone-stats", flags=ctl_flags)
            zone_stats = ctl.receive_stats()
        except:
           pass

        # Disconnect from the server.
        ctl.send(libknot.control.KnotCtlType.END)
        ctl.close()

        # Publish the stats.
        stats = {**global_stats, **zone_stats}
        self.wfile.write(bytes(json.dumps(stats, indent=4, sort_keys=True), "utf-8"))
github CZ-NIC / knot / samples / stats_influxdb.py View on Github external
try:
        ctl.send_block(cmd="stats", flags="F")
        global_stats = ctl.receive_stats()
    except:
        pass

    # Get zone metrics.
    zone_stats = dict()
    try:
        ctl.send_block(cmd="zone-stats", flags="F")
        zone_stats = ctl.receive_stats()
    except:
        pass

    # Disconnect from the server.
    ctl.send(libknot.control.KnotCtlType.END)
    ctl.close()

    # Prepare the metrics to publish.
    output = io.StringIO()

    stats = {**global_stats, **zone_stats}
    timestamp = str(int(time.time()))

    for metric in stats["server"]:
        print("server,instance=" + instance + ",metric=" + metric + " value=" +
              stats["server"][metric] + " " + timestamp, file=output)

    for group in stats["mod-stats"]:
        for metric in stats["mod-stats"][group]:
            print(group + ",instance=" + instance + ",metric=" + metric +
                  " value=" + stats["mod-stats"][group][metric] + " " + timestamp,

libknot

Python bindings for libknot

GPL-3.0
Latest version published 8 days ago

Package Health Score

60 / 100
Full package analysis