From 1627e3004ab275e19ac36e820cc883724b6146b4 Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Thu, 15 Jun 2023 14:11:44 +0800 Subject: [PATCH] remove monitortargets function from galaops plugin --- gala-ops/server/httphandler/agent.go | 10 ------- gala-ops/server/main.go | 6 ---- gala-ops/server/plugin/prometheus.go | 45 ---------------------------- 3 files changed, 61 deletions(-) diff --git a/gala-ops/server/httphandler/agent.go b/gala-ops/server/httphandler/agent.go index 8fb93c8c..bf7403a1 100644 --- a/gala-ops/server/httphandler/agent.go +++ b/gala-ops/server/httphandler/agent.go @@ -8,7 +8,6 @@ import ( "gitee.com/openeuler/PilotGo-plugins/sdk/common" "gitee.com/openeuler/PilotGo-plugins/sdk/plugin/client" "github.com/gin-gonic/gin" - "openeuler.org/PilotGo/gala-ops-plugin/plugin" ) func InstallGopher(ctx *gin.Context) { @@ -37,7 +36,6 @@ func InstallGopher(ctx *gin.Context) { } ret := []interface{}{} - monitorTargets := []string{} for _, result := range cmdResults { d := struct { MachineUUID string @@ -53,18 +51,10 @@ func InstallGopher(ctx *gin.Context) { if result.RetCode != 0 { d.InstallStatus = "error" d.Error = result.Stderr - } else { - // TODO: add gala-gopher to prometheus monitor target here - // default exporter port :8888 - monitorTargets = append(monitorTargets, result.MachineIP+":8888") } ret = append(ret, d) } - err = plugin.MonitorTargets(monitorTargets, Galaops.PromePlugin["url"].(string)) - if err != nil { - fmt.Println("error: failed to add gala-gopher to prometheus monitor targets") - } ctx.JSON(http.StatusOK, gin.H{ "code": 0, diff --git a/gala-ops/server/main.go b/gala-ops/server/main.go index fee8ff69..96badbfc 100644 --- a/gala-ops/server/main.go +++ b/gala-ops/server/main.go @@ -41,12 +41,6 @@ func main() { // 临时给server赋值 PluginClient.Server = "http://192.168.75.100:8888" - // PromePlugin, err := client.GetClient().GetPluginInfo("prometheus") - // if err != nil { - // logger.Error("failed to get plugin info from pilotgoserver: ", err) - // os.Exit(1) - // } - httphandler.Galaops = &httphandler.Opsclient{ Sdkmethod: PluginClient, PromePlugin: nil, diff --git a/gala-ops/server/plugin/prometheus.go b/gala-ops/server/plugin/prometheus.go index a6699f09..b0736c3a 100644 --- a/gala-ops/server/plugin/prometheus.go +++ b/gala-ops/server/plugin/prometheus.go @@ -1,46 +1 @@ package plugin - -import ( - "gitee.com/openeuler/PilotGo-plugins/sdk/plugin/client" -) - -// 请求prometheus插件接口,将gala-ops targets添加到监控清单当中 -func addTargets(targets []string, url string) error { - // TODO: - // jobName := "gala-gopher" - // url := url+"/api/add_targets" - - return nil -} - -func MonitorTargets(targets []string, promeurl string) error { - // plugin, err := client.GetClient().GetPluginInfo("prometheus") - // if err != nil { - // return err - // } - - if err := addTargets(targets, promeurl); err != nil { - return err - } - - return nil -} - -func deleteTargets(targets []string, url string) error { - // TODO: - - return nil -} - -func DeleteTargets(targets []string, client *client.Client) error { - plugin, err := client.GetPluginInfo("prometheus") - if err != nil { - return err - } - - if err := deleteTargets(targets, plugin.Url); err != nil { - return err - } - - return nil -} -- Gitee