modify default settings
This commit is contained in:
parent
43fbccb1a4
commit
e9d7d50f2b
|
@ -1,11 +1,11 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# # commands, support glob
|
||||
# commands = [
|
||||
commands = [
|
||||
# "/opt/categraf/scripts/*.sh"
|
||||
# ]
|
||||
]
|
||||
|
||||
# # timeout for each command to complete
|
||||
# timeout = 5
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
# targets = [
|
||||
[[instances]]
|
||||
targets = [
|
||||
# "http://localhost",
|
||||
# "https://www.baidu.com"
|
||||
# ]
|
||||
]
|
||||
|
||||
# # append some labels for series
|
||||
# labels = { region="cloud", product="n9e" }
|
||||
|
|
|
@ -15,7 +15,8 @@ labels = { cluster="kafka-cluster-01" }
|
|||
log_level = "error"
|
||||
|
||||
# Address (host:port) of Kafka server.
|
||||
kafka_uris = ["127.0.0.1:9092","127.0.0.1:9092","127.0.0.1:9092"]
|
||||
# kafka_uris = ["127.0.0.1:9092","127.0.0.1:9092","127.0.0.1:9092"]
|
||||
kafka_uris = []
|
||||
|
||||
# Connect using SASL/PLAIN
|
||||
# Default is false
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# # append some labels for series
|
||||
# labels = { region="cloud", product="n9e" }
|
||||
|
||||
|
@ -9,7 +9,8 @@
|
|||
# interval_times = 1
|
||||
|
||||
# URL for the kubelet
|
||||
url = "https://$HOSTIP:10250"
|
||||
# url = "https://$HOSTIP:10250"
|
||||
url = ""
|
||||
|
||||
gather_system_container_metrics = true
|
||||
gather_node_metrics = true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# address = "127.0.0.1:3306"
|
||||
# username = "root"
|
||||
# password = "1234"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
# targets = [
|
||||
[[instances]]
|
||||
targets = [
|
||||
# "127.0.0.1:22",
|
||||
# "localhost:6379",
|
||||
# ":9090"
|
||||
# ]
|
||||
]
|
||||
|
||||
# # append some labels for series
|
||||
# labels = { region="cloud", product="n9e" }
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
# interval = 15
|
||||
|
||||
# exec local command
|
||||
# nvidia_smi_command = "nvidia-smi"
|
||||
# e.g. nvidia_smi_command = "nvidia-smi"
|
||||
nvidia_smi_command = ""
|
||||
|
||||
# exec remote command
|
||||
# nvidia_smi_command = "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null SSH_USER@SSH_HOST nvidia-smi"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# address = "10.1.2.3:1521/orcl"
|
||||
# username = "monitor"
|
||||
# password = "123456"
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# send ping packets to
|
||||
# targets = [
|
||||
targets = [
|
||||
# "www.baidu.com",
|
||||
# "127.0.0.1",
|
||||
# "10.4.5.6",
|
||||
# "10.4.5.7"
|
||||
# ]
|
||||
]
|
||||
|
||||
# # append some labels for series
|
||||
# labels = { region="cloud", product="n9e" }
|
||||
|
|
|
@ -2,25 +2,25 @@
|
|||
# interval = 15
|
||||
|
||||
[[instances]]
|
||||
# urls = [
|
||||
urls = [
|
||||
# "http://localhost:9104/metrics"
|
||||
# ]
|
||||
]
|
||||
|
||||
url_label_key = "instance"
|
||||
url_label_value = "{{.Host}}"
|
||||
|
||||
## Scrape Services available in Consul Catalog
|
||||
[instances.consul]
|
||||
enabled = false
|
||||
agent = "http://localhost:8500"
|
||||
query_interval = "5m"
|
||||
# [instances.consul]
|
||||
# enabled = false
|
||||
# agent = "http://localhost:8500"
|
||||
# query_interval = "5m"
|
||||
|
||||
[[instances.consul.query]]
|
||||
name = "a service name"
|
||||
tag = "a service tag"
|
||||
url = 'http://{{if ne .ServiceAddress ""}}{{.ServiceAddress}}{{else}}{{.Address}}{{end}}:{{.ServicePort}}/{{with .ServiceMeta.metrics_path}}{{.}}{{else}}metrics{{end}}'
|
||||
[instances.consul.query.tags]
|
||||
host = "{{.Node}}"
|
||||
# [[instances.consul.query]]
|
||||
# name = "a service name"
|
||||
# tag = "a service tag"
|
||||
# url = 'http://{{if ne .ServiceAddress ""}}{{.ServiceAddress}}{{else}}{{.Address}}{{end}}:{{.ServicePort}}/{{with .ServiceMeta.metrics_path}}{{.}}{{else}}metrics{{end}}'
|
||||
# [instances.consul.query.tags]
|
||||
# host = "{{.Node}}"
|
||||
|
||||
# bearer_token_string = ""
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# # Management Plugin url
|
||||
# url = "http://localhost:15672"
|
||||
# username = "guest"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# address = "127.0.0.1:6379"
|
||||
# username = ""
|
||||
# password = ""
|
||||
|
|
|
@ -7,18 +7,18 @@ switch_id_label = "ip"
|
|||
"192.168.88.160" = "switch001.bj"
|
||||
"192.168.88.161" = "switch002.bj"
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# # interval = global.interval * interval_times
|
||||
# interval_times = 1
|
||||
|
||||
# use global unique string to specify instance
|
||||
# labels = { region="beijing" }
|
||||
|
||||
# ips = [
|
||||
ips = [
|
||||
# "172.16.2.1",
|
||||
# "172.16.4/24",
|
||||
# "192.168.56.102-192.168.56.120"
|
||||
# ]
|
||||
]
|
||||
|
||||
community = "public"
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
# interval = 15
|
||||
|
||||
# Gather metrics from the Tomcat server status page.
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
## URL of the Tomcat server status
|
||||
# url = "http://127.0.0.1:8080/manager/status/all?XML=true"
|
||||
url = ""
|
||||
|
||||
## HTTP Basic Auth Credentials
|
||||
# username = "tomcat"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# # collect interval
|
||||
# interval = 15
|
||||
|
||||
# [[instances]]
|
||||
[[instances]]
|
||||
# cluster_name = "dev-zk-cluster"
|
||||
# addresses = "127.0.0.1:2181"
|
||||
# timeout = 10
|
||||
|
|
|
@ -59,6 +59,9 @@ func (e *Exec) Init() error {
|
|||
}
|
||||
|
||||
for i := 0; i < len(e.Instances); i++ {
|
||||
if len(e.Instances[i].Commands) == 0 {
|
||||
continue
|
||||
}
|
||||
if e.Instances[i].DataFormat == "" || e.Instances[i].DataFormat == "influx" {
|
||||
e.Instances[i].parser = influx.NewParser()
|
||||
} else if e.Instances[i].DataFormat == "falcon" {
|
||||
|
@ -82,6 +85,9 @@ func (e *Exec) Gather(slist *list.SafeList) {
|
|||
wg.Add(len(e.Instances))
|
||||
for i := range e.Instances {
|
||||
ins := e.Instances[i]
|
||||
if len(ins.Commands) == 0 {
|
||||
continue
|
||||
}
|
||||
go e.GatherOnce(&wg, slist, ins)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package http_response
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -59,6 +58,10 @@ type httpClient interface {
|
|||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if len(ins.Targets) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.ResponseTimeout < config.Duration(time.Second) {
|
||||
ins.ResponseTimeout = config.Duration(time.Second * 3)
|
||||
}
|
||||
|
@ -67,10 +70,6 @@ func (ins *Instance) Init() error {
|
|||
ins.Method = "GET"
|
||||
}
|
||||
|
||||
if len(ins.Targets) == 0 {
|
||||
return errors.New("http_response targets empty")
|
||||
}
|
||||
|
||||
client, err := ins.createHTTPClient()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create http client: %v", err)
|
||||
|
@ -174,6 +173,9 @@ func (h *HTTPResponse) Gather(slist *list.SafeList) {
|
|||
atomic.AddUint64(&h.Counter, 1)
|
||||
for i := range h.Instances {
|
||||
ins := h.Instances[i]
|
||||
if len(ins.Targets) == 0 {
|
||||
continue
|
||||
}
|
||||
h.wg.Add(1)
|
||||
go h.gatherOnce(slist, ins)
|
||||
}
|
||||
|
|
|
@ -70,6 +70,10 @@ func (r *Kafka) Gather(slist *list.SafeList) {
|
|||
for i := range r.Instances {
|
||||
ins := r.Instances[i]
|
||||
|
||||
if len(ins.KafkaURIs) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
r.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer r.waitgrp.Done()
|
||||
|
@ -159,8 +163,9 @@ type Instance struct {
|
|||
|
||||
func (ins *Instance) Init() error {
|
||||
if len(ins.KafkaURIs) == 0 || ins.KafkaURIs[0] == "" {
|
||||
return fmt.Errorf("kafka_uris must be specified")
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.UseTLS && (ins.CertFile == "" || ins.KeyFile == "") {
|
||||
return fmt.Errorf("tls is enabled but key pair was not provided")
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package kubernetes
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -64,6 +63,10 @@ func (k *Kubernetes) Gather(slist *list.SafeList) {
|
|||
for i := range k.Instances {
|
||||
ins := k.Instances[i]
|
||||
|
||||
if ins.URL == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
k.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer k.waitgrp.Done()
|
||||
|
@ -113,7 +116,7 @@ type Instance struct {
|
|||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.URL == "" {
|
||||
return errors.New("url is blank")
|
||||
return nil
|
||||
}
|
||||
|
||||
ins.URL = os.Expand(ins.URL, config.GetEnv)
|
||||
|
@ -185,10 +188,10 @@ func (ins *Instance) buildPodMetrics(summaryMetrics *SummaryMetrics, podInfo []M
|
|||
if ins.GatherPodContainerMetrics {
|
||||
for _, container := range pod.Containers {
|
||||
tags := map[string]string{
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
"namespace": pod.PodRef.Namespace,
|
||||
"container": container.Name,
|
||||
"pod": pod.PodRef.Name,
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
"namespace": pod.PodRef.Namespace,
|
||||
"container": container.Name,
|
||||
"pod": pod.PodRef.Name,
|
||||
}
|
||||
for k, v := range podLabels {
|
||||
tags[k] = v
|
||||
|
@ -214,10 +217,10 @@ func (ins *Instance) buildPodMetrics(summaryMetrics *SummaryMetrics, podInfo []M
|
|||
if ins.GatherPodVolumeMetrics {
|
||||
for _, volume := range pod.Volumes {
|
||||
tags := map[string]string{
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
"pod": pod.PodRef.Name,
|
||||
"namespace": pod.PodRef.Namespace,
|
||||
"volume": volume.Name,
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
"pod": pod.PodRef.Name,
|
||||
"namespace": pod.PodRef.Namespace,
|
||||
"volume": volume.Name,
|
||||
}
|
||||
for k, v := range podLabels {
|
||||
tags[k] = v
|
||||
|
@ -252,8 +255,8 @@ func (ins *Instance) buildPodMetrics(summaryMetrics *SummaryMetrics, podInfo []M
|
|||
func (ins *Instance) buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, slist *list.SafeList) {
|
||||
for _, container := range summaryMetrics.Node.SystemContainers {
|
||||
tags := map[string]string{
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
"container": container.Name,
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
"container": container.Name,
|
||||
}
|
||||
|
||||
fields := make(map[string]interface{})
|
||||
|
@ -275,7 +278,7 @@ func (ins *Instance) buildSystemContainerMetrics(summaryMetrics *SummaryMetrics,
|
|||
|
||||
func (ins *Instance) buildNodeMetrics(summaryMetrics *SummaryMetrics, slist *list.SafeList) {
|
||||
tags := map[string]string{
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
"node": summaryMetrics.Node.NodeName,
|
||||
}
|
||||
fields := make(map[string]interface{})
|
||||
fields["node_cpu_usage_nanocores"] = summaryMetrics.Node.CPU.UsageNanoCores
|
||||
|
|
|
@ -2,7 +2,6 @@ package mysql
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
|
@ -55,7 +54,7 @@ type Instance struct {
|
|||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.Address == "" {
|
||||
return errors.New("address is blank")
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.UseTLS {
|
||||
|
@ -189,6 +188,9 @@ func (m *MySQL) Gather(slist *list.SafeList) {
|
|||
atomic.AddUint64(&m.Counter, 1)
|
||||
for i := range m.Instances {
|
||||
ins := m.Instances[i]
|
||||
if len(ins.Address) == 0 {
|
||||
continue
|
||||
}
|
||||
m.wg.Add(1)
|
||||
go m.gatherOnce(slist, ins)
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ type Instance struct {
|
|||
|
||||
func (ins *Instance) Init() error {
|
||||
if len(ins.Targets) == 0 {
|
||||
return errors.New("targets empty")
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.Protocol == "" {
|
||||
|
@ -121,6 +121,9 @@ func (n *NetResponse) Gather(slist *list.SafeList) {
|
|||
atomic.AddUint64(&n.Counter, 1)
|
||||
for i := range n.Instances {
|
||||
ins := n.Instances[i]
|
||||
if len(ins.Targets) == 0 {
|
||||
continue
|
||||
}
|
||||
n.wg.Add(1)
|
||||
go n.gatherOnce(slist, ins)
|
||||
}
|
||||
|
|
|
@ -62,6 +62,10 @@ func (r *NginxUpstreamCheck) Gather(slist *list.SafeList) {
|
|||
for i := range r.Instances {
|
||||
ins := r.Instances[i]
|
||||
|
||||
if len(ins.Targets) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
r.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer r.waitgrp.Done()
|
||||
|
@ -103,6 +107,10 @@ type httpClient interface {
|
|||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if len(ins.Targets) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.Timeout < config.Duration(time.Second) {
|
||||
ins.Timeout = config.Duration(time.Second * 5)
|
||||
}
|
||||
|
@ -111,10 +119,6 @@ func (ins *Instance) Init() error {
|
|||
ins.Method = "GET"
|
||||
}
|
||||
|
||||
if len(ins.Targets) == 0 {
|
||||
return types.ErrInstancesEmpty
|
||||
}
|
||||
|
||||
client, err := ins.createHTTPClient()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create http client: %v", err)
|
||||
|
|
|
@ -39,8 +39,7 @@ func (s *GPUStats) Drop() {}
|
|||
|
||||
func (s *GPUStats) Init() error {
|
||||
if s.NvidiaSmiCommand == "" {
|
||||
// do nothing
|
||||
return nil
|
||||
return types.ErrInstancesEmpty
|
||||
}
|
||||
|
||||
qFieldsOrdered, qFieldToRFieldMap, err := buildQFieldToRFieldMap(s.QueryFieldNames, s.NvidiaSmiCommand)
|
||||
|
|
|
@ -76,7 +76,7 @@ func (o *Oracle) Init() error {
|
|||
for i := 0; i < len(o.Instances); i++ {
|
||||
dbConf := o.Instances[i]
|
||||
if dbConf.Address == "" {
|
||||
return fmt.Errorf("some oracle address is blank")
|
||||
continue
|
||||
}
|
||||
connString := getConnectionString(dbConf)
|
||||
db, err := sqlx.Open("godror", connString)
|
||||
|
@ -105,6 +105,9 @@ func (o *Oracle) Gather(slist *list.SafeList) {
|
|||
atomic.AddUint64(&o.Counter, 1)
|
||||
for i := range o.Instances {
|
||||
ins := o.Instances[i]
|
||||
if ins.Address == "" {
|
||||
continue
|
||||
}
|
||||
o.wg.Add(1)
|
||||
go o.gatherOnce(slist, ins)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ type Instance struct {
|
|||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if len(ins.Targets) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.Count < 1 {
|
||||
ins.Count = 1
|
||||
}
|
||||
|
@ -113,6 +117,9 @@ func (p *Ping) Gather(slist *list.SafeList) {
|
|||
atomic.AddUint64(&p.Counter, 1)
|
||||
for i := range p.Instances {
|
||||
ins := p.Instances[i]
|
||||
if len(ins.Targets) == 0 {
|
||||
continue
|
||||
}
|
||||
p.wg.Add(1)
|
||||
go p.gatherOnce(slist, ins)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package prometheus
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -46,17 +47,29 @@ type Instance struct {
|
|||
client *http.Client
|
||||
}
|
||||
|
||||
func (ins *Instance) Empty() bool {
|
||||
if len(ins.URLs) > 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
if ins.ConsulConfig.Enabled && len(ins.ConsulConfig.Queries) > 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.ConsulConfig.Enabled {
|
||||
if len(ins.ConsulConfig.Queries) == 0 {
|
||||
return types.ErrInstancesEmpty
|
||||
}
|
||||
if ins.Empty() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.ConsulConfig.Enabled && len(ins.ConsulConfig.Queries) > 0 {
|
||||
if err := ins.InitConsulClient(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if len(ins.URLs) == 0 {
|
||||
return types.ErrInstancesEmpty
|
||||
}
|
||||
|
||||
for i, u := range ins.URLs {
|
||||
ins.URLs[i] = strings.Replace(u, "$hostname", config.Config.GetHostname(), -1)
|
||||
ins.URLs[i] = strings.Replace(u, "$ip", config.Config.Global.IP, -1)
|
||||
|
@ -139,7 +152,9 @@ func (p *Prometheus) Init() error {
|
|||
|
||||
for i := 0; i < len(p.Instances); i++ {
|
||||
if err := p.Instances[i].Init(); err != nil {
|
||||
return err
|
||||
if !errors.Is(err, types.ErrInstancesEmpty) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,6 +169,10 @@ func (p *Prometheus) Gather(slist *list.SafeList) {
|
|||
for i := range p.Instances {
|
||||
ins := p.Instances[i]
|
||||
|
||||
if ins.Empty() {
|
||||
continue
|
||||
}
|
||||
|
||||
p.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer p.waitgrp.Done()
|
||||
|
|
|
@ -2,7 +2,6 @@ package rabbitmq
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
|
@ -60,6 +59,10 @@ func (r *RabbitMQ) Gather(slist *list.SafeList) {
|
|||
for i := range r.Instances {
|
||||
ins := r.Instances[i]
|
||||
|
||||
if ins.URL == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
r.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer r.waitgrp.Done()
|
||||
|
@ -111,7 +114,7 @@ type Instance struct {
|
|||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.URL == "" {
|
||||
return errors.New("url is blank")
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
|
|
@ -44,6 +44,10 @@ type Instance struct {
|
|||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.Address == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
redisOptions := &redis.Options{
|
||||
Addr: ins.Address,
|
||||
Username: ins.Username,
|
||||
|
@ -107,6 +111,9 @@ func (r *Redis) Gather(slist *list.SafeList) {
|
|||
atomic.AddUint64(&r.Counter, 1)
|
||||
for i := range r.Instances {
|
||||
ins := r.Instances[i]
|
||||
if ins.Address == "" {
|
||||
continue
|
||||
}
|
||||
r.wg.Add(1)
|
||||
go r.gatherOnce(slist, ins)
|
||||
}
|
||||
|
|
|
@ -64,6 +64,10 @@ func (s *Switch) Gather(slist *list.SafeList) {
|
|||
for i := range s.Instances {
|
||||
ins := s.Instances[i]
|
||||
|
||||
if len(ins.IPs) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
s.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer s.waitgrp.Done()
|
||||
|
@ -138,6 +142,10 @@ type Custom struct {
|
|||
}
|
||||
|
||||
func (ins *Instance) Init() error {
|
||||
if len(ins.IPs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
ips := ins.parseIPs()
|
||||
if len(ips) == 0 {
|
||||
return errors.New("ips empty")
|
||||
|
@ -633,10 +641,9 @@ func (ins *Instance) parseIPs() (lst []string) {
|
|||
item := ins.IPs[i]
|
||||
|
||||
aip := sw.ParseIp(item)
|
||||
for _, ip := range aip {
|
||||
lst = append(lst, ip)
|
||||
}
|
||||
lst = append(lst, aip...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package tomcat
|
|||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -80,7 +79,7 @@ type Instance struct {
|
|||
|
||||
func (ins *Instance) Init() error {
|
||||
if ins.URL == "" {
|
||||
return errors.New("url is blank")
|
||||
return nil
|
||||
}
|
||||
|
||||
if ins.Timeout <= 0 {
|
||||
|
@ -170,6 +169,9 @@ func (t *Tomcat) Gather(slist *list.SafeList) {
|
|||
atomic.AddUint64(&t.Counter, 1)
|
||||
for i := range t.Instances {
|
||||
ins := t.Instances[i]
|
||||
if ins.URL == "" {
|
||||
continue
|
||||
}
|
||||
t.wg.Add(1)
|
||||
go t.gatherOnce(slist, ins)
|
||||
}
|
||||
|
|
|
@ -94,6 +94,10 @@ func (z *Zookeeper) Gather(slist *list.SafeList) {
|
|||
for i := range z.Instances {
|
||||
ins := z.Instances[i]
|
||||
|
||||
if len(ins.Addresses) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
z.waitgrp.Add(1)
|
||||
go func(slist *list.SafeList, ins *Instance) {
|
||||
defer z.waitgrp.Done()
|
||||
|
|
Loading…
Reference in New Issue