period picker
This commit is contained in:
29
collector.py
29
collector.py
@@ -137,20 +137,32 @@ class GPONCollector:
|
||||
uptime_str = uptime_match.group(1).strip()
|
||||
logger.debug(f"[WEB] Raw uptime: '{uptime_str}'")
|
||||
|
||||
days_match = re.search(r'(\d+)\s*days?,\s*(\d+):(\d+)', uptime_str)
|
||||
if days_match:
|
||||
days = int(days_match.group(1))
|
||||
hours = int(days_match.group(2))
|
||||
minutes = int(days_match.group(3))
|
||||
days_min_match = re.search(r'(\d+)\s*days?,\s*(\d+)\s*min', uptime_str, re.IGNORECASE)
|
||||
if days_min_match:
|
||||
days = int(days_min_match.group(1))
|
||||
minutes = int(days_min_match.group(2))
|
||||
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)
|
||||
logger.info(f"[WEB] Uptime: {days}d {hours}h {minutes}m = {data['uptime']}s")
|
||||
else:
|
||||
time_match = re.search(r'(\d+):(\d+)', uptime_str)
|
||||
if time_match:
|
||||
|
||||
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:
|
||||
logger.warning(f"[WEB] Could not parse uptime: '{uptime_str}'")
|
||||
else:
|
||||
@@ -205,6 +217,7 @@ class GPONCollector:
|
||||
logger.error(f"[WEB] Web scraping failed: {e}")
|
||||
return {}
|
||||
|
||||
|
||||
async def _collect_omci_async(self):
|
||||
try:
|
||||
reader, writer = await asyncio.wait_for(
|
||||
|
||||
Reference in New Issue
Block a user