Repository: ClusterLabs/ha_cluster_exporter (go)

Issue:
regexp parsing corosync-cfgtool output will not work
In collector/corosync/parser.go line 154
There is a bug in the regexp when parsing corosync-cfgtool -s output:
```re := regexp.MustCompile(`(?m)(?P<prefix>RING|Link) ID (?P<number>\d+)\s+(?P<id>id|addr) \s*= (?P<address>.+)\s+status \s*= (?P<status>.+)`)```
corosync-cfgtool outputs a tab character after "id" and "status", so the regexp with an additional space after id/status will not match. Without the spaces in front of "\s" the regexp will work. 
```...(?P<id>id|addr)\s*= (?P<address>.+)\s+status\s*=...```
  

Pull request description:
fine tune regexp and test case with tabs
fixes #215 

Patch:
diff --git a/collector/corosync/parser.go b/collector/corosync/parser.go
index af7abba..f7f934d 100644
--- a/collector/corosync/parser.go
+++ b/collector/corosync/parser.go
@@ -151,7 +151,7 @@ func parseRings(cfgToolOutput []byte) []Ring {
 	   	addr	= 192.168.125.15
 	   	status	= ring 0 active with no faults
 	*/
-	re := regexp.MustCompile(`(?m)(?P<prefix>RING|Link) ID (?P<number>\d+)\s+(?P<id>id|addr) \s*= (?P<address>.+)\s+status \s*= (?P<status>.+)`)
+	re := regexp.MustCompile(`(?m)(?P<prefix>RING|Link) ID (?P<number>\d+)\s+(?P<id>id|addr)\s+= (?P<address>.+)\s+status\s+= (?P<status>.+)`)
 	matches := re.FindAllSubmatch(cfgToolOutput, -1)
 	rings := make([]Ring, len(matches))
 	for i, match := range matches {
@@ -227,7 +227,7 @@ func parseMembers(quorumToolOutput []byte) (members []Member, err error) {
 	/*
 		1          1  A,V,NMW 192.168.125.24 (local)
 	*/
-	linesRE := regexp.MustCompile(`(?m)(?P<node_id>\w+)\s+(?P<votes>\d+)\s+(?P<qdevice>(\w,?)+)?\s+(?P<name>[\w-\.]+)(?:\s(?P<local>\(local\)))?\n?`)
+	linesRE := regexp.MustCompile(`(?m)(?P<node_id>\w+)\s+(?P<votes>\d+)\s+(?P<qdevice>(\w,?)+)?\s+(?P<name>[\w-.]+)(?:\s(?P<local>\(local\)))?\n?`)
 	linesMatches := linesRE.FindAllSubmatch(sectionMatch[1], -1)
 	for _, match := range linesMatches {
 		matches := extractRENamedCaptureGroups(linesRE, match)


Test patch:
diff --git a/collector/corosync/parser_test.go b/collector/corosync/parser_test.go
index cdf21c3..13dba84 100644
--- a/collector/corosync/parser_test.go
+++ b/collector/corosync/parser_test.go
@@ -13,11 +13,11 @@ func TestParse(t *testing.T) {
 	cfgToolOutput := []byte(`Printing link status.
 Local node ID 1084780051
 Link ID 0
-		addr      = 10.0.0.1
-		status    = OK
+		addr	= 10.0.0.1
+		status	= OK
 Link ID 1
-		addr      = 172.16.0.1
-		status    = OK`)
+        addr      = 172.16.0.1
+        status    = OK`)
 
 	quoromToolOutput := []byte(`Quorum information
 ------------------