mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-05-01 03:46:22 +00:00
Update health_monitor.py
This commit is contained in:
@@ -1712,21 +1712,22 @@ class HealthMonitor:
|
|||||||
display = f"VM {vmid} ({vm_name})" if vm_name else f"VM {vmid}"
|
display = f"VM {vmid} ({vm_name})" if vm_name else f"VM {vmid}"
|
||||||
error_key = f'vm_{vmid}'
|
error_key = f'vm_{vmid}'
|
||||||
if error_key not in vm_details:
|
if error_key not in vm_details:
|
||||||
health_persistence.record_error(
|
rec_result = health_persistence.record_error(
|
||||||
error_key=error_key,
|
error_key=error_key,
|
||||||
category='vms',
|
category='vms',
|
||||||
severity='WARNING',
|
severity='WARNING',
|
||||||
reason=f'{display}: QMP command failed or timed out.\n{line.strip()[:200]}',
|
reason=f'{display}: QMP command failed or timed out.\n{line.strip()[:200]}',
|
||||||
details={'id': vmid, 'vmname': vm_name, 'type': 'VM'}
|
details={'id': vmid, 'vmname': vm_name, 'type': 'VM'}
|
||||||
)
|
)
|
||||||
issues.append(f'{display}: QMP communication issue')
|
if not rec_result or rec_result.get('type') != 'skipped_acknowledged':
|
||||||
vm_details[error_key] = {
|
issues.append(f'{display}: QMP communication issue')
|
||||||
'status': 'WARNING',
|
vm_details[error_key] = {
|
||||||
'reason': f'{display}: QMP command failed or timed out',
|
'status': 'WARNING',
|
||||||
'id': vmid,
|
'reason': f'{display}: QMP command failed or timed out',
|
||||||
'vmname': vm_name,
|
'id': vmid,
|
||||||
'type': 'VM'
|
'vmname': vm_name,
|
||||||
}
|
'type': 'VM'
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Container errors (including startup issues via vzstart)
|
# Container errors (including startup issues via vzstart)
|
||||||
@@ -1746,20 +1747,21 @@ class HealthMonitor:
|
|||||||
reason = 'Startup error'
|
reason = 'Startup error'
|
||||||
|
|
||||||
# Record persistent error
|
# Record persistent error
|
||||||
health_persistence.record_error(
|
rec_result = health_persistence.record_error(
|
||||||
error_key=error_key,
|
error_key=error_key,
|
||||||
category='vms',
|
category='vms',
|
||||||
severity='WARNING',
|
severity='WARNING',
|
||||||
reason=reason,
|
reason=reason,
|
||||||
details={'id': ctid, 'type': 'CT'}
|
details={'id': ctid, 'type': 'CT'}
|
||||||
)
|
)
|
||||||
issues.append(f'CT {ctid}: {reason}')
|
if not rec_result or rec_result.get('type') != 'skipped_acknowledged':
|
||||||
vm_details[error_key] = {
|
issues.append(f'CT {ctid}: {reason}')
|
||||||
'status': 'WARNING',
|
vm_details[error_key] = {
|
||||||
'reason': reason,
|
'status': 'WARNING',
|
||||||
'id': ctid,
|
'reason': reason,
|
||||||
'type': 'CT'
|
'id': ctid,
|
||||||
}
|
'type': 'CT'
|
||||||
|
}
|
||||||
|
|
||||||
# Generic failed to start for VMs and CTs
|
# Generic failed to start for VMs and CTs
|
||||||
if any(keyword in line_lower for keyword in ['failed to start', 'cannot start', 'activation failed', 'start error']):
|
if any(keyword in line_lower for keyword in ['failed to start', 'cannot start', 'activation failed', 'start error']):
|
||||||
@@ -1790,21 +1792,22 @@ class HealthMonitor:
|
|||||||
display = f"{vm_type} {vmid_ctid} ({vm_name})"
|
display = f"{vm_type} {vmid_ctid} ({vm_name})"
|
||||||
reason = f'{display}: Failed to start\n{line.strip()[:200]}'
|
reason = f'{display}: Failed to start\n{line.strip()[:200]}'
|
||||||
# Record persistent error
|
# Record persistent error
|
||||||
health_persistence.record_error(
|
rec_result = health_persistence.record_error(
|
||||||
error_key=error_key,
|
error_key=error_key,
|
||||||
category='vms',
|
category='vms',
|
||||||
severity='CRITICAL',
|
severity='CRITICAL',
|
||||||
reason=reason,
|
reason=reason,
|
||||||
details={'id': vmid_ctid, 'vmname': vm_name, 'type': vm_type}
|
details={'id': vmid_ctid, 'vmname': vm_name, 'type': vm_type}
|
||||||
)
|
)
|
||||||
issues.append(f'{display}: Failed to start')
|
if not rec_result or rec_result.get('type') != 'skipped_acknowledged':
|
||||||
vm_details[error_key] = {
|
issues.append(f'{display}: Failed to start')
|
||||||
'status': 'CRITICAL',
|
vm_details[error_key] = {
|
||||||
'reason': reason,
|
'status': 'CRITICAL',
|
||||||
'id': vmid_ctid,
|
'reason': reason,
|
||||||
'vmname': vm_name,
|
'id': vmid_ctid,
|
||||||
'type': vm_type
|
'vmname': vm_name,
|
||||||
}
|
'type': vm_type
|
||||||
|
}
|
||||||
|
|
||||||
# Build checks dict from vm_details
|
# Build checks dict from vm_details
|
||||||
checks = {}
|
checks = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user