From f8b690602d20f6ac133bffbf15fb4da898eef413 Mon Sep 17 00:00:00 2001 From: zhaoxiangchun <1422928955@qq.com> Date: Mon, 28 Jun 2021 12:16:00 +0800 Subject: [PATCH] fix(monitor): update monitor resourece joint scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.将agent监控报警策略关联到虚拟机资源 --- pkg/monitor/models/monitor_resource.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/monitor/models/monitor_resource.go b/pkg/monitor/models/monitor_resource.go index 1c4ce83c66..be8865e8ea 100644 --- a/pkg/monitor/models/monitor_resource.go +++ b/pkg/monitor/models/monitor_resource.go @@ -295,10 +295,13 @@ func (manager *SMonitorResourceManager) GetPropertyAlert(ctx context.Context, us func (manager *SMonitorResourceManager) UpdateMonitorResourceAttachJoint(ctx context.Context, userCred mcclient.TokenCredential, alertRecord *SAlertRecord) error { if !utils.IsInStringArray(alertRecord.ResType, []string{monitor.METRIC_RES_TYPE_HOST, - monitor.METRIC_RES_TYPE_GUEST}) { + monitor.METRIC_RES_TYPE_GUEST, monitor.METRIC_RES_TYPE_AGENT}) { return nil } - + resType := alertRecord.ResType + if resType == monitor.METRIC_RES_TYPE_AGENT { + resType = monitor.METRIC_RES_TYPE_GUEST + } matches, _ := alertRecord.GetEvalData() errs := make([]error, 0) for _, matche := range matches { @@ -306,7 +309,7 @@ func (manager *SMonitorResourceManager) UpdateMonitorResourceAttachJoint(ctx con if len(resId) == 0 { continue } - monitorResources, err := manager.GetMonitorResources(monitor.MonitorResourceListInput{ResType: alertRecord.ResType, ResId: []string{resId}}) + monitorResources, err := manager.GetMonitorResources(monitor.MonitorResourceListInput{ResType: resType, ResId: []string{resId}}) if err != nil { errs = append(errs, errors.Wrapf(err, "SMonitorResourceManager GetMonitorResources by resId:%s err", resId)) continue