Strip out count dictionary and remove incremental operations.

This commit is contained in:
Dan Schaper 2016-10-02 11:05:56 -07:00
parent 9f94570fff
commit 185efaf82e

View file

@ -106,21 +106,18 @@ def convert_date(ds):
def parse_query(query):
m = q_re.match(query)
if m is not None:
counts['qc'] += 1
add_query(m.group(4), m.group(2), m.group(3), m.group(1))
def parse_forward(query):
m = f_re.match(query)
if m is not None:
counts['fc'] += 1
add_forward(m.group(3), m.group(2), m.group(1))
def parse_reply(query):
m = r_re.match(query)
if m is not None:
counts['rc'] += 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]
counts = {'lc': 0, 'qc': 0, 'fc': 0, 'rc': 0, 'bc':0}
# Create the SQLite connection
conn = sqlite3.connect('/etc/pihole/pihole.db')
c = conn.cursor()
@ -159,10 +154,6 @@ create_tables()
# Parse the log file.
for line in open(logfile):
line = line.rstrip()
counts['lc'] += 1
if (counts['lc'] % 10000) == 0:
conn.commit()
if ': query[' in line:
parse_query(line)
@ -173,7 +164,4 @@ for line in open(logfile):
elif (': reply ' in line) or (': cached ' in line):
parse_reply(line)
else:
counts['bc'] += 1
conn.commit()