Add admin panel

This commit is contained in:
2025-12-19 02:07:25 +07:00
parent 8e634994bd
commit 481bdabaa8
40 changed files with 3526 additions and 112 deletions

View File

@@ -249,8 +249,8 @@ def get_ssl_info(domain: str) -> Optional[dict]:
return None
def cleanup_old_metrics(days: int = 7):
"""Delete metrics older than specified days."""
def cleanup_old_metrics(days: int = 1):
"""Delete metrics older than specified days (default: 24 hours)."""
conn = get_connection()
cursor = conn.cursor()
cutoff = datetime.now() - timedelta(days=days)

View File

@@ -19,7 +19,7 @@ FRONTEND_URL = os.getenv("FRONTEND_URL", "http://frontend:80")
BOT_URL = os.getenv("BOT_URL", "http://bot:8080")
EXTERNAL_URL = os.getenv("EXTERNAL_URL", "") # Public URL for external checks
PUBLIC_URL = os.getenv("PUBLIC_URL", "") # Public HTTPS URL for SSL checks
CHECK_INTERVAL = int(os.getenv("CHECK_INTERVAL", "30"))
CHECK_INTERVAL = int(os.getenv("CHECK_INTERVAL", "600")) # 10 minutes
# Initialize monitor
monitor = ServiceMonitor()
@@ -46,11 +46,11 @@ async def periodic_health_check():
async def periodic_cleanup():
"""Background task to cleanup old metrics (daily)."""
"""Background task to cleanup old metrics (hourly)."""
while True:
await asyncio.sleep(86400) # 24 hours
await asyncio.sleep(3600) # 1 hour
try:
deleted = cleanup_old_metrics(days=7)
deleted = cleanup_old_metrics(days=1) # Keep only last 24 hours
print(f"Cleaned up {deleted} old metrics")
except Exception as e:
print(f"Cleanup error: {e}")