mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
修改规则执行时间
在将资源数据取到后更新执行时间
This commit is contained in:
@@ -15,7 +15,10 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/monitor/models"
|
||||
)
|
||||
|
||||
func DealAlertData(oldAlerts []models.SSuggestSysAlert, newAlerts []jsonutils.JSONObject) {
|
||||
func DealAlertData(typ string, oldAlerts []models.SSuggestSysAlert, newAlerts []jsonutils.JSONObject) {
|
||||
rules, _ := models.SuggestSysRuleManager.GetRules(typ)
|
||||
rules[0].UpdateExecTime()
|
||||
|
||||
oldMap := make(map[string]models.SSuggestSysAlert, 0)
|
||||
for _, alert := range oldAlerts {
|
||||
oldMap[alert.ResId] = alert
|
||||
|
||||
@@ -48,7 +48,7 @@ func (rule *DiskUnused) Run(instance *monitor.SSuggestSysAlertSetting) {
|
||||
log.Errorln(errors.Wrap(err, "DiskUnused getLatestAlerts error"))
|
||||
return
|
||||
}
|
||||
DealAlertData(oldAlert, newAlerts.Value())
|
||||
DealAlertData(rule.GetType(), oldAlert, newAlerts.Value())
|
||||
}
|
||||
|
||||
func (rule *DiskUnused) getLatestAlerts(instance *monitor.SSuggestSysAlertSetting) (*jsonutils.JSONArray, error) {
|
||||
|
||||
@@ -65,7 +65,7 @@ func (rule *EIPUnused) Run(instance *monitor.SSuggestSysAlertSetting) {
|
||||
return
|
||||
}
|
||||
|
||||
DealAlertData(oldAlert, newAlert.Value())
|
||||
DealAlertData(rule.GetType(), oldAlert, newAlert.Value())
|
||||
}
|
||||
|
||||
func (rule *EIPUnused) getEIPUnused(instance *monitor.SSuggestSysAlertSetting) (*jsonutils.JSONArray, error) {
|
||||
|
||||
@@ -54,7 +54,7 @@ func (rule *LBUnused) Run(instance *monitor.SSuggestSysAlertSetting) {
|
||||
log.Errorln(errors.Wrap(err, "getEIPUnused error"))
|
||||
return
|
||||
}
|
||||
DealAlertData(oldAlert, newAlert.Value())
|
||||
DealAlertData(rule.GetType(), oldAlert, newAlert.Value())
|
||||
}
|
||||
|
||||
func (rule *LBUnused) getLatestAlerts(instance *monitor.SSuggestSysAlertSetting) (*jsonutils.JSONArray, error) {
|
||||
|
||||
@@ -92,7 +92,7 @@ func (rule *ScaleDown) Run(instance *monitor.SSuggestSysAlertSetting) {
|
||||
log.Errorln(err)
|
||||
return
|
||||
}
|
||||
DealAlertData(oldAlert, newAlert.Value())
|
||||
DealAlertData(rule.GetType(), oldAlert, newAlert.Value())
|
||||
}
|
||||
|
||||
func (rule *ScaleDown) getLatestAlerts(instance *monitor.SSuggestSysAlertSetting) (*jsonutils.JSONArray, error) {
|
||||
|
||||
Reference in New Issue
Block a user