Skip to content

Commit

Permalink
Merge pull request #48 from vvanholl/master
Browse files Browse the repository at this point in the history
Added CLUSTER INFO support when cluster enabled
  • Loading branch information
oliver006 authored Dec 23, 2016
2 parents 45ed897 + d2186f9 commit 52c7713
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions exporter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ var (
"used_cpu_user": "used_cpu_user",
"used_cpu_sys_children": "used_cpu_sys_children",
"used_cpu_user_children": "used_cpu_user_children",

// # Cluster
"cluster_stats_messages_sent": "cluster_messages_sent_total",
"cluster_stats_messages_received": "cluster_messages_received_total",
}
)

Expand Down Expand Up @@ -439,13 +443,23 @@ func (e *Exporter) scrape(scrapes chan<- scrapeResult) {
info, err := redis.String(c.Do("INFO", "ALL"))
if err == nil {
err = e.extractInfoMetrics(info, addr, scrapes)
}
if err != nil {
} else {
log.Printf("redis err: %s", err)
errorCount++
continue
}

if strings.Index(info, "cluster_enabled:1") != -1 {
info, err = redis.String(c.Do("CLUSTER", "INFO"))
if err == nil {
err = e.extractInfoMetrics(info, addr, scrapes)
} else {
log.Printf("redis err: %s", err)
errorCount++
continue
}
}

scrapes <- scrapeResult{Name: "up", Addr: addr, Value: 1}

if config, err := redis.Strings(c.Do("CONFIG", "GET", "maxmemory")); err == nil {
Expand Down

0 comments on commit 52c7713

Please sign in to comment.