Update health_monitor.py

This commit is contained in:
MacRimi
2026-02-27 20:07:01 +01:00
parent 9841e92634
commit 828c0f66a6

View File

@@ -1712,13 +1712,14 @@ 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'}
) )
if not rec_result or rec_result.get('type') != 'skipped_acknowledged':
issues.append(f'{display}: QMP communication issue') issues.append(f'{display}: QMP communication issue')
vm_details[error_key] = { vm_details[error_key] = {
'status': 'WARNING', 'status': 'WARNING',
@@ -1746,13 +1747,14 @@ 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'}
) )
if not rec_result or rec_result.get('type') != 'skipped_acknowledged':
issues.append(f'CT {ctid}: {reason}') issues.append(f'CT {ctid}: {reason}')
vm_details[error_key] = { vm_details[error_key] = {
'status': 'WARNING', 'status': 'WARNING',
@@ -1790,13 +1792,14 @@ 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}
) )
if not rec_result or rec_result.get('type') != 'skipped_acknowledged':
issues.append(f'{display}: Failed to start') issues.append(f'{display}: Failed to start')
vm_details[error_key] = { vm_details[error_key] = {
'status': 'CRITICAL', 'status': 'CRITICAL',