diff options
author | Daniel Salzman <daniel.salzman@nic.cz> | 2023-12-05 08:54:41 +0100 |
---|---|---|
committer | Daniel Salzman <daniel.salzman@nic.cz> | 2023-12-05 08:54:41 +0100 |
commit | 7d900a7152f669601f8faff2ffc61a99d3612f1b (patch) | |
tree | 569c854f6d3497e90d80d3c1520b98bc68b67353 /python | |
parent | ctl: add flag for unix time values in zone status (diff) | |
download | knot-7d900a7152f669601f8faff2ffc61a99d3612f1b.tar.xz knot-7d900a7152f669601f8faff2ffc61a99d3612f1b.zip |
python/libknot: add example for zone status
Diffstat (limited to 'python')
-rw-r--r-- | python/libknot/README.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/python/libknot/README.md b/python/libknot/README.md index fdf65b42f..ff11447a7 100644 --- a/python/libknot/README.md +++ b/python/libknot/README.md @@ -88,6 +88,21 @@ finally: print(zone) ``` +```python3 + # Print expirations as unixtime for all secondary zones + ctl.send_block(cmd="zone-status", flags="u") + resp = ctl.receive_block() + for zone in resp: + if resp[zone]["role"] == "master": + continue + + expiration = resp[zone]["expiration"] + if expiration == "-": + print("Zone %s not loaded" % zone) + else: + print("Zone %s expires at %s" % (zone, resp[zone]["expiration"])) +``` + ## Probe module Using this module it's possible to receive traffic data from a running daemon with |