From 578463c91bd4b78bf77aebfee66289ad59a6fa6a Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan.grewe@flixbus.com>
Date: Thu, 7 Jun 2018 17:26:08 +0200
Subject: [PATCH] Rename 'nexenta_volume_online' to 'nexenta_volume_status',
 add 'state' and 'errors' labels to 'nexenta_volume_status'

---
 README.md |  2 +-
 main.go   | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index f24d9cf..f238b32 100644
--- a/README.md
+++ b/README.md
@@ -24,5 +24,5 @@ Metric | Type | Description
 `nexenta_jbod_temp` | gauge | Temperature of JBOD (°C)
 `nexenta_jbod_voltage` | gauge | Voltage of JBOD (Volts)
 `nexenta_jbod_slot_status` | gauge | Status of JBOD slot (0/1)
-`nexenta_volume_online` | gauge | Is the volume online (0/1)
+`nexenta_volume_status` | gauge | Is the volume online (0/1)
 `nexenta_license_days_left` | gauge | License days left
diff --git a/main.go b/main.go
index 76bf352..5e550ab 100644
--- a/main.go
+++ b/main.go
@@ -78,7 +78,7 @@ type Exporter struct {
 
 	up             	*prometheus.Desc
 	scrapeFailures 	 prometheus.Counter
-	volumeOnline   	*prometheus.Desc
+	volumeStatus   	*prometheus.Desc
 	jbodStatus	   	*prometheus.Desc
 	jbodTemp       	*prometheus.Desc
 	jbodVoltage	   	*prometheus.Desc
@@ -101,10 +101,10 @@ func NewExporter(uri string) *Exporter {
 			Help:        "Number of errors while scraping the Nexenta API",
 			ConstLabels: prometheus.Labels{"host":*apiHost},
 		}),
-		volumeOnline: prometheus.NewDesc(
-			prometheus.BuildFQName(namespace, "volume", "online"),
+		volumeStatus: prometheus.NewDesc(
+			prometheus.BuildFQName(namespace, "volume", "status"),
 			"Status of volume.",
-			[]string{"volume"},
+			[]string{"volume", "state", "errors"},
 			prometheus.Labels{"host":*apiHost},
 		),
 		jbodStatus: prometheus.NewDesc(
@@ -148,7 +148,7 @@ func NewExporter(uri string) *Exporter {
 func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
 	ch <- e.up
 	e.scrapeFailures.Describe(ch)
-	ch <- e.volumeOnline
+	ch <- e.volumeStatus
 	ch <- e.jbodStatus
 	ch <- e.jbodTemp
 	ch <- e.jbodVoltage
@@ -233,7 +233,7 @@ func (e *Exporter) getVolumeStatus(ch chan<- prometheus.Metric, volume string) e
 		if volumeStatus.State[0] == "ONLINE" { volumeOnline = 1 }
 	}
 
-	ch <- prometheus.MustNewConstMetric(e.volumeOnline, prometheus.GaugeValue, volumeOnline, volume)
+	ch <- prometheus.MustNewConstMetric(e.volumeStatus, prometheus.GaugeValue, volumeOnline, volume, volumeStatus.State[0], volumeStatus.Errors[0])
 
 	return err
 }
-- 
GitLab