mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-30 03:16:34 +00:00
Update notification service
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
import type React from "react"
|
import type React from "react"
|
||||||
|
|
||||||
import { useState, useEffect, useCallback } from "react"
|
import { useState, useEffect, useCallback } from "react"
|
||||||
import { fetchApi, getApiUrl, getAuthToken } from "@/lib/api-config"
|
import { getAuthToken } from "@/lib/api-config"
|
||||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
|
|||||||
@@ -83,11 +83,10 @@ def acknowledge_error():
|
|||||||
health_monitor.last_check_times.pop(cache_key, None)
|
health_monitor.last_check_times.pop(cache_key, None)
|
||||||
health_monitor.cached_results.pop(cache_key, None)
|
health_monitor.cached_results.pop(cache_key, None)
|
||||||
|
|
||||||
# Also invalidate overall status caches so header updates immediately
|
# Also invalidate ALL background/overall caches so next fetch reflects dismiss
|
||||||
health_monitor.last_check_times.pop('_bg_overall', None)
|
for ck in ['_bg_overall', '_bg_detailed', 'overall_health']:
|
||||||
health_monitor.cached_results.pop('_bg_overall', None)
|
health_monitor.last_check_times.pop(ck, None)
|
||||||
health_monitor.last_check_times.pop('overall_health', None)
|
health_monitor.cached_results.pop(ck, None)
|
||||||
health_monitor.cached_results.pop('overall_health', None)
|
|
||||||
|
|
||||||
# Use the per-record suppression hours from acknowledge_error()
|
# Use the per-record suppression hours from acknowledge_error()
|
||||||
sup_hours = result.get('suppression_hours', 24)
|
sup_hours = result.get('suppression_hours', 24)
|
||||||
|
|||||||
@@ -2248,24 +2248,28 @@ class HealthMonitor:
|
|||||||
'status': _log_check_status('log_error_cascade', cascade_count > 0, 'WARNING'),
|
'status': _log_check_status('log_error_cascade', cascade_count > 0, 'WARNING'),
|
||||||
'detail': f'{cascade_count} pattern(s) repeating >=15 times' if cascade_count > 0 else 'No cascading errors',
|
'detail': f'{cascade_count} pattern(s) repeating >=15 times' if cascade_count > 0 else 'No cascading errors',
|
||||||
'dismissable': True,
|
'dismissable': True,
|
||||||
'dismissed': 'log_error_cascade' in dismissed_keys
|
'dismissed': 'log_error_cascade' in dismissed_keys,
|
||||||
|
'error_key': 'log_error_cascade'
|
||||||
},
|
},
|
||||||
'log_error_spike': {
|
'log_error_spike': {
|
||||||
'status': _log_check_status('log_error_spike', spike_count > 0, 'WARNING'),
|
'status': _log_check_status('log_error_spike', spike_count > 0, 'WARNING'),
|
||||||
'detail': f'{spike_count} pattern(s) with 4x increase' if spike_count > 0 else 'No error spikes',
|
'detail': f'{spike_count} pattern(s) with 4x increase' if spike_count > 0 else 'No error spikes',
|
||||||
'dismissable': True,
|
'dismissable': True,
|
||||||
'dismissed': 'log_error_spike' in dismissed_keys
|
'dismissed': 'log_error_spike' in dismissed_keys,
|
||||||
|
'error_key': 'log_error_spike'
|
||||||
},
|
},
|
||||||
'log_persistent_errors': {
|
'log_persistent_errors': {
|
||||||
'status': _log_check_status('log_persistent_errors', persistent_count > 0, 'WARNING'),
|
'status': _log_check_status('log_persistent_errors', persistent_count > 0, 'WARNING'),
|
||||||
'detail': f'{persistent_count} recurring pattern(s) over 15+ min' if persistent_count > 0 else 'No persistent patterns',
|
'detail': f'{persistent_count} recurring pattern(s) over 15+ min' if persistent_count > 0 else 'No persistent patterns',
|
||||||
'dismissable': True,
|
'dismissable': True,
|
||||||
'dismissed': 'log_persistent_errors' in dismissed_keys
|
'dismissed': 'log_persistent_errors' in dismissed_keys,
|
||||||
|
'error_key': 'log_persistent_errors'
|
||||||
},
|
},
|
||||||
'log_critical_errors': {
|
'log_critical_errors': {
|
||||||
'status': _log_check_status('log_critical_errors', unique_critical_count > 0, 'CRITICAL'),
|
'status': _log_check_status('log_critical_errors', unique_critical_count > 0, 'CRITICAL'),
|
||||||
'detail': f'{unique_critical_count} critical error(s) found' if unique_critical_count > 0 else 'No critical errors',
|
'detail': f'{unique_critical_count} critical error(s) found' if unique_critical_count > 0 else 'No critical errors',
|
||||||
'dismissable': False
|
'dismissable': False,
|
||||||
|
'error_key': 'log_critical_errors'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -414,13 +414,15 @@ class HealthPersistence:
|
|||||||
# Error not in DB yet -- create a minimal record so the dismiss persists.
|
# Error not in DB yet -- create a minimal record so the dismiss persists.
|
||||||
# Try to infer category from the error_key prefix.
|
# Try to infer category from the error_key prefix.
|
||||||
category = ''
|
category = ''
|
||||||
for cat, prefix in [('security', 'security_'), ('updates', 'security_updates'),
|
# Order matters: more specific prefixes MUST come before shorter ones
|
||||||
('updates', 'update_'), ('updates', 'kernel_'),
|
# e.g. 'security_updates' (updates) before 'security_' (security)
|
||||||
('updates', 'pending_'), ('updates', 'system_age'),
|
for cat, prefix in [('updates', 'security_updates'), ('updates', 'system_age'),
|
||||||
|
('updates', 'pending_updates'), ('updates', 'kernel_pve'),
|
||||||
|
('security', 'security_'),
|
||||||
('pve_services', 'pve_service_'), ('vms', 'vm_'), ('vms', 'ct_'),
|
('pve_services', 'pve_service_'), ('vms', 'vm_'), ('vms', 'ct_'),
|
||||||
('disks', 'disk_'), ('logs', 'log_'), ('network', 'net_'),
|
('disks', 'disk_'), ('logs', 'log_'), ('network', 'net_'),
|
||||||
('temperature', 'temp_')]:
|
('temperature', 'temp_')]:
|
||||||
if error_key.startswith(prefix) or error_key == prefix:
|
if error_key == prefix or error_key.startswith(prefix):
|
||||||
category = cat
|
category = cat
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user