Commit 71cc6f26 authored by Alexandre's avatar Alexandre
Browse files

Option --time to display transfer time

parent 8b20f660
......@@ -146,12 +146,29 @@ In order to focus on the time per request, you can suppress the
output by using the option `--silent`.
This option only works with `--multistreams`.
Finally, two modes are available. By default each response is read,
Two modes are available. By default each response is read,
checked and displayed as soon as it is received.
You can use `--sync` to delay this processing after the last transfer.
In that case the DNS responses are displayed in the same order as they
were sent.
An option `--time` allows to display the time taken by each transfer.
This is based on [libcurl time values](https://curl.haxx.se/libcurl/c/curl_easy_getinfo.html#TIMES)
[CURLINFO_TOTAL_TIME](https://curl.haxx.se/libcurl/c/curl_easy_getinfo.html#CURLINFOTOTALTIME)
and [CURLINFO_PRETRANSFER_TIME](https://curl.haxx.se/libcurl/c/curl_easy_getinfo.html#CURLINFOPRETRANSFERTIME)
```
% ./homer.py --multistreams --file input_file --repeat 5 --silent --time https://doh.powerdns.org
0 36.165 ms 44.773 ms 8.608 ms
1 0.142 ms 8.580 ms 8.438 ms
3 0.095 ms 9.223 ms 9.128 ms
2 0.103 ms 10.282 ms 10.179 ms
4 0.104 ms 10.068 ms 9.964 ms
Total elapsed time: 0.07 seconds (9.26 ms/request)
OK
```
### Monitoring with Nagios, Icinga, or similar software
......
......@@ -55,6 +55,7 @@ connectTo = None
multistreams = False
sync = False
silent = False
show_time = False
check = False
mandatory_level = None
check_additional = True
......@@ -585,10 +586,11 @@ class ConnectionDoH(Connection):
def read_result_handle(self, handle):
self.receive(handle)
handle.request.check_response()
print(f'{handle.request.i:3d}', end=' ')
print(f'{handle.pretime * 1000:6.3f} ms', end=' ')
print(f'{handle.time * 1000:6.3f} ms', end=' ')
print(f'{(handle.time - handle.pretime) * 1000:6.3f} ms')
if show_time:
print(f'{handle.request.i:3d}', end=' ')
print(f'{handle.pretime * 1000:8.3f} ms', end=' ')
print(f'{handle.time * 1000:8.3f} ms', end=' ')
print(f'{(handle.time - handle.pretime) * 1000:8.3f} ms')
if not silent:
print("Return code %s (%.2f ms):" % (handle.request.rcode,
(handle.time - handle.pretime) * 1000))
......@@ -836,7 +838,7 @@ if not monitoring:
optlist, args = getopt.getopt (sys.argv[1:], "hvPkeV:r:f:d:t46",
["help", "verbose", "dot", "head",
"insecure", "POST", "vhost=", "multistreams",
"sync", "silent",
"sync", "silent", "time",
"dnssec", "noedns", "ecs", "repeat=", "file=", "delay=",
"key=", "nosni",
"v4only", "v6only",
......@@ -863,6 +865,8 @@ if not monitoring:
sync = True
elif option == "--silent":
silent = True
elif option == "--time":
show_time = True
elif option == "--dnssec":
dnssec = True
elif option == "--nosni":
......@@ -922,6 +926,9 @@ if not monitoring:
if silent and not multistreams:
usage("--silent cannot be used without --multistreams")
sys.exit(1)
if show_time and not multistreams:
usage("--time cannot be used without --multistreams")
sys.exit(1)
if not edns and not no_ecs:
usage("ECS requires EDNS")
sys.exit(1)
......
Supports Markdown
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