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