count host from .infini_host priority
This commit is contained in:
parent
43b6322188
commit
320ee33390
|
@ -6,6 +6,7 @@ import (
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
"infini.sh/framework/core/elastic"
|
"infini.sh/framework/core/elastic"
|
||||||
"infini.sh/framework/core/event"
|
"infini.sh/framework/core/event"
|
||||||
|
"infini.sh/framework/core/host"
|
||||||
"infini.sh/framework/core/orm"
|
"infini.sh/framework/core/orm"
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -80,10 +81,19 @@ func (handler APIHandler) ElasticsearchOverviewAction(w http.ResponseWriter, req
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hostCount, err := handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "metadata.host", clusterIDs)
|
hostCount, err := handler.getMetricCount(orm.GetIndexName(host.HostInfo{}), "ip", nil)
|
||||||
if err != nil{
|
if err != nil{
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
log.Info(hostCount)
|
||||||
|
if v, ok := hostCount.(float64); ok && v == 0 {
|
||||||
|
log.Error("sss")
|
||||||
|
hostCount, err = handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "metadata.host", clusterIDs)
|
||||||
|
if err != nil{
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nodeCount, err := handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "id", clusterIDs)
|
nodeCount, err := handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "id", clusterIDs)
|
||||||
if err != nil{
|
if err != nil{
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *ht
|
||||||
_, _, idxs, err := client.GetMapping(copyAll, indexName)
|
_, _, idxs, err := client.GetMapping(copyAll, indexName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err.Error()
|
||||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -91,14 +91,14 @@ func (handler APIHandler) HandleUpdateSettingsAction(w http.ResponseWriter, req
|
||||||
err := handler.DecodeJSON(req, &settings)
|
err := handler.DecodeJSON(req, &settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err.Error()
|
||||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = client.UpdateIndexSettings(indexName, settings)
|
err = client.UpdateIndexSettings(indexName, settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err.Error()
|
||||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ func (handler APIHandler) HandleDeleteIndexAction(w http.ResponseWriter, req *ht
|
||||||
err := client.DeleteIndex(indexName)
|
err := client.DeleteIndex(indexName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err.Error()
|
||||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -132,14 +132,14 @@ func (handler APIHandler) HandleCreateIndexAction(w http.ResponseWriter, req *ht
|
||||||
err := handler.DecodeJSON(req, &config)
|
err := handler.DecodeJSON(req, &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err.Error()
|
||||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = client.CreateIndex(indexName, config)
|
err = client.CreateIndex(indexName, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err.Error()
|
||||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue