Development

This commit is contained in:
Matthew Grotke 2026-06-09 21:28:38 -04:00
parent e9166d8a6a
commit 0983e14de4
7 changed files with 494 additions and 160 deletions

View file

@ -99,5 +99,75 @@
}
]
}
,
{
"type": "card",
"label": "DNS Statistics",
"items": [
{
"type": "grid",
"rows": [
{
"cells": [
{"type": "grid_label", "text": "Tracking Since"},
{"type": "grid_value", "text": "%DNS_METRICS_SINCE%"}
]
},
{
"cells": [
{"type": "grid_label", "text": "Last Updated"},
{"type": "grid_value", "text": "%DNS_METRICS_UPDATED%"}
]
},
{
"cells": [
{"type": "grid_label", "text": "Total Queries"},
{"type": "grid_value", "text": "%DNS_STAT_QUERIES%"}
]
},
{
"cells": [
{"type": "grid_label", "text": "Cache Hits"},
{"type": "grid_value", "text": "%DNS_STAT_HITS% (%DNS_STAT_HIT_RATE% hit rate)"}
]
},
{
"cells": [
{"type": "grid_label", "text": "Forwarded to Upstream"},
{"type": "grid_value", "text": "%DNS_STAT_FORWARDED%"}
]
},
{
"cells": [
{"type": "grid_label", "text": "Authoritative Answers"},
{"type": "grid_value", "text": "%DNS_STAT_AUTH%"}
]
},
{
"cells": [
{"type": "grid_label", "text": "TCP Peak"},
{"type": "grid_value", "text": "%DNS_STAT_TCP_PEAK%"}
]
},
{
"cells": [
{"type": "grid_label", "text": "Cache Capacity"},
{"type": "grid_value", "text": "%DNS_CACHE_SIZE% entries"}
]
},
{
"cells": [
{"type": "grid_label", "text": "Cache Evictions"},
{"type": "grid_value", "text": "%DNS_STAT_CACHE_EVICTIONS%"}
]
}
]
},
{
"type": "raw_html",
"html": "%DNS_PROVIDERS_TABLE%"
}
]
}
]
}

View file

@ -1,12 +1,25 @@
import json
import config_utils
from pages.overview.view import load_dns_metrics, _dns_providers_table
def collect_tokens(cfg):
tokens = config_utils.collect_layout_tokens(cfg)
dns = cfg.get('upstream_dns', {})
dns = cfg.get('upstream_dns', {})
servers = dns.get('upstream_servers', [])
tokens['DNS_STRICT_ORDER'] = 'true' if dns.get('strict_order') else 'false'
tokens['DNS_CACHE_SIZE'] = str(dns.get('cache_size', '-'))
tokens['DNS_STRICT_ORDER'] = 'true' if dns.get('strict_order') else 'false'
tokens['DNS_CACHE_SIZE'] = str(dns.get('cache_size', '-'))
tokens['DNS_UPSTREAM_SERVERS_JSON'] = json.dumps(servers)
dns_stats = load_dns_metrics()
tokens['DNS_METRICS_SINCE'] = dns_stats['since']
tokens['DNS_METRICS_UPDATED'] = dns_stats['updated']
tokens['DNS_STAT_QUERIES'] = dns_stats['queries']
tokens['DNS_STAT_HITS'] = dns_stats['hits']
tokens['DNS_STAT_HIT_RATE'] = dns_stats['hit_rate']
tokens['DNS_STAT_FORWARDED'] = dns_stats['forwarded']
tokens['DNS_STAT_AUTH'] = dns_stats['auth']
tokens['DNS_STAT_TCP_PEAK'] = dns_stats['tcp_peak']
tokens['DNS_STAT_CACHE_EVICTIONS'] = dns_stats['cache_evictions']
tokens['DNS_PROVIDERS_TABLE'] = _dns_providers_table(dns_stats['servers'])
return tokens