update health_persistence.py

This commit is contained in:
MacRimi
2026-04-04 00:51:20 +02:00
parent db113f0433
commit d1efae37a4
2 changed files with 46 additions and 0 deletions

View File

@@ -1095,6 +1095,22 @@ export default function Hardware() {
</div>
)}
</>
) : (findPCIDeviceForGPU(selectedGPU)?.driver === 'vfio-pci' || selectedGPU.pci_driver === 'vfio-pci') ? (
<div className="rounded-lg bg-purple-500/10 p-4 border border-purple-500/20">
<div className="flex gap-3">
<div className="flex-shrink-0">
<svg className="h-5 w-5 text-purple-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
<path strokeLinecap="round" strokeLinejoin="round" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" />
</svg>
</div>
<div className="flex-1">
<h4 className="text-sm font-semibold text-purple-500 mb-1">GPU in Switch Mode VM</h4>
<p className="text-sm text-muted-foreground">
This GPU is assigned to a virtual machine via VFIO passthrough. Real-time monitoring is not available from the host because the GPU is controlled by the VM.
</p>
</div>
</div>
</div>
) : (
<div className="rounded-lg bg-blue-500/10 p-4 border border-blue-500/20">
<div className="flex gap-3">

View File

@@ -967,6 +967,36 @@ class HealthPersistence:
cutoff_events = (now - timedelta(days=30)).isoformat()
cursor.execute('DELETE FROM events WHERE timestamp < ?', (cutoff_events,))
# ── Auto-resolve log errors that occurred before the last system reboot ──
# After a reboot, transient errors like OOM, service failures, etc. are resolved.
# Only resolve log errors (not disk errors which may persist across reboots).
try:
import os
# Get system boot time from /proc/stat
with open('/proc/stat', 'r') as f:
for line in f:
if line.startswith('btime '):
boot_timestamp = int(line.split()[1])
boot_time = datetime.fromtimestamp(boot_timestamp)
# Resolve log errors that were last seen BEFORE the boot time
# These are transient errors (OOM, service crashes) that a reboot fixes
boot_time_iso = boot_time.isoformat()
cursor.execute('''
UPDATE errors
SET resolved_at = ?
WHERE category = 'logs'
AND resolved_at IS NULL
AND acknowledged = 0
AND last_seen < ?
AND (error_key LIKE 'log_critical_%'
OR reason LIKE '%Out of memory%'
OR reason LIKE '%service%Failed%'
OR reason LIKE '%timeout%')
''', (now_iso, boot_time_iso))
break
except Exception:
pass # If we can't read boot time, skip this cleanup
conn.commit()
conn.close()