mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
use goroutines to send alerts
This commit is contained in:
@@ -284,10 +284,10 @@ func (am *AlertManager) HandleSystemAlerts(systemRecord *models.Record, systemIn
|
|||||||
if float32(alert.count) >= minCount {
|
if float32(alert.count) >= minCount {
|
||||||
if !alert.triggered && alert.val > alert.threshold {
|
if !alert.triggered && alert.val > alert.threshold {
|
||||||
alert.triggered = true
|
alert.triggered = true
|
||||||
am.sendSystemAlert(alert)
|
go am.sendSystemAlert(alert)
|
||||||
} else if alert.triggered && alert.val <= alert.threshold {
|
} else if alert.triggered && alert.val <= alert.threshold {
|
||||||
alert.triggered = false
|
alert.triggered = false
|
||||||
am.sendSystemAlert(alert)
|
go am.sendSystemAlert(alert)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ func (am *AlertManager) sendSystemAlert(alert SystemAlertData) {
|
|||||||
UserID: user.GetId(),
|
UserID: user.GetId(),
|
||||||
Title: subject,
|
Title: subject,
|
||||||
Message: body,
|
Message: body,
|
||||||
Link: am.app.Settings().Meta.AppUrl + "/system/" + url.QueryEscape(systemName),
|
Link: am.app.Settings().Meta.AppUrl + "/system/" + url.PathEscape(systemName),
|
||||||
LinkText: "View " + systemName,
|
LinkText: "View " + systemName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user