update parsing

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

View File

@ -783,11 +783,9 @@ class SystemHealthMonitor:
if not size_str or not isinstance(size_str, str): if not size_str or not isinstance(size_str, str):
return 0.0 return 0.0
# Remove any whitespace and convert to uppercase for consistent handling
size_str = size_str.strip().upper() size_str = size_str.strip().upper()
# Handle values with decimal points (like 192.2M) match = re.match(r'^([\d.]+)\s*([KMGT])?B?$', size_str) # Corrected regex
match = re.match(r'^([\d.]+)\s*([KMGT])?B?$', size_str)
if match: if match:
value = float(match.group(1)) value = float(match.group(1))
unit = match.group(2) if match.group(2) else 'B' unit = match.group(2) if match.group(2) else 'B'
@ -1424,9 +1422,9 @@ class SystemHealthMonitor:
avail_bytes = self._parse_size(filesystem['available']) avail_bytes = self._parse_size(filesystem['available'])
# Store both human readable and byte values # Store both human readable and byte values
filesystem['total_bytes'] = total_bytes filesystem['total_bytes'] = self._parse_size(filesystem['total_space'])
filesystem['used_bytes'] = used_bytes filesystem['used_bytes'] = self._parse_size(filesystem['used_space'])
filesystem['avail_bytes'] = avail_bytes filesystem['avail_bytes'] = self._parse_size(filesystem['available'])
if filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['LXC_CRITICAL']: if filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['LXC_CRITICAL']:
lxc_health['status'] = 'CRITICAL' lxc_health['status'] = 'CRITICAL'