feat: add adguard+scrutiny to aggregator

This commit is contained in:
2026-04-05 21:12:22 +00:00
parent 2c87ae2d6e
commit 734d0176d4
@@ -6,9 +6,11 @@ from datetime import datetime, timezone
from functools import lru_cache from functools import lru_cache
from typing import Iterable from typing import Iterable
from app.clients.adguard_client import AdGuardClient
from app.clients.beszel_client import BeszelClient from app.clients.beszel_client import BeszelClient
from app.clients.docker_proxy_client import DockerProxyClient from app.clients.docker_proxy_client import DockerProxyClient
from app.clients.home_assistant_client import HomeAssistantClient from app.clients.home_assistant_client import HomeAssistantClient
from app.clients.scrutiny_client import ScrutinyClient
from app.clients.uptime_kuma_client import UptimeKumaClient from app.clients.uptime_kuma_client import UptimeKumaClient
from app.config import Settings, get_settings from app.config import Settings, get_settings
from app.models.common import DiskStatus, HealthStatus, OverallStatus from app.models.common import DiskStatus, HealthStatus, OverallStatus
@@ -27,10 +29,12 @@ from app.models.services import (
ServicesUptimeKumaSummary, ServicesUptimeKumaSummary,
) )
from app.models.sources import ( from app.models.sources import (
AdGuardSnapshot,
BeszelDiskMetric, BeszelDiskMetric,
BeszelSystemSnapshot, BeszelSystemSnapshot,
DockerSnapshot, DockerSnapshot,
HomeAssistantSnapshot, HomeAssistantSnapshot,
ScrutinySnapshot,
UptimeKumaMonitor, UptimeKumaMonitor,
UptimeKumaSnapshot, UptimeKumaSnapshot,
) )
@@ -58,6 +62,8 @@ class AggregatorService:
docker_client: DockerProxyClient, docker_client: DockerProxyClient,
uptime_kuma_client: UptimeKumaClient, uptime_kuma_client: UptimeKumaClient,
home_assistant_client: HomeAssistantClient, home_assistant_client: HomeAssistantClient,
adguard_client: AdGuardClient,
scrutiny_client: ScrutinyClient,
) -> None: ) -> None:
self.settings = settings self.settings = settings
self.cache = cache self.cache = cache
@@ -65,6 +71,8 @@ class AggregatorService:
self.docker_client = docker_client self.docker_client = docker_client
self.uptime_kuma_client = uptime_kuma_client self.uptime_kuma_client = uptime_kuma_client
self.home_assistant_client = home_assistant_client self.home_assistant_client = home_assistant_client
self.adguard_client = adguard_client
self.scrutiny_client = scrutiny_client
async def get_system(self) -> SystemResponse: async def get_system(self) -> SystemResponse:
return await self.cache.get_or_load( return await self.cache.get_or_load(
@@ -87,6 +95,20 @@ class AggregatorService:
self._build_services, self._build_services,
) )
async def get_adguard(self) -> AdGuardSnapshot:
return await self.cache.get_or_load(
"adguard",
self.settings.cache_ttl_services_seconds,
self.adguard_client.fetch_stats,
)
async def get_scrutiny(self) -> ScrutinySnapshot:
return await self.cache.get_or_load(
"scrutiny",
self.settings.cache_ttl_storage_seconds,
self.scrutiny_client.fetch_summary,
)
async def get_overview(self) -> OverviewResponse: async def get_overview(self) -> OverviewResponse:
return await self.cache.get_or_load( return await self.cache.get_or_load(
"overview", "overview",
@@ -380,4 +402,6 @@ def get_aggregator_service() -> AggregatorService:
docker_client=DockerProxyClient(settings), docker_client=DockerProxyClient(settings),
uptime_kuma_client=UptimeKumaClient(settings), uptime_kuma_client=UptimeKumaClient(settings),
home_assistant_client=HomeAssistantClient(settings), home_assistant_client=HomeAssistantClient(settings),
adguard_client=AdGuardClient(settings),
scrutiny_client=ScrutinyClient(settings),
) )