diff --git a/internal/alerts/alerts.go b/internal/alerts/alerts.go index ce8b21053..f737907a5 100644 --- a/internal/alerts/alerts.go +++ b/internal/alerts/alerts.go @@ -403,7 +403,7 @@ func (m *Manager) CheckGuest(guest interface{}, instanceName string) { node = g.Node status = g.Status guestType = "VM" - cpu = g.CPU * 100 // Convert to percentage + cpu = g.CPU // Already in percentage memUsage = g.Memory.Usage diskUsage = g.Disk.Usage diskRead = g.DiskRead @@ -416,7 +416,7 @@ func (m *Manager) CheckGuest(guest interface{}, instanceName string) { node = g.Node status = g.Status guestType = "Container" - cpu = g.CPU * 100 // Convert to percentage + cpu = g.CPU // Already in percentage memUsage = g.Memory.Usage diskUsage = g.Disk.Usage diskRead = g.DiskRead @@ -450,7 +450,7 @@ func (m *Manager) CheckGuest(guest interface{}, instanceName string) { m.mu.RUnlock() // Check each metric - log.Debug(). + log.Info(). Str("guest", name). Float64("cpu", cpu). Float64("memory", memUsage). diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go index d00236ea4..dcda34aca 100644 --- a/internal/monitoring/monitor.go +++ b/internal/monitoring/monitor.go @@ -924,6 +924,9 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam allVMs = append(allVMs, vm) + // Check thresholds for alerts + m.alertManager.CheckGuest(vm, instanceName) + } else if res.Type == "lxc" { // Skip templates if configured if res.Template == 1 { @@ -966,6 +969,9 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam } allContainers = append(allContainers, container) + + // Check thresholds for alerts + m.alertManager.CheckGuest(container, instanceName) } } @@ -1241,6 +1247,7 @@ func (m *Monitor) pollContainersWithNodes(ctx context.Context, instanceName stri m.metricsHistory.AddGuestMetric(modelCT.ID, "netout", float64(modelCT.NetworkOut), now) // Check thresholds for alerts + log.Info().Str("container", modelCT.Name).Msg("Checking container alerts") m.alertManager.CheckGuest(modelCT, instanceName) } }