mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-01 03:24:29 +08:00
修改规则执行时间
在将资源数据取到后更新执行时间
This commit is contained in:
@@ -62,7 +62,7 @@ type SSuggestSysRule struct {
|
||||
Period string `width:"256" charset:"ascii" list:"user" update:"user"`
|
||||
TimeFrom string `width:"256" charset:"ascii" list:"user" update:"user"`
|
||||
Setting jsonutils.JSONObject ` list:"user" update:"user"`
|
||||
ExecTime time.Time `json:"exec_time"`
|
||||
ExecTime time.Time `list:"user" update:"user"`
|
||||
}
|
||||
|
||||
func (man *SSuggestSysRuleManager) FetchSuggestSysAlartSettings(ruleTypes ...string) (map[string]*monitor.SuggestSysRuleDetails, error) {
|
||||
@@ -194,6 +194,7 @@ func (man *SSuggestSysRuleManager) FetchCustomizeColumns(
|
||||
rows[i] = monitor.SuggestSysRuleDetails{
|
||||
VirtualResourceDetails: virtRows[i],
|
||||
}
|
||||
rows[i] = objs[i].(*SSuggestSysRule).getMoreDetails(rows[i])
|
||||
}
|
||||
return rows
|
||||
}
|
||||
@@ -335,3 +336,10 @@ func (self *SSuggestSysRuleManager) GetRules(tp ...string) ([]SSuggestSysRule, e
|
||||
}
|
||||
return rules, nil
|
||||
}
|
||||
|
||||
func (self *SSuggestSysRule) UpdateExecTime() {
|
||||
db.Update(self, func() error {
|
||||
self.ExecTime = time.Now()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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