~phlash/sinkhole

fc1f23c832690c9faf535a581515beba7786da4a — Phil Ashby 3 months ago 2758f9b
report total hits per run
1 files changed, 3 insertions(+), 1 deletions(-)

M etc/cron.daily/x1report-hosts-blocked
M etc/cron.daily/x1report-hosts-blocked => etc/cron.daily/x1report-hosts-blocked +3 -1
@@ 36,6 36,7 @@ if os.access(SINKHOLE_CONFIG, os.R_OK):
                SINKHOLE_TOPSIZE=int(val.strip())

hits = {}
total = 0
if os.access(SINKHOLE_LOG, os.R_OK):
    with open(SINKHOLE_LOG, 'r') as f:
        for line in f:


@@ 44,6 45,7 @@ if os.access(SINKHOLE_LOG, os.R_OK):
                continue
            if not chk.startswith('is'):
                continue
            total += 1
            if hit in hits:
                hits[hit] += 1
            else:


@@ 80,7 82,7 @@ def update(k, v):
stats = {k: update(k,v) for (k,v) in stats.items()}
#print(f"Updated({len(stats)}):", stats)

print(f"Blocked DNS lookups from log {SINKHOLE_LOG} ({len(hits)} hosts), suppressed by {SINKHOLE_SUPPFILE} ({len(stats)} entries) for {SINKHOLE_SUPPDAYS} days")
print(f"Blocked DNS lookups from log {SINKHOLE_LOG} ({total} hits for {len(hits)} hosts), suppressed by {SINKHOLE_SUPPFILE} ({len(stats)} entries) for {SINKHOLE_SUPPDAYS} days")
for hit in sorted(hits, key=hits.get, reverse=True):
    if not hit in suppress:
        print(f"{hits[hit]} {hit}")