Development

This commit is contained in:
Matthew Grotke 2026-06-09 21:49:29 -04:00
parent e4629fd164
commit 0806656d68
2 changed files with 12 additions and 11 deletions

View file

@ -20,7 +20,7 @@ from datetime import date
import mod_shared as shared
import mod_validation as validation
DB_FILE = shared.SCRIPT_DIR / ".dns-metrics2"
DB_FILE = shared.SCRIPT_DIR / ".dns-metrics"
# ===================================================================
@ -33,6 +33,7 @@ def open_db():
con.executescript('''
CREATE TABLE IF NOT EXISTS daily_totals (
date TEXT PRIMARY KEY,
last_updated INTEGER,
queries_forwarded INTEGER NOT NULL DEFAULT 0,
queries_answered_locally INTEGER NOT NULL DEFAULT 0,
queries_authoritative INTEGER NOT NULL DEFAULT 0,
@ -162,12 +163,13 @@ def update_metrics_db(new_metrics):
con.execute('''
INSERT INTO daily_totals(
date,
date, last_updated,
queries_forwarded, queries_answered_locally, queries_authoritative,
cache_reused, tcp_hwm, tcp_max_allowed, pool_memory_max,
dnssec_subqueries_hwm, dnssec_crypto_hwm, dnssec_sig_fails_hwm
) VALUES (?,?,?,?,?,?,?,?,?,?,?)
) VALUES (?,strftime('%s','now'),?,?,?,?,?,?,?,?,?,?)
ON CONFLICT(date) DO UPDATE SET
last_updated = strftime('%s','now'),
queries_forwarded = queries_forwarded + excluded.queries_forwarded,
queries_answered_locally = queries_answered_locally + excluded.queries_answered_locally,
queries_authoritative = queries_authoritative + excluded.queries_authoritative,