mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-23 03:33:53 +00:00
fix: enable alert checking for mock mode data (addresses #399)
Mock mode was bypassing alert checking entirely, causing alerts not to trigger even when thresholds were exceeded. Added checkMockAlerts() function that processes mock VMs, containers, nodes and storage through the alert manager.
This commit is contained in:
@@ -406,6 +406,9 @@ func (m *Monitor) Start(ctx context.Context, wsHub *websocket.Hub) {
|
||||
// Start polling in a goroutine so it doesn't block the ticker (only if not in mock mode)
|
||||
if !mockEnabled {
|
||||
go m.poll(ctx, wsHub)
|
||||
} else {
|
||||
// In mock mode, still check alerts for mock data
|
||||
go m.checkMockAlerts()
|
||||
}
|
||||
|
||||
case <-broadcastTicker.C:
|
||||
@@ -2800,3 +2803,38 @@ func (m *Monitor) pollPBSBackups(ctx context.Context, instanceName string, clien
|
||||
// Update state
|
||||
m.state.UpdatePBSBackups(instanceName, allBackups)
|
||||
}
|
||||
|
||||
// checkMockAlerts checks alerts for mock data
|
||||
func (m *Monitor) checkMockAlerts() {
|
||||
if !mock.IsMockEnabled() {
|
||||
return
|
||||
}
|
||||
|
||||
// Get mock state
|
||||
state := mock.GetMockState()
|
||||
|
||||
log.Info().
|
||||
Int("vms", len(state.VMs)).
|
||||
Int("containers", len(state.Containers)).
|
||||
Msg("Checking alerts for mock data")
|
||||
|
||||
// Check alerts for each VM
|
||||
for _, vm := range state.VMs {
|
||||
m.alertManager.CheckGuest(vm, "mock")
|
||||
}
|
||||
|
||||
// Check alerts for each container
|
||||
for _, container := range state.Containers {
|
||||
m.alertManager.CheckGuest(container, "mock")
|
||||
}
|
||||
|
||||
// Check alerts for each node
|
||||
for _, node := range state.Nodes {
|
||||
m.alertManager.CheckNode(node)
|
||||
}
|
||||
|
||||
// Check alerts for storage
|
||||
for _, storage := range state.Storage {
|
||||
m.alertManager.CheckStorage(storage)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user