Repository: ClusterLabs/ha_cluster_exporter
Pull request #102 (2019-11-27 20:01:05)

OBS automated releases
This PR adds automated releases to OBS and automatic assets uploads in GH releases.

To perform a release, just create a release/tag in GH, or even push a tag from a local clone.

This required setting some environment variables in Travis, which I already have taken care of.

It is also possible to produce the obs working directory locally by running `VERSION=$TAG make obs-workdir`, which will prepare everything in the temporary directory `build/obs`, and then commit to OBS with `make obs-commit`.
These make targets assume a configured `osc` host, which in Travis is provided with Docker.


Patch:
diff --git a/.ci/gh_release_to_obs_changeset.py b/.ci/gh_release_to_obs_changeset.py
new file mode 100755
index 0000000..8d326f1
--- /dev/null
+++ b/.ci/gh_release_to_obs_changeset.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+
+import argparse
+import json
+import sys
+import textwrap
+from urllib import request
+import urllib.error
+from datetime import datetime
+from datetime import timezone
+import tempfile
+
+parser = argparse.ArgumentParser(description="Add a GitHub release to an RPM changelog", usage=argparse.SUPPRESS)
+parser.add_argument("repo", help="GitHub repository (owner/name)")
+parser.add_argument("-t", "--tag", help="A specific Git tag to get; if none, latest will be used")
+parser.add_argument("-a", "--author", help="The author of the RPM changelog entry")
+parser.add_argument("-f", "--file", help="Prepend the new changelog entry to file instead of printing in stdout")
+
+if len(sys.argv) == 1:
+    parser.print_help(sys.stderr)
+    sys.exit(1)
+
+args = parser.parse_args()
+
+releaseSegment = f"/tags/{args.tag}" if args.tag else "/latest"
+url = f'https://api.github.com/repos/{args.repo}/releases{releaseSegment}'
+
+try:
+    response = request.urlopen(url)
+except urllib.error.HTTPError as error:
+    print(f"GitHub API responded with a {error.code} error!", file=sys.stderr)
+    print("Url:", url, file=sys.stderr)
+    print("Response:", json.dumps(json.load(error), indent=4), file=sys.stderr, sep="\n")
+    sys.exit(1)
+
+release = json.load(response)
+
+releaseDate = datetime.strptime(release['published_at'], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc)
+
+with tempfile.TemporaryFile("r+") as temp:
+    print("-------------------------------------------------------------------", file=temp)
+
+    print(f"{releaseDate.strftime('%c')} {releaseDate.strftime('%Z')}", end="", file=temp)
+    if args.author:
+        print(f" - {args.author}", end="", file=temp)
+    print("\n", file=temp)
+
+    print(f"- Release {args.tag}", end="", file=temp)
+    if release['name'] and release['name'] != args.tag:
+        print(f" - {release['name']}", end="", file=temp)
+    print("\n", file=temp)
+
+    if release['body']:
+        print(textwrap.indent(release['body'], "  "), file=temp, end="\n\n")
+    temp.seek(0)
+
+    if args.file:
+        with open(args.file, "r") as prev:
+            old = prev.read()
+        with open(args.file, "w") as new:
+            for line in temp:
+                new.write(line)
+            new.write(old)
+        sys.exit(0)
+
+    print(temp.read())
diff --git a/.ci/init_osc_creds.sh b/.ci/init_osc_creds.sh
new file mode 100755
index 0000000..d203605
--- /dev/null
+++ b/.ci/init_osc_creds.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+set -e
+
+# this file is intended to be run inside a shap/continuous_deliver container
+# see https://github.com/arbulu89/continuous-delivery
+
+source /scripts/utils.sh
+
+OSCRC_FILE=${OSCRC_FILE:=/root/.config/osc/oscrc}
+
+check_user
diff --git a/.gitignore b/.gitignore
index 3277347..0b72cd6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ ha_cluster_exporter
 
 # we don't use vendoring
 /vendor
+/build
diff --git a/.travis.yml b/.travis.yml
index b3d7fcb..0976da2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,10 @@
-sudo:     false
 language: go
 go:
-  - 1.11.x
-env:
-  - GO111MODULE=on
+  - "stable"
+
+cache:
+  directories:
+    - $GOPATH/pkg/mod
 
 jobs:
   include:
@@ -13,6 +14,26 @@ jobs:
     - stage: Test
       name: Unit tests
       script: make test
-    - stage: Release
-      script: make release
+    - stage: Build & release
       if: tag IS present
+      services:
+        - docker
+      env:
+        - VERSION=$TRAVIS_TAG
+      script:
+        - make -j4 build-all
+      deploy:
+        provider: releases
+        api_key: $GITHUB_OAUTH_TOKEN
+        file_glob: yes
+        file: build/bin/*
+        name: $TRAVIS_TAG
+        skip_cleanup: true
+        on:
+          tags: true
+      after_deploy:
+        - |
+          docker run --rm -t -v "$(pwd):/package" -w /package \
+          -e OBS_USER -e OBS_PASS -e OBS_PROJECT -e OBS_PACKAGE -e VERSION -e REPOSITORY=$TRAVIS_REPO_SLUG \
+          shap/continuous_deliver \
+          bash -c ".ci/init_osc_creds.sh && make obs-commit"
diff --git a/Makefile b/Makefile
index 7d4ae55..a608966 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,31 @@
-default: clean static-checks test build post-build
+# this is the what ends up in the RPM "Version" field and it is also used as suffix for the built binaries
+# it can be arbitrary for local builds, but it if you want to commit to OBS it must correspond to a Git tag with an associated GitHub release
+VERSION ?= dev
+
+# we only use this to comply with RPM changelog conventions at SUSE
+AUTHOR ?= shap-staff@suse.de
+
+# you can customize any of the following to build forks
+OBS_PROJECT ?= server:monitoring
+OBS_PACKAGE ?= prometheus-ha_cluster_exporter
+REPOSITORY ?= clusterlabs/ha_cluster_exporter
+
+# the Go archs we crosscompile to
+ARCHS ?= amd64 arm64 ppc64le s390x
+
+default: clean mod-tidy fmt vet-check test build
 
 download:
 	go mod download
 	go mod verify
 
-build: ha_cluster_exporter
-ha_cluster_exporter: download
-	go fmt
-	go build .
+build: amd64
+
+build-all: clean-bin $(ARCHS)
+
+$(ARCHS):
+	@mkdir -p build/bin
+	CGO_ENABLED=0 GOOS=linux GOARCH=$@ go build -trimpath -ldflags "-s -w -X main.version=$(VERSION)" -o build/bin/ha_cluster_exporter-$(VERSION)-$@
 
 install:
 	go install
@@ -17,6 +35,12 @@ static-checks: vet-check fmt-check
 vet-check: download
 	go vet .
 
+fmt:
+	go fmt
+
+mod-tidy:
+	go mod tidy
+
 fmt-check:
 	.ci/go_lint.sh
 
@@ -28,13 +52,31 @@ coverage.out:
 	go test -cover -coverprofile=coverage.out
 	go tool cover -html=coverage.out
 
-clean:
+clean: clean-bin clean-obs
 	go clean
 	rm -f coverage.out
 
-post-build:
-	go mod tidy
+clean-bin:
+	rm -rf build/bin
+
+clean-obs:
+	rm -rf build/obs
+
+obs-workdir: clean-obs
+	@mkdir -p build/obs/$(OBS_PACKAGE)
+	osc checkout $(OBS_PROJECT)/$(OBS_PACKAGE) -o build/obs
+	cp ha_cluster_exporter.spec build/obs/$(OBS_PACKAGE).spec
+	cp -r doc LICENSE *.md ha_cluster_exporter.service build/obs/$(OBS_PACKAGE)/
+	cp build/bin/* build/obs/$(OBS_PACKAGE)/
+	mv build/obs/$(OBS_PACKAGE)/ha_cluster_exporter-$(VERSION)-arm64 build/obs/$(OBS_PACKAGE)/ha_cluster_exporter-$(VERSION)-aarch64
+	mv build/obs/$(OBS_PACKAGE)/ha_cluster_exporter-$(VERSION)-amd64 build/obs/$(OBS_PACKAGE)/ha_cluster_exporter-$(VERSION)-x86_64
+	sed -i 's/%%VERSION%%/$(VERSION)/' build/obs/$(OBS_PACKAGE).spec
+	rm build/obs/*.tar.gz
+	tar -cvzf build/obs/$(OBS_PACKAGE)-$(VERSION).tar.gz -C build/obs/$(OBS_PACKAGE) .
+	.ci/gh_release_to_obs_changeset.py $(REPOSITORY) -a $(AUTHOR) -t $(VERSION) -f build/obs/$(OBS_PACKAGE).changes || true
 
-release:
+obs-commit: obs-workdir
+	cd build/obs; osc addremove
+	cd build/obs; osc commit -m "Automated $(VERSION) release"
 
-.PHONY: default download install static-checks vet-check fmt-check test clean release post-build
+.PHONY: default download install static-checks vet-check fmt fmt-check mod-tidy test clean clean-bin clean-obs build build-all obs-commit obs-workdir $(ARCHS)
diff --git a/README.md b/README.md
index cfd4935..a9809b2 100644
--- a/README.md
+++ b/README.md
@@ -90,7 +90,7 @@ Please refer to the example [YAML configuration](ha_cluster_exporter.yaml) for m
 
 ### systemd integration
 
-A [systemd unit file](prometheus-ha_cluster_exporter.service) is provided with the RPM packages. You can enable and start it as usual:  
+A [systemd unit file](ha_cluster_exporter.service) is provided with the RPM packages. You can enable and start it as usual:  
 
 ```
 systemctl --now enable prometheus-ha_cluster_exporter
diff --git a/doc/metric_spec.md b/doc/metric_spec.md
index d09979d..2c734b0 100644
--- a/doc/metric_spec.md
+++ b/doc/metric_spec.md
@@ -206,8 +206,8 @@ The DRBD subsystems collect devices stats by parsing its configuration the JSON
 0. [Sample](../test/drbd.metrics)
 1. [`ha_cluster_drbd_resources`](#ha_cluster_drbd_resources)
 2. [`ha_cluster_drbd_connections`](#ha_cluster_drbd_connections)
-3. [`ha_cluster_drbd_connections_sync`](#ha_cluster_drbd_connections_sync)
-4. [`ha_cluster_drbd_split_brain`](#ha_cluster_drbd_split_brain)
+3. [`ha_cluster_drbd_connections_sync`](#ha_cluster_drbd_connections_sync`)
+
 
 ### `ha_cluster_drbd_connections`
 
@@ -249,36 +249,3 @@ Either the value is `1`, or the line is absent altogether.
 - `disk_state`: one of `attaching|failed|negotiating|inconsistent|outdated|dunknown|consistent|uptodate`
 
 The total number of lines for this metric will be the cardinality of `name` times the cardinality of `volume`.
-
-### `ha_cluster_drbd_split_brain`
-
-#### Description
-
-This metric signal if there is a split brain occuring per resource and volume.
-Either the value is `1`, or the line is absent altogether.
-
-This metric is a special metric comparing to others, because in order to make this metric working you will need to set a drbd customer split-brain handler. Look at the end 
-
-#### Labels
-
-- `resource`: the name of the resource.
-- `volume`: the volume number
-
-#### Setting up the DRBD split-brain hook
-
-In order to get the `split_brain` metric working:
-
-1) copy hook into all drbd nodes:
-
-get the hook from:
-https://github.com/SUSE/ha-sap-terraform-deployments/blob/72c9d3ecf6c3f6dd18ccb7bcbde4b40722d5c641/salt/drbd_node/files/notify-split-brain-haclusterexporter-suse-metric.sh
-
-2) on the drbd configuration enable the hook:
-
-```split_brain: "/usr/lib/drbd/notify-split-brain-haclusterexporter-suse-metric.sh"`
-
-Refer to upstream doc: https://docs.linbit.com/docs/users-guide-8.4/#s-configure-split-brain-behavior
-
-It is important for the exporter that he hook should create the files in that location and naming. 
-
-Remember to remove the files manually after the split brain is solved
diff --git a/drbd_metrics.go b/drbd_metrics.go
index addda55..06ab5d9 100644
--- a/drbd_metrics.go
+++ b/drbd_metrics.go
@@ -2,9 +2,7 @@ package main
 
 import (
 	"encoding/json"
-	"io/ioutil"
 	"os/exec"
-	"path/filepath"
 	"strconv"
 	"strings"
 
@@ -39,11 +37,10 @@ var (
 		"resources":        NewMetricDesc("drbd", "resources", "The DRBD resources; 1 line per name, per volume", []string{"resource", "role", "volume", "disk_state"}),
 		"connections":      NewMetricDesc("drbd", "connections", "The DRBD resource connections; 1 line per per resource, per peer_node_id", []string{"resource", "peer_node_id", "peer_role", "volume", "peer_disk_state"}),
 		"connections_sync": NewMetricDesc("drbd", "connections_sync", "The in sync percentage value for DRBD resource connections", []string{"resource", "peer_node_id", "volume"}),
-		"split_brain":      NewMetricDesc("drbd", "split_brain", "Whether a split brain has been detected; 1 line per resource, per volume.", []string{"resource", "volume"}),
 	}
 )
 
-func NewDrbdCollector(drbdSetupPath string, drbdSplitBrainPath string) (*drbdCollector, error) {
+func NewDrbdCollector(drbdSetupPath string) (*drbdCollector, error) {
 	err := CheckExecutables(drbdSetupPath)
 	if err != nil {
 		return nil, errors.Wrap(err, "could not initialize DRBD collector")
@@ -54,14 +51,12 @@ func NewDrbdCollector(drbdSetupPath string, drbdSplitBrainPath string) (*drbdCol
 			metrics: drbdMetrics,
 		},
 		drbdSetupPath,
-		drbdSplitBrainPath,
 	}, nil
 }
 
 type drbdCollector struct {
 	DefaultCollector
-	drbdsetupPath      string
-	drbdSplitBrainPath string
+	drbdsetupPath string
 }
 
 func (c *drbdCollector) Collect(ch chan<- prometheus.Metric) {
@@ -70,9 +65,6 @@ func (c *drbdCollector) Collect(ch chan<- prometheus.Metric) {
 
 	log.Infoln("Collecting DRBD metrics...")
 
-	// set split brain metric
-	c.setDrbdSplitBrainMetric(ch)
-
 	drbdStatusRaw, err := exec.Command(c.drbdsetupPath, "status", "--json").Output()
 	if err != nil {
 		log.Warnf("Error while retrieving drbd infos %s", err)
@@ -109,7 +101,6 @@ func (c *drbdCollector) Collect(ch chan<- prometheus.Metric) {
 			}
 		}
 	}
-
 }
 
 func parseDrbdStatus(statusRaw []byte) ([]drbdStatus, error) {
@@ -120,32 +111,3 @@ func parseDrbdStatus(statusRaw []byte) ([]drbdStatus, error) {
 	}
 	return drbdDevs, nil
 }
-
-func (c *drbdCollector) setDrbdSplitBrainMetric(ch chan<- prometheus.Metric) {
-
-	// set split brain metric
-	// by default if the custom hook is not set, the exporter will not be able to detect it
-	files, err := ioutil.ReadDir(c.drbdSplitBrainPath)
-	if err != nil {
-		log.Warnf("Error while reading directory %s: %s", c.drbdSplitBrainPath, err)
-	}
-
-	for _, f := range files {
-		// check if in directory there are file of syntax we expect (nil is when there is not any)
-		match, _ := filepath.Glob(c.drbdSplitBrainPath + "/drbd-split-brain-detected-*")
-		if match == nil {
-			continue
-		}
-		resAndVolume := strings.Split(f.Name(), "drbd-split-brain-detected-")[1]
-
-		// avoid to have index out range panic error (in case the there is not resource-volume syntax)
-		if len(strings.Split(resAndVolume, "-")) != 2 {
-			continue
-		}
-		//Resource (0) volume (1) place in slice
-		resourceAndVolume := strings.Split(resAndVolume, "-")
-
-		ch <- c.makeGaugeMetric("split_brain", float64(1), resourceAndVolume[0], resourceAndVolume[1])
-
-	}
-}
diff --git a/ha_cluster_exporter.go b/ha_cluster_exporter.go
index 27d2314..b68190e 100644
--- a/ha_cluster_exporter.go
+++ b/ha_cluster_exporter.go
@@ -126,7 +126,6 @@ func init() {
 	flag.String("sbd-path", "/usr/sbin/sbd", "path to sbd executable")
 	flag.String("sbd-config-path", "/etc/sysconfig/sbd", "path to sbd configuration")
 	flag.String("drbdsetup-path", "/sbin/drbdsetup", "path to drbdsetup executable")
-	flag.String("drbdsplitbrain-path", "/var/run/drbd/splitbrain", "path to drbd splitbrain hooks temporary files")
 
 	err := config.BindPFlags(flag.CommandLine)
 	if err != nil {
@@ -182,7 +181,7 @@ func main() {
 		log.Info("SBD collector registered")
 	}
 
-	drbdCollector, err := NewDrbdCollector(config.GetString("drbdsetup-path"), config.GetString("drbdsplitbrain-path"))
+	drbdCollector, err := NewDrbdCollector(config.GetString("drbdsetup-path"))
 	if err != nil {
 		log.Warn(err)
 	} else {
diff --git a/prometheus-ha_cluster_exporter.service b/ha_cluster_exporter.service
similarity index 76%
rename from prometheus-ha_cluster_exporter.service
rename to ha_cluster_exporter.service
index 1182d91..4f0be93 100644
--- a/prometheus-ha_cluster_exporter.service
+++ b/ha_cluster_exporter.service
@@ -1,5 +1,5 @@
 [Unit]
-Description=Prometheus exporter for ha_cluster metrics (pacemaker)
+Description=Prometheus exporter for Pacemaker HA clusters metrics
 Wants=pacemaker.service
 After=network.target pacemaker.service
 
diff --git a/ha_cluster_exporter.spec b/ha_cluster_exporter.spec
new file mode 100644
index 0000000..350c356
--- /dev/null
+++ b/ha_cluster_exporter.spec
@@ -0,0 +1,64 @@
+Name:           prometheus-ha_cluster_exporter
+# Version will be processed by the set_version source service
+Version:        %%VERSION%%
+Release:        0
+License:        Apache-2.0
+Summary:        Prometheus exporter for Pacemaker HA clusters metrics
+Group:          System/Monitoring
+Url:            https://github.com/ClusterLabs/ha_cluster_exporter
+Source:         %{name}-%{version}.tar.gz
+ExclusiveArch:  aarch64 x86_64 ppc64le s390x
+Provides:       ha_cluster_exporter = %{version}-%{release}
+Provides:       prometheus(ha_cluster_exporter) = %{version}-%{release}
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+
+# Make sure that the binary is not getting stripped.
+%undefine _build_create_debug
+%define __arch_install_post export NO_BRP_STRIP_DEBUG=true
+
+%description
+Prometheus exporter for Pacemaker HA clusters metrics
+
+%prep
+%setup -q -c # unpack project sources
+
+%define shortname ha_cluster_exporter
+
+%install
+
+# Install the binary.
+install -D -m 0755 %{shortname}-%{version}-%{_arch} "%{buildroot}%{_bindir}/%{shortname}"
+
+# Install the systemd unit
+install -D -m 0644 %{shortname}.service %{buildroot}%{_unitdir}/%{name}.service
+
+# Install compat wrapper for legacy init systems
+install -Dd -m 0755 %{buildroot}%{_sbindir}
+ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
+
+%pre
+%service_add_pre %{name}.service
+
+%post
+%service_add_post %{name}.service
+
+%preun
+%service_del_preun %{name}.service
+
+%postun
+%service_del_postun %{name}.service
+
+%files
+%defattr(-,root,root)
+%doc *.md
+%doc doc/*
+%if 0%{?suse_version} >= 1500
+%license LICENSE
+%else
+%doc LICENSE
+%endif
+%{_bindir}/%{shortname}
+%{_unitdir}/%{name}.service
+%{_sbindir}/rc%{name}
+
+%changelog
diff --git a/prometheus-ha_cluster_exporter.spec b/prometheus-ha_cluster_exporter.spec
deleted file mode 100644
index 4bb6712..0000000
--- a/prometheus-ha_cluster_exporter.spec
+++ /dev/null
@@ -1,99 +0,0 @@
-#
-# spec file for package prometheus-ha_cluster_exporter
-#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
-#
-# All modifications and additions to the file contributed by third parties
-# remain the property of their copyright owners, unless otherwise agreed
-# upon. The license for this file, and modifications and additions to the
-# file, is the same license as for the pristine package itself (unless the
-# license for the pristine package is not an Open Source License, in which
-# case the license is the MIT License). An "Open Source License" is a
-# license that conforms to the Open Source Definition (Version 1.9)
-# published by the Open Source Initiative.
-
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
-#
-
-
-Name:           prometheus-ha_cluster_exporter
-# will be processed by the set_version source service
-Version:        0.0
-Release:        0
-License:        Apache-2.0
-Summary:        Prometheus exporter for ha_cluster server metrics
-Group:          System/Monitoring
-Url:            https://github.com/ClusterLabs/ha_cluster_exporter
-Source:         %{name}-%{version}.tar.gz
-# prepared by the go_modules source service
-Source1:        vendor.tar.gz
-BuildRequires:  git-core
-BuildRequires:  fdupes
-BuildRequires:  golang-packaging
-BuildRequires:  go1.11
-Provides:       ha_cluster_exporter = %{version}-%{release}
-Provides:       prometheus(ha_cluster_exporter) = %{version}-%{release}
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-%{go_provides}
-# Make sure that the binary is not getting stripped.
-%{go_nostrip}
-
-%description
-Prometheus exporter for ha_cluster pacemaker metrics.
-
-%prep
-%setup -q # unpack project sources
-%setup -q -T -D -a 1 # unpack go dependencies in vendor.tar.gz, which was prepared by the source services
-
-%define binary_name ha_cluster_exporter
-
-%build
-# we don't use OBS Go packaging macros but explicit go build command, as illustrated in the go_modules source service example
-export VERSION=%{version}
-export COMMIT=%{commit}
-export CGO_ENABLED=0
-go build \
-   -mod=vendor \
-   -buildmode=pie \
-   -ldflags "-s -w -X main.gitCommit=$COMMIT -X main.version=$VERSION" \
-   -o %{binary_name} ;
-
-%install
-
-# Install the binary.
-install -D -m 0755 %{binary_name} "%{buildroot}%{_bindir}/%{binary_name}"
-
-# Install the systemd unit
-install -D -m 0644 %{name}.service %{buildroot}%{_unitdir}/%{name}.service
-
-# Install compat wrapper for legacy init systems
-install -Dd -m 0755 %{buildroot}%{_sbindir}
-ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
-
-%fdupes %{buildroot}
-
-%pre
-%service_add_pre %{name}.service
-
-%post
-%service_add_post %{name}.service
-
-%preun
-%service_del_preun %{name}.service
-
-%postun
-%service_del_postun %{name}.service
-
-%files
-%defattr(-,root,root)
-%doc *.md
-%if 0%{?suse_version} >= 1500
-%license LICENSE
-%else
-%doc LICENSE
-%endif
-%{_bindir}/%{binary_name}
-%{_unitdir}/%{name}.service
-%{_sbindir}/rc%{name}
-
-%changelog


Test patch:
diff --git a/drbd_metrics_test.go b/drbd_metrics_test.go
index 5a901be..5457c9c 100644
--- a/drbd_metrics_test.go
+++ b/drbd_metrics_test.go
@@ -1,7 +1,6 @@
 package main
 
 import (
-	"os"
 	"testing"
 )
 
@@ -153,14 +152,14 @@ func TestDrbdParsing(t *testing.T) {
 }
 
 func TestNewDrbdCollector(t *testing.T) {
-	_, err := NewDrbdCollector("test/fake_drbdsetup.sh", "splitbrainpath")
+	_, err := NewDrbdCollector("test/fake_drbdsetup.sh")
 	if err != nil {
 		t.Errorf("Unexpected error, got: %v", err)
 	}
 }
 
 func TestNewDrbdCollectorChecksDrbdsetupExistence(t *testing.T) {
-	_, err := NewDrbdCollector("test/nonexistent", "splitbrainfake")
+	_, err := NewDrbdCollector("test/nonexistent")
 	if err == nil {
 		t.Fatal("a non nil error was expected")
 	}
@@ -170,7 +169,7 @@ func TestNewDrbdCollectorChecksDrbdsetupExistence(t *testing.T) {
 }
 
 func TestNewDrbdCollectorChecksDrbdsetupExecutableBits(t *testing.T) {
-	_, err := NewDrbdCollector("test/dummy", "splibrainfake")
+	_, err := NewDrbdCollector("test/dummy")
 	if err == nil {
 		t.Fatalf("a non nil error was expected")
 	}
@@ -181,26 +180,7 @@ func TestNewDrbdCollectorChecksDrbdsetupExecutableBits(t *testing.T) {
 
 func TestDRBDCollector(t *testing.T) {
 	clock = StoppedClock{}
-	splitBrainDir := "/var/tmp/drbd/splitbrain"
-	testFiles := [3]string{
-		"drbd-split-brain-detected-resource01-vol01",
-		"drbd-split-brain-detected-resource02-vol02",
-		"drbd-split-brain-detected-missingthingsWrongSkippedMetricS",
-	}
-	// create dir for putting temp file if not existings
-	if _, err := os.Stat(splitBrainDir); os.IsNotExist(err) {
-		err := os.MkdirAll(splitBrainDir, os.ModePerm)
-		if err != nil {
-			t.Errorf("Unexpected error: %v", err)
-		}
-	}
 
-	for _, testFile := range testFiles {
-		os.Create(splitBrainDir + "/" + testFile)
-	}
-	defer os.RemoveAll(splitBrainDir)
-
-	collector, _ := NewDrbdCollector("test/fake_drbdsetup.sh", splitBrainDir)
+	collector, _ := NewDrbdCollector("test/fake_drbdsetup.sh")
 	expectMetrics(t, collector, "drbd.metrics")
-
 }
diff --git a/test/drbd.metrics b/test/drbd.metrics
index d950db6..f08941a 100644
--- a/test/drbd.metrics
+++ b/test/drbd.metrics
@@ -10,7 +10,3 @@ ha_cluster_drbd_connections_sync{peer_node_id="1",resource="1-single-1",volume="
 # TYPE ha_cluster_drbd_resources gauge
 ha_cluster_drbd_resources{disk_state="uptodate",resource="1-single-0",role="Secondary",volume="0"} 1 1234
 ha_cluster_drbd_resources{disk_state="uptodate",resource="1-single-1",role="Secondary",volume="0"} 1 1234
-# HELP ha_cluster_drbd_split_brain Whether a split brain has been detected; 1 line per resource, per volume.
-# TYPE ha_cluster_drbd_split_brain gauge
-ha_cluster_drbd_split_brain{resource="resource01",volume="vol01"} 1 1234
-ha_cluster_drbd_split_brain{resource="resource02",volume="vol02"} 1 1234