Development

This commit is contained in:
Matthew Grotke 2026-06-09 15:49:07 -04:00
parent 836f4557f2
commit 46afed7965
2 changed files with 19 additions and 7 deletions

View file

@ -34,6 +34,8 @@ import sys
import logging
from pathlib import Path
import mod_metrics as metrics
SCRIPT_DIR = Path(__file__).parent
CONFIG_FILE = SCRIPT_DIR / "config.json"
CACHE_SERVICE_FILE = SCRIPT_DIR / ".ddns-last-service"
@ -650,5 +652,14 @@ def main():
rotate_radius_log(cfg.get("_radius", {}))
refresh_arp_cache(cfg)
try:
with open(CONFIG_FILE) as f:
full_cfg = json.load(f)
new_metrics = metrics.collect_metrics(full_cfg)
if new_metrics:
metrics.update_metrics_file(new_metrics)
except Exception as e:
log.warning(f"DNS metrics collection failed: {e}")
if __name__ == "__main__":
main()

View file

@ -6,7 +6,9 @@ and accumulates lifetime totals in a JSON file.
"""
import json
import os
import re
import signal
import subprocess
import time
from datetime import datetime
@ -42,14 +44,13 @@ def collect_metrics(data):
any_running = False
for vlan in data["vlans"]:
svc = shared.vlan_service_name(vlan, validation.derive_interface(vlan, data))
result = subprocess.run(
["systemctl", "kill", "--signal=SIGUSR1", svc],
capture_output=True, text=True
)
if result.returncode != 0:
pid_file = shared.vlan_pid_file(vlan)
try:
pid = int(pid_file.read_text().strip())
os.kill(pid, signal.SIGUSR1)
any_running = True
except Exception:
continue
any_running = True
if not any_running:
print("No dnsmasq instances are running.")