update parsing

This commit is contained in:
2025-03-09 21:47:41 -04:00
parent 55813c5441
commit 519a30e11e

View File

@ -782,16 +782,14 @@ class SystemHealthMonitor:
"""Parse size string with units to bytes"""
if not size_str or not isinstance(size_str, str):
return 0.0
# 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])?B?$', size_str)
match = re.match(r'^([\d.]+)\s*([KMGT])?B?$', size_str) # Corrected regex
if match:
value = float(match.group(1))
unit = match.group(2) if match.group(2) else 'B'
multipliers = {
'B': 1,
'K': 1024,
@ -799,9 +797,9 @@ class SystemHealthMonitor:
'G': 1024**3,
'T': 1024**4
}
return value * multipliers[unit]
return 0.0
def _is_physical_disk(self, device_path):
@ -1424,9 +1422,9 @@ class SystemHealthMonitor:
avail_bytes = self._parse_size(filesystem['available'])
# Store both human readable and byte values
filesystem['total_bytes'] = total_bytes
filesystem['used_bytes'] = used_bytes
filesystem['avail_bytes'] = avail_bytes
filesystem['total_bytes'] = self._parse_size(filesystem['total_space'])
filesystem['used_bytes'] = self._parse_size(filesystem['used_space'])
filesystem['avail_bytes'] = self._parse_size(filesystem['available'])
if filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['LXC_CRITICAL']:
lxc_health['status'] = 'CRITICAL'