| | |
| | | package service |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "basic.com/valib/logger.git" |
| | | "encoding/json" |
| | | "fmt" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | | "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": [{ |
| | |
| | | }, |
| | | { |
| | | "terms": { |
| | | "analyServerId": ["` + sysconf.ServerId + `",""] |
| | | "analyServerId": ["` + localConf.ServerId + `",""] |
| | | } |
| | | } |
| | | ] |
| | |
| | | "size": 10000 |
| | | } |
| | | ` |
| | | buf, err := esutil.EsReq("POST", url, []byte(jsonDsl)) |
| | | buf, err := esutil.EsReq("POST", url, []byte(jsonDSL)) |
| | | if err != nil { |
| | | logger.Debug(err) |
| | | } |
| | |
| | | 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 := ` |
| | | { |
| | |
| | | } |
| | | 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, |
| | | // }) |
| | | //} |
| | | message = "修改成功" |
| | | } |
| | | return message |