Skip to content
Advertisement

Analyze log file of dnsmasq

I current facing a problem. When I open the dnsmasq log, it looks like this:

JavaScript

It’s very difficult for us to analyze it. Anybody have a idea to only show the queried domain which should be like this?

JavaScript

However I tried this: http://www.tannerwilliamson.com/analyzing-dnsmasq-log-with-awk/1610/

and its output i like this:

JavaScript

It’s little bit different from what I want. Anybody could help me? Thanks for the help!

Advertisement

Answer

A simple awk script could be sufficient for this, provided the logfile you showed remains intact.

JavaScript

will produce the output as

JavaScript

The logic is simple, it parses each entry in column six and adds it into the array seen and prints the element only if it is not seen before.

P.S. If the order of the columns in the log file are subject to change in the future the awk command may not work, as it purely relies on the index of the column to get the results.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement