update parsing
This commit is contained in:
@ -782,16 +782,14 @@ class SystemHealthMonitor:
|
|||||||
"""Parse size string with units to bytes"""
|
"""Parse size string with units to bytes"""
|
||||||
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'
|
||||||
|
|
||||||
multipliers = {
|
multipliers = {
|
||||||
'B': 1,
|
'B': 1,
|
||||||
'K': 1024,
|
'K': 1024,
|
||||||
@ -799,9 +797,9 @@ class SystemHealthMonitor:
|
|||||||
'G': 1024**3,
|
'G': 1024**3,
|
||||||
'T': 1024**4
|
'T': 1024**4
|
||||||
}
|
}
|
||||||
|
|
||||||
return value * multipliers[unit]
|
return value * multipliers[unit]
|
||||||
|
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def _is_physical_disk(self, device_path):
|
def _is_physical_disk(self, device_path):
|
||||||
@ -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'
|
||||||
|
|||||||
Reference in New Issue
Block a user