Changed dictionary access for single scope
This commit is contained in:
@ -633,7 +633,7 @@ class SystemHealthMonitor:
|
||||
priority = self.PRIORITIES['MEDIUM']
|
||||
category = self.TICKET_TEMPLATES['DEFAULT_CATEGORY']
|
||||
issue_type = self.TICKET_TEMPLATES['DEFAULT_ISSUE_TYPE']
|
||||
scope = self.TICKET_TEMPLATES['SCOPE_SINGLE']
|
||||
scope = self.TICKET_TEMPLATES['SCOPE']['SINGLE_NODE']
|
||||
|
||||
drive_size = ""
|
||||
if "Drive" in issue:
|
||||
@ -1381,46 +1381,47 @@ class SystemHealthMonitor:
|
||||
try:
|
||||
parts = fs_line.split()
|
||||
if len(parts) >= 6:
|
||||
if parts[5] and not self._is_excluded_mount(parts[5]):
|
||||
|
||||
# Convert size strings to comparable values
|
||||
total = parts[2]
|
||||
used = parts[3]
|
||||
avail = parts[4]
|
||||
|
||||
# Calculate usage percentage
|
||||
total_bytes = self._convert_size_to_bytes(total)
|
||||
used_bytes = self._convert_size_to_bytes(used)
|
||||
usage_percent = int((used_bytes / total_bytes) * 100)
|
||||
|
||||
filesystem = {
|
||||
'mountpoint': parts[5],
|
||||
'total': total,
|
||||
'used': used,
|
||||
'available': avail,
|
||||
'usage_percent': usage_percent
|
||||
}
|
||||
|
||||
if any(re.match(pattern, parts[5]) for pattern in self.CONFIG['EXCLUDED_PATTERNS']) or \
|
||||
parts[5] in self.CONFIG['EXCLUDED_MOUNTS']:
|
||||
continue
|
||||
# Convert size strings to comparable values
|
||||
total = parts[2]
|
||||
used = parts[3]
|
||||
avail = parts[4]
|
||||
|
||||
# Calculate usage percentage
|
||||
total_bytes = self._convert_size_to_bytes(total)
|
||||
used_bytes = self._convert_size_to_bytes(used)
|
||||
usage_percent = int((used_bytes / total_bytes) * 100)
|
||||
|
||||
filesystem = {
|
||||
'mountpoint': parts[5],
|
||||
'total': total,
|
||||
'used': used,
|
||||
'available': avail,
|
||||
'usage_percent': usage_percent
|
||||
}
|
||||
|
||||
if self.dry_run:
|
||||
logger.debug(f"Container {vmid} filesystem details:")
|
||||
logger.debug(f" Mountpoint: {filesystem['mountpoint']}")
|
||||
logger.debug(f" Usage: {used}/{total} ({usage_percent}%)")
|
||||
|
||||
if usage_percent >= self.CONFIG['THRESHOLDS']['DISK_CRITICAL']:
|
||||
lxc_health['status'] = 'CRITICAL'
|
||||
issue = f"LXC {vmid} critical storage usage: {usage_percent}% on {parts[5]}"
|
||||
lxc_health['issues'].append(issue)
|
||||
if self.dry_run:
|
||||
logger.debug(f"Container {vmid} filesystem details:")
|
||||
logger.debug(f" Mountpoint: {filesystem['mountpoint']}")
|
||||
logger.debug(f" Usage: {used}/{total} ({usage_percent}%)")
|
||||
logger.debug(f"Critical issue detected: {issue}")
|
||||
elif usage_percent >= self.CONFIG['THRESHOLDS']['DISK_WARNING']:
|
||||
if lxc_health['status'] != 'CRITICAL':
|
||||
lxc_health['status'] = 'WARNING'
|
||||
issue = f"LXC {vmid} high storage usage: {usage_percent}% on {parts[5]}"
|
||||
lxc_health['issues'].append(issue)
|
||||
if self.dry_run:
|
||||
logger.debug(f"Warning issue detected: {issue}")
|
||||
|
||||
if usage_percent >= self.CONFIG['THRESHOLDS']['DISK_CRITICAL']:
|
||||
lxc_health['status'] = 'CRITICAL'
|
||||
issue = f"LXC {vmid} critical storage usage: {usage_percent}% on {parts[5]}"
|
||||
lxc_health['issues'].append(issue)
|
||||
if self.dry_run:
|
||||
logger.debug(f"Critical issue detected: {issue}")
|
||||
elif usage_percent >= self.CONFIG['THRESHOLDS']['DISK_WARNING']:
|
||||
if lxc_health['status'] != 'CRITICAL':
|
||||
lxc_health['status'] = 'WARNING'
|
||||
issue = f"LXC {vmid} high storage usage: {usage_percent}% on {parts[5]}"
|
||||
lxc_health['issues'].append(issue)
|
||||
if self.dry_run:
|
||||
logger.debug(f"Warning issue detected: {issue}")
|
||||
|
||||
container_info['filesystems'].append(filesystem)
|
||||
container_info['filesystems'].append(filesystem)
|
||||
except Exception as e:
|
||||
if self.dry_run:
|
||||
logger.debug(f"Error processing filesystem line for container {vmid}: {str(e)}")
|
||||
|
||||
Reference in New Issue
Block a user