Giter Club home page Giter Club logo

bind-query-log-statistics's People

Contributors

matty9191 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bind-query-log-statistics's Issues

Bind 9.11 Log Format

After a recent upgrade of my systems to Ubuntu 18.04 which provides Bind 9.11.3 I found that your script wouldn't parse the log files. I fixed the issue by adding the following to process_query at line 179:

"""
# Bind 9.11
04-Jun-2018 14:48:15.540 queries: info: client @0x7fda1d74e7d0 \
192.168.1.6#60844 (prefetch.net): query: prefetch.net IN A +E(0)D \
(192.168.1.250)
"""
    elif len(chopped) == 10:
        timestamp = chopped[0] + " " + chopped[1]
        """ Had to change the item reference in chopped[] below because they added a memory location
             in the middle of everything, instead of putting it at the end
        """
        client_ip = chopped[3].split("#")[0]
        """ That also shifted the rr_type over
        """
        rr_type = chopped[7]
        dns_question = chopped[4]

I hope this helps.

Bind 9.13 Format

` # Bind 9.13 (chopped = 10)
18-Nov-2023 00:47:15.587 client @0x7f601c0be800 192.168.0.192#56000 (www.google.com):
query: www.google.com IN A + (192.168.0.91)

elif len(chopped) == 10:
    timestamp = chopped[0] + " " + chopped[1]
    client_ip = chopped[3].split("#")[0]
    rr_type = chopped[7]
    dns_question = chopped[5]

`

Wrong type for "--count" arg

The "--count" argument does not really work:

# python /var/tmp/bind-query-log-stats.py --count 10 /var/log/dns/query.log
Processing logfile /var/log/dns/query.log

<skip>

Top  ['10']  DNS names requested:
Traceback (most recent call last):
  File "/var/tmp/bind-query-log-stats.py", line 265, in <module>
    print_top_dns_requests(COUNT)
  File "/var/tmp/bind-query-log-stats.py", line 97, in print_top_dns_requests
    for query, _ in Counter(DNS_QUERIES).most_common(num_print):
  File "/usr/lib64/python2.7/collections.py", line 462, in most_common
    return _heapq.nlargest(n, self.iteritems(), key=_itemgetter(1))
  File "/usr/lib64/python2.7/heapq.py", line 465, in nlargest
    result = _nlargest(n, it)
TypeError: an integer is required

socket.gaierror: [Errno -2] Name or service not known

Hello,

I am using your script like this:
./bind-query-log-stats.py /var/log/bind9/query.log
and I get this output:

Processing logfile /var/log/bind9/query.log

Summary for 18-Jan-2018 07:54:51.603 - 18-Jan-2018 08:32:27.532

Total DNS_QUERIES processed : 2583
  +E     records requested : 2583

Top  100  DNS names requested:
  IN : 2583

Top  100  DNS clients:
Traceback (most recent call last):
  File "./bind-query-log-stats.py", line 268, in <module>
    print_top_dns_clients(COUNT)
  File "./bind-query-log-stats.py", line 105, in print_top_dns_clients
    client_name = socket.gethostbyaddr(client_ip)[0]
socket.gaierror: [Errno -2] Name or service not known

My log format is like this:
tail -1 /var/log/bind9/query.log

18-Jan-2018 08:36:30.387 client 173.90.213.148#9307 (edu.za): query: edu.za IN ANY +E (172.31.7.30)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.