From 4c7890a506f95bfc8d06a75dbf6150bb8fcad1bb Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期六, 28 九月 2019 15:28:32 +0800 Subject: [PATCH] add logger --- service/EnableStatusControlService.go | 63 +++++++++++++++++-------------- 1 files changed, 35 insertions(+), 28 deletions(-) diff --git a/service/EnableStatusControlService.go b/service/EnableStatusControlService.go index 7206b0b..a0439b1 100644 --- a/service/EnableStatusControlService.go +++ b/service/EnableStatusControlService.go @@ -1,25 +1,27 @@ package service import ( - "basic.com/dbapi.git" - "basic.com/pubsub/protomsg.git" + "basic.com/valib/logger.git" "encoding/json" "fmt" "strconv" "strings" "time" - "webserver/discovery" + "webserver/cache" "webserver/extend/config" "webserver/extend/esutil" - "webserver/extend/logger" ) func GetVerificationData() []map[string]interface{} { - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + + localConf, err2 := cache.GetServerInfo() + if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { + logger.Debug("localConfig is wrong!!!") + return nil + } + url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_search" - var setApi dbapi.SysSetApi - _, sysconf := setApi.GetServerInfo() - jsonDsl := `{ + + jsonDSL := `{ "query": { "bool": { "filter": [{ @@ -29,7 +31,7 @@ }, { "terms": { - "analyServerId": ["` + sysconf.ServerId + `",""] + "analyServerId": ["` + localConf.ServerId + `",""] } } ] @@ -38,7 +40,7 @@ "size": 10000 } ` - buf, err := esutil.EsReq("POST", url, []byte(jsonDsl)) + buf, err := esutil.EsReq("POST", url, []byte(jsonDSL)) if err != nil { logger.Debug(err) } @@ -85,7 +87,12 @@ status = 1 } enable := strconv.Itoa(status) - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + + localConf, err2 := cache.GetServerInfo() + if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { + logger.Debug("localConfig is wrong!!!") + return "localConf wrong" + } + url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_update_by_query?refresh" jsonDsl := ` { @@ -119,23 +126,23 @@ } if middle > 0 { logger.Debug("淇敼鎴愬姛") - if flag {//鐢熸晥鐨� - discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ - Type: protomsg.EsCacheChanged_T_DbTable, - PersonId: "", - TableId: id, - Feature: "", - Action: protomsg.DbAction_Insert, - }) - } else {//澶辨晥鐨� - discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ - Type: protomsg.EsCacheChanged_T_DbTable, - PersonId: "", - TableId: id, - Feature: "", - Action: protomsg.DbAction_Insert, - }) - } + //if flag {//鐢熸晥鐨� + // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ + // Type: protomsg.EsCacheChanged_T_DbTable, + // PersonId: "", + // TableId: id, + // Feature: "", + // Action: protomsg.DbAction_Insert, + // }) + //} else {//澶辨晥鐨� + // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ + // Type: protomsg.EsCacheChanged_T_DbTable, + // PersonId: "", + // TableId: id, + // Feature: "", + // Action: protomsg.DbAction_Insert, + // }) + //} message = "淇敼鎴愬姛" } return message -- Gitblit v1.8.0