diff --git a/docker/routlin-dash/app/pages/overview/content.json b/docker/routlin-dash/app/pages/overview/content.json index bbd75e8..16a163e 100644 --- a/docker/routlin-dash/app/pages/overview/content.json +++ b/docker/routlin-dash/app/pages/overview/content.json @@ -196,6 +196,18 @@ { "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"}, @@ -214,18 +226,6 @@ {"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"}, @@ -234,23 +234,15 @@ }, { "cells": [ - {"type": "grid_label", "text": "DNS Providers"}, - {"type": "grid_value", "text": "%OVERVIEW_UPSTREAM_SERVERS%"} - ] - }, - { - "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%"} + {"type": "grid_label", "text": "Cache Evictions"}, + {"type": "grid_value", "text": "%DNS_STAT_CACHE_EVICTIONS%"} ] } ] + }, + { + "type": "raw_html", + "html": "%DNS_PROVIDERS_TABLE%" } ] } diff --git a/docker/routlin-dash/app/pages/overview/view.py b/docker/routlin-dash/app/pages/overview/view.py index c13da0d..a7c963e 100644 --- a/docker/routlin-dash/app/pages/overview/view.py +++ b/docker/routlin-dash/app/pages/overview/view.py @@ -1,5 +1,6 @@ import json import os +from datetime import datetime import config_utils import factory from pages.ddns.view import public_ip_info @@ -8,9 +9,61 @@ from pages.dhcpleases.view import live_dhcp_leases METRICS_FILE = f'{config_utils.CONFIGS_DIR}/.dns-metrics' +def _fmt_since(since_str): + try: + dt = datetime.strptime(since_str, '%Y-%m-%d %H:%M:%S') + now = datetime.now() + rel = config_utils.relative_time(int(dt.timestamp()), int(now.timestamp())) + if dt.date() == now.date(): + return f'Today at {dt.strftime("%H:%M")} ({rel} ago)' + return f'{dt.strftime("%Y-%m-%d")} ({rel} ago)' + except Exception: + return since_str + + +def _fmt_updated(updated_str): + try: + dt = datetime.strptime(updated_str, '%Y-%m-%d %H:%M:%S') + now = datetime.now() + rel = config_utils.relative_time(int(dt.timestamp()), int(now.timestamp())) + return f'{rel} ago' + except Exception: + return updated_str + + +def _dns_providers_table(servers): + if not servers: + return '
No upstream server data recorded yet.
' + rows = [] + for s in servers: + latency = f'{s["avg_latency_ms"]} ms' if s.get("avg_latency_ms") else '-' + rows.append( + f'| Server | ' + 'Queries Sent | ' + 'Retried | ' + 'Failed | ' + 'NXDOMAIN | ' + 'Avg Latency | ' + '
|---|