debug
This commit is contained in:
@ -41,6 +41,8 @@ class SystemHealthMonitor:
|
||||
'THRESHOLDS': {
|
||||
'DISK_CRITICAL': 90,
|
||||
'DISK_WARNING': 80,
|
||||
'LXC_CRITICAL': 90,
|
||||
'LXC_WARNING': 80,
|
||||
'CPU_WARNING': 80,
|
||||
'TEMPERATURE_WARNING': 65
|
||||
},
|
||||
@ -779,13 +781,7 @@ 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}")
|
||||
|
||||
if not size_str:
|
||||
return 0.0
|
||||
|
||||
# Handle decimal numbers with units (like 192.2M, 3.5G)
|
||||
# Also handle cases with spaces between number and unit
|
||||
match = re.match(r'([\d.]+)\s*([KMGT])(?:iB|B)?', size_str.strip())
|
||||
match = re.match(r'([\d.]+)\s*([KMGT])', size_str.strip())
|
||||
if match:
|
||||
value = float(match.group(1))
|
||||
unit = match.group(2)
|
||||
@ -795,31 +791,9 @@ class SystemHealthMonitor:
|
||||
'G': 1024**3,
|
||||
'T': 1024**4
|
||||
}
|
||||
result = value * multipliers[unit]
|
||||
logger.debug(f"Parsed {size_str} to {result} bytes")
|
||||
return result
|
||||
|
||||
# Handle cases like '957.2M'
|
||||
match = re.match(r'([\d.]+)([KMGT])', size_str.strip())
|
||||
if match:
|
||||
value = float(match.group(1))
|
||||
unit = match.group(2)
|
||||
multipliers = {
|
||||
'K': 1024,
|
||||
'M': 1024**2,
|
||||
'G': 1024**3,
|
||||
'T': 1024**4
|
||||
}
|
||||
result = value * multipliers[unit]
|
||||
logger.debug(f"Parsed {size_str} to {result} bytes")
|
||||
return result
|
||||
|
||||
# Try parsing as plain number
|
||||
try:
|
||||
return float(size_str)
|
||||
except ValueError:
|
||||
logger.debug(f"Failed to parse size string: {size_str}")
|
||||
return 0.0
|
||||
return value * multipliers[unit]
|
||||
logger.debug(f"Parsed value: {value}, Unit: {unit}, Result: {value * multipliers[unit]}")
|
||||
return float(size_str)
|
||||
|
||||
def _is_physical_disk(self, device_path):
|
||||
"""
|
||||
@ -1439,12 +1413,12 @@ class SystemHealthMonitor:
|
||||
filesystem['total_bytes'] = total_bytes
|
||||
filesystem['used_bytes'] = used_bytes
|
||||
filesystem['avail_bytes'] = avail_bytes
|
||||
|
||||
if filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['DISK_CRITICAL']:
|
||||
|
||||
if filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['LXC_CRITICAL']:
|
||||
lxc_health['status'] = 'CRITICAL'
|
||||
issue = f"LXC {vmid} critical storage usage: {filesystem['usage_percent']}% on {filesystem['mountpoint']}"
|
||||
lxc_health['issues'].append(issue)
|
||||
elif filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['DISK_WARNING']:
|
||||
elif filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['LXC_WARNING']:
|
||||
if lxc_health['status'] != 'CRITICAL':
|
||||
lxc_health['status'] = 'WARNING'
|
||||
issue = f"LXC {vmid} high storage usage: {filesystem['usage_percent']}% on {filesystem['mountpoint']}"
|
||||
@ -1452,6 +1426,10 @@ class SystemHealthMonitor:
|
||||
|
||||
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']}%")
|
||||
logger.debug(f"LXC_CRITICAL threshold: {self.CONFIG['THRESHOLDS']['LXC_CRITICAL']}%")
|
||||
except Exception as e:
|
||||
logger.debug(f"Error processing filesystem line for container {vmid}: {str(e)}")
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user