period picker

This commit is contained in:
Mateusz Gruszczyński
2026-01-03 20:00:57 +01:00
parent 559bfda091
commit bea108c593

View File

@@ -137,22 +137,34 @@ class GPONCollector:
uptime_str = uptime_match.group(1).strip() uptime_str = uptime_match.group(1).strip()
logger.debug(f"[WEB] Raw uptime: '{uptime_str}'") logger.debug(f"[WEB] Raw uptime: '{uptime_str}'")
days_match = re.search(r'(\d+)\s*days?,\s*(\d+):(\d+)', uptime_str) days_min_match = re.search(r'(\d+)\s*days?,\s*(\d+)\s*min', uptime_str, re.IGNORECASE)
if days_match: if days_min_match:
days = int(days_match.group(1)) days = int(days_min_match.group(1))
hours = int(days_match.group(2)) minutes = int(days_min_match.group(2))
minutes = int(days_match.group(3)) data['uptime'] = (days * 86400) + (minutes * 60)
logger.info(f"[WEB] Uptime: {days}d {minutes}m = {data['uptime']}s")
elif days_hm_match := re.search(r'(\d+)\s*days?,\s*(\d+):(\d+)', uptime_str):
days = int(days_hm_match.group(1))
hours = int(days_hm_match.group(2))
minutes = int(days_hm_match.group(3))
data['uptime'] = (days * 86400) + (hours * 3600) + (minutes * 60) data['uptime'] = (days * 86400) + (hours * 3600) + (minutes * 60)
logger.info(f"[WEB] Uptime: {days}d {hours}h {minutes}m = {data['uptime']}s") logger.info(f"[WEB] Uptime: {days}d {hours}h {minutes}m = {data['uptime']}s")
elif hm_match := re.search(r'(\d+)\s*h(?:our)?[s]?,?\s*(\d+)\s*min', uptime_str, re.IGNORECASE):
hours = int(hm_match.group(1))
minutes = int(hm_match.group(2))
data['uptime'] = (hours * 3600) + (minutes * 60)
logger.info(f"[WEB] Uptime: {hours}h {minutes}m = {data['uptime']}s")
elif time_match := re.search(r'^(\d+):(\d+)$', uptime_str):
hours = int(time_match.group(1))
minutes = int(time_match.group(2))
data['uptime'] = (hours * 3600) + (minutes * 60)
logger.info(f"[WEB] Uptime: {hours}h {minutes}m = {data['uptime']}s")
else: else:
time_match = re.search(r'(\d+):(\d+)', uptime_str) logger.warning(f"[WEB] Could not parse uptime: '{uptime_str}'")
if time_match:
hours = int(time_match.group(1))
minutes = int(time_match.group(2))
data['uptime'] = (hours * 3600) + (minutes * 60)
logger.info(f"[WEB] Uptime: {hours}h {minutes}m = {data['uptime']}s")
else:
logger.warning(f"[WEB] Could not parse uptime: '{uptime_str}'")
else: else:
logger.warning("[WEB] Uptime not found in status.asp") logger.warning("[WEB] Uptime not found in status.asp")
@@ -205,6 +217,7 @@ class GPONCollector:
logger.error(f"[WEB] Web scraping failed: {e}") logger.error(f"[WEB] Web scraping failed: {e}")
return {} return {}
async def _collect_omci_async(self): async def _collect_omci_async(self):
try: try:
reader, writer = await asyncio.wait_for( reader, writer = await asyncio.wait_for(