diff --git a/CHANGES b/CHANGES index bb49c971f3..645a2c9684 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +6163. [func] Add option to dnstap-read to use timestamps in + milliseconds (thanks to Oliver Ford). [GL #2360] + 6162. [placeholder] 6161. [bug] Fix log file rotation when using absolute path as diff --git a/bin/tools/dnstap-read.c b/bin/tools/dnstap-read.c index fc924ad621..bc5f69d370 100644 --- a/bin/tools/dnstap-read.c +++ b/bin/tools/dnstap-read.c @@ -57,6 +57,7 @@ bool memrecord = false; bool printmessage = false; bool hexmessage = false; bool yaml = false; +bool timestampmillis = false; const char *program = "dnstap-read"; @@ -90,6 +91,8 @@ usage(void) { fprintf(stderr, "dnstap-read [-mpxy] [filename]\n"); fprintf(stderr, "\t-m\ttrace memory allocations\n"); fprintf(stderr, "\t-p\tprint the full DNS message\n"); + fprintf(stderr, + "\t-t\tprint long timestamps with millisecond precision\n"); fprintf(stderr, "\t-x\tuse hex format to print DNS message\n"); fprintf(stderr, "\t-y\tprint YAML format (implies -p)\n"); } @@ -231,13 +234,21 @@ print_yaml(dns_dtdata_t *dt) { if (!isc_time_isepoch(&dt->qtime)) { char buf[100]; - isc_time_formatISO8601(&dt->qtime, buf, sizeof(buf)); + if (timestampmillis) { + isc_time_formatISO8601ms(&dt->qtime, buf, sizeof(buf)); + } else { + isc_time_formatISO8601(&dt->qtime, buf, sizeof(buf)); + } printf(" query_time: !!timestamp %s\n", buf); } if (!isc_time_isepoch(&dt->rtime)) { char buf[100]; - isc_time_formatISO8601(&dt->rtime, buf, sizeof(buf)); + if (timestampmillis) { + isc_time_formatISO8601ms(&dt->rtime, buf, sizeof(buf)); + } else { + isc_time_formatISO8601(&dt->rtime, buf, sizeof(buf)); + } printf(" response_time: !!timestamp %s\n", buf); } @@ -330,7 +341,7 @@ main(int argc, char *argv[]) { dns_dthandle_t *handle = NULL; int rv = 0, ch; - while ((ch = isc_commandline_parse(argc, argv, "mpxy")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "mptxy")) != -1) { switch (ch) { case 'm': isc_mem_debugging |= ISC_MEM_DEBUGRECORD; @@ -339,6 +350,9 @@ main(int argc, char *argv[]) { case 'p': printmessage = true; break; + case 't': + timestampmillis = true; + break; case 'x': hexmessage = true; break; diff --git a/bin/tools/dnstap-read.rst b/bin/tools/dnstap-read.rst index a5956825fc..38e2838a82 100644 --- a/bin/tools/dnstap-read.rst +++ b/bin/tools/dnstap-read.rst @@ -43,6 +43,9 @@ Options This option prints the text form of the DNS message that was encapsulated in the ``dnstap`` frame, after printing the ``dnstap`` data. +.. option:: -t + + This option prints long timestamps with millisecond precision. .. option:: -x This option prints a hex dump of the wire form diff --git a/doc/notes/notes-current.rst b/doc/notes/notes-current.rst index bb0553723a..fd3c957985 100644 --- a/doc/notes/notes-current.rst +++ b/doc/notes/notes-current.rst @@ -20,7 +20,8 @@ Security Fixes New Features ~~~~~~~~~~~~ -- None. +- ``dnstap-read`` can now print long timestamps with millisecond precision. + :gl:`#2360` Removed Features ~~~~~~~~~~~~~~~~