code refactor
This commit is contained in:
parent
9561275da1
commit
ef0e2b5c86
|
@ -1,5 +1,5 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
interval = 5
|
||||
|
||||
############################################################################
|
||||
# !!! uncomment [[instances]] to enable this plugin
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
## specify a list of one or more Elasticsearch servers
|
||||
# servers = ["http://localhost:9200"]
|
||||
servers = []
|
||||
servers = ["http://10.206.16.3:9200"]
|
||||
|
||||
## Timeout for HTTP requests to the elastic search server(s)
|
||||
http_timeout = "5s"
|
||||
|
@ -49,7 +49,7 @@ indices_level = "shards"
|
|||
|
||||
## HTTP Basic Authentication username and password.
|
||||
username = "elastic"
|
||||
password = "password"
|
||||
password = "MhxzKhl@FC"
|
||||
|
||||
## Optional TLS Config
|
||||
# use_tls = false
|
||||
|
|
|
@ -110,8 +110,8 @@ func (r *Elasticsearch) Init() error {
|
|||
}
|
||||
|
||||
for i := 0; i < len(r.Instances); i++ {
|
||||
if len(r.Instances[i].Servers) == 0 {
|
||||
log.Println("W! servers empty")
|
||||
if r.Instances[i].TargetsEmpty() {
|
||||
log.Println("W! targets empty")
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,10 @@ func (r *Elasticsearch) Gather(slist *list.SafeList) {
|
|||
for i := range r.Instances {
|
||||
ins := r.Instances[i]
|
||||
|
||||
if ins.TargetsEmpty() {
|
||||
continue
|
||||
}
|
||||
|
||||
r.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer r.waitgrp.Done()
|
||||
|
@ -182,6 +186,10 @@ func (i serverInfo) isMaster() bool {
|
|||
return i.nodeID == i.masterID
|
||||
}
|
||||
|
||||
func (ins *Instance) TargetsEmpty() bool {
|
||||
return len(ins.Servers) == 0
|
||||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.HTTPTimeout <= 0 {
|
||||
ins.HTTPTimeout = config.Duration(time.Second * 5)
|
||||
|
|
Loading…
Reference in New Issue