From ca54e639d2addb9a9e1c6cb927dcde90adbc0314 Mon Sep 17 00:00:00 2001 From: adivinho Date: Thu, 28 May 2020 18:38:23 +0300 Subject: [PATCH 1/3] Fixed output value of wsrep_cluster_status Signed-off-by: adivinho --- collector/collector.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 444adf8a8..99a29a713 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -52,11 +52,11 @@ func parseStatus(data sql.RawBytes) (float64, bool) { if bytes.Equal(data, []byte("Connecting")) { return 0, true } - // SHOW GLOBAL STATUS like 'wsrep_cluster_status' can return "Primary" or "Non-Primary"/"Disconnected" + // SHOW GLOBAL STATUS like 'wsrep_cluster_status' can return "Primary" or "non-Primary"/"Disconnected" if bytes.Equal(data, []byte("Primary")) { return 1, true } - if bytes.Equal(data, []byte("Non-Primary")) || bytes.Equal(data, []byte("Disconnected")) { + if bytes.Equal(data, []byte("non-Primary")) || bytes.Equal(data, []byte("Disconnected")) { return 0, true } if logNum := logRE.Find(data); logNum != nil { From aa789db8e87f94e50311cc877fe817f15f76dd62 Mon Sep 17 00:00:00 2001 From: adivinho Date: Mon, 1 Jun 2020 11:30:33 +0300 Subject: [PATCH 2/3] Fixed output value of wsrep_cluster_status Signed-off-by: adivinho --- CHANGELOG.md | 1 + collector/collector.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4de0c482d..b4fe5c8e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * [FEATURE] Add `tls.insecure-skip-verify` flag to ignore tls verification errors (PR #417) #348 * [FEATURE] Add new metrics to `replication_group_member_stats` collector to support MySQL 8.x. * [FEATURE] Add collector for `replication_group_members` (PR #459) #362 +* [BUGFIX] Fixed output value of wsrep_cluster_status #473 ### BREAKING CHANGES: diff --git a/collector/collector.go b/collector/collector.go index 99a29a713..3583a61f5 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -56,7 +56,7 @@ func parseStatus(data sql.RawBytes) (float64, bool) { if bytes.Equal(data, []byte("Primary")) { return 1, true } - if bytes.Equal(data, []byte("non-Primary")) || bytes.Equal(data, []byte("Disconnected")) { + if strings.EqualFold(string(data), "non-Primary") || bytes.Equal(data, []byte("Disconnected")) { return 0, true } if logNum := logRE.Find(data); logNum != nil { From 5ee832216df022d35615d1cd9f66230a00b88588 Mon Sep 17 00:00:00 2001 From: adivinho Date: Mon, 1 Jun 2020 13:01:37 +0300 Subject: [PATCH 3/3] Fixed output value of wsrep_cluster_status Signed-off-by: adivinho --- collector/collector.go | 1 + 1 file changed, 1 insertion(+) diff --git a/collector/collector.go b/collector/collector.go index 3583a61f5..8a624161b 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -18,6 +18,7 @@ import ( "database/sql" "regexp" "strconv" + "strings" "github.com/prometheus/client_golang/prometheus" )