mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-20 22:30:13 +00:00
Strip out count dictionary and remove incremental operations.
This commit is contained in:
parent
9f94570fff
commit
185efaf82e
1 changed files with 0 additions and 12 deletions
|
@ -106,21 +106,18 @@ def convert_date(ds):
|
||||||
def parse_query(query):
|
def parse_query(query):
|
||||||
m = q_re.match(query)
|
m = q_re.match(query)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
counts['qc'] += 1
|
|
||||||
add_query(m.group(4), m.group(2), m.group(3), m.group(1))
|
add_query(m.group(4), m.group(2), m.group(3), m.group(1))
|
||||||
|
|
||||||
|
|
||||||
def parse_forward(query):
|
def parse_forward(query):
|
||||||
m = f_re.match(query)
|
m = f_re.match(query)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
counts['fc'] += 1
|
|
||||||
add_forward(m.group(3), m.group(2), m.group(1))
|
add_forward(m.group(3), m.group(2), m.group(1))
|
||||||
|
|
||||||
|
|
||||||
def parse_reply(query):
|
def parse_reply(query):
|
||||||
m = r_re.match(query)
|
m = r_re.match(query)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
counts['rc'] += 1
|
|
||||||
add_reply(m.group(4), m.group(2), m.group(3), m.group(1))
|
add_reply(m.group(4), m.group(2), m.group(3), m.group(1))
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,8 +145,6 @@ if len(sys.argv) != 2:
|
||||||
|
|
||||||
logfile = sys.argv[1]
|
logfile = sys.argv[1]
|
||||||
|
|
||||||
counts = {'lc': 0, 'qc': 0, 'fc': 0, 'rc': 0, 'bc':0}
|
|
||||||
|
|
||||||
# Create the SQLite connection
|
# Create the SQLite connection
|
||||||
conn = sqlite3.connect('/etc/pihole/pihole.db')
|
conn = sqlite3.connect('/etc/pihole/pihole.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
@ -159,10 +154,6 @@ create_tables()
|
||||||
# Parse the log file.
|
# Parse the log file.
|
||||||
for line in open(logfile):
|
for line in open(logfile):
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
counts['lc'] += 1
|
|
||||||
|
|
||||||
if (counts['lc'] % 10000) == 0:
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
if ': query[' in line:
|
if ': query[' in line:
|
||||||
parse_query(line)
|
parse_query(line)
|
||||||
|
@ -173,7 +164,4 @@ for line in open(logfile):
|
||||||
elif (': reply ' in line) or (': cached ' in line):
|
elif (': reply ' in line) or (': cached ' in line):
|
||||||
parse_reply(line)
|
parse_reply(line)
|
||||||
|
|
||||||
else:
|
|
||||||
counts['bc'] += 1
|
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue