update maybe
This commit is contained in:
@ -780,17 +780,14 @@ class SystemHealthMonitor:
|
||||
|
||||
def _parse_size(self, size_str: str) -> float:
|
||||
"""Parse size string with units to bytes"""
|
||||
logger.debug(f"Parsing size string: {size_str}")
|
||||
|
||||
# Handle empty or invalid input
|
||||
if not size_str or not isinstance(size_str, str):
|
||||
return 0.0
|
||||
|
||||
# Remove any whitespace and handle M/G/T units
|
||||
size_str = size_str.strip()
|
||||
|
||||
# Remove any whitespace and convert to uppercase for consistent handling
|
||||
size_str = size_str.strip().upper()
|
||||
|
||||
# Handle values with decimal points (like 192.2M)
|
||||
match = re.match(r'^([\d.]+)\s*([KMGT])?', size_str)
|
||||
match = re.match(r'^([\d.]+)\s*([KMGT])?B?$', size_str)
|
||||
if match:
|
||||
value = float(match.group(1))
|
||||
unit = match.group(2) if match.group(2) else 'B'
|
||||
@ -803,16 +800,9 @@ class SystemHealthMonitor:
|
||||
'T': 1024**4
|
||||
}
|
||||
|
||||
result = value * multipliers[unit]
|
||||
logger.debug(f"Parsed value: {value}, Unit: {unit}, Result: {result}")
|
||||
return result
|
||||
|
||||
# If no match, try to convert directly to float
|
||||
try:
|
||||
return float(size_str)
|
||||
except ValueError:
|
||||
logger.debug(f"Could not parse size string: {size_str}")
|
||||
return 0.0
|
||||
return value * multipliers[unit]
|
||||
|
||||
return 0.0
|
||||
|
||||
def _is_physical_disk(self, device_path):
|
||||
"""
|
||||
@ -1423,6 +1413,7 @@ class SystemHealthMonitor:
|
||||
'available': parts[3], # Avail
|
||||
'usage_percent': float(parts[4].rstrip('%')) # Use%
|
||||
}
|
||||
container_info['filesystems'].append(filesystem)
|
||||
logger.debug(f"Usage percent before threshold check: {usage_percent}")
|
||||
logger.debug(f"LXC_WARNING threshold: {self.CONFIG['THRESHOLDS']['LXC_WARNING']}")
|
||||
logger.debug(f"LXC_CRITICAL threshold: {self.CONFIG['THRESHOLDS']['LXC_CRITICAL']}")
|
||||
@ -1446,9 +1437,7 @@ class SystemHealthMonitor:
|
||||
lxc_health['status'] = 'WARNING'
|
||||
issue = f"LXC {vmid} high storage usage: {filesystem['usage_percent']}% on {filesystem['mountpoint']}"
|
||||
lxc_health['issues'].append(issue)
|
||||
|
||||
container_info['filesystems'].append(filesystem)
|
||||
|
||||
|
||||
logger.debug(f"Filesystem details: {filesystem}")
|
||||
logger.debug(f"Usage percent: {filesystem['usage_percent']}%")
|
||||
logger.debug(f"LXC_WARNING threshold: {self.CONFIG['THRESHOLDS']['LXC_WARNING']}%")
|
||||
|
||||
Reference in New Issue
Block a user