diff --git a/main.go b/main.go
index 519ca66..2a06b56 100644
--- a/main.go
+++ b/main.go
@@ -304,16 +304,16 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
if err != nil {
log.Errorf("couldn't parse xml of peer status: %v", err)
}
- for _, vol := range volumeStatusAll.VolStatus.Volumes {
- for _, node := range vol.Volume.Node {
+ for _, vol := range volumeStatusAll.VolStatus.Volumes.Volume {
+ for _, node := range vol.Node {
if node.Status != 1 {
}
ch <- prometheus.MustNewConstMetric(
- nodeSizeTotalBytes, prometheus.CounterValue, float64(node.SizeTotal), node.Hostname, node.Path, vol.Volume.VolName,
+ nodeSizeTotalBytes, prometheus.CounterValue, float64(node.SizeTotal), node.Hostname, node.Path, vol.VolName,
)
ch <- prometheus.MustNewConstMetric(
- nodeSizeFreeBytes, prometheus.CounterValue, float64(node.SizeFree), node.Hostname, node.Path, vol.Volume.VolName,
+ nodeSizeFreeBytes, prometheus.CounterValue, float64(node.SizeFree), node.Hostname, node.Path, vol.VolName,
)
}
}
diff --git a/structs/xmlStructs.go b/structs/xmlStructs.go
index c1eb345..1ac0f77 100644
--- a/structs/xmlStructs.go
+++ b/structs/xmlStructs.go
@@ -237,8 +237,8 @@ type VolumeStatusXML struct {
OpErrno int `xml:"opErrno"`
OpErrstr string `xml:"opErrstr"`
VolStatus struct {
- Volumes []struct {
- Volume struct {
+ Volumes struct {
+ Volume []struct {
VolName string `xml:"volName"`
NodeCount int `xml:"nodeCount"`
Node []struct {
diff --git a/structs/xmlStructs_test.go b/structs/xmlStructs_test.go
index a395ff9..eedf516 100644
--- a/structs/xmlStructs_test.go
+++ b/structs/xmlStructs_test.go
@@ -92,7 +92,7 @@ func TestPeerStatusXMLUnmarshall(t *testing.T) {
func TestVolumeStatusAllDetailXMLUnmarshall(t *testing.T) {
testXMLPath := "../test/gluster_volume_status_all_detail.xml"
- t.Log("Test xml unmarshal for 'gluster peer status' with file: ", testXMLPath)
+ t.Log("Test xml unmarshal for 'gluster volume status all detail' with file: ", testXMLPath)
dat, err := ioutil.ReadFile(testXMLPath)
if err != nil {
t.Errorf("error reading testxml in Path: %v", testXMLPath)
@@ -106,26 +106,34 @@ func TestVolumeStatusAllDetailXMLUnmarshall(t *testing.T) {
t.Error(volumeStatus.OpErrstr)
}
- for _, vol := range volumeStatus.VolStatus.Volumes {
- if vol.Volume.NodeCount != 4 {
- t.Errorf("nodecount mismatch %v instead of 4", vol.Volume.NodeCount)
+ for _, vol := range volumeStatus.VolStatus.Volumes.Volume {
+ if vol.NodeCount != 4 {
+ t.Errorf("nodecount mismatch %v instead of 4", vol.NodeCount)
}
- for _, node := range vol.Volume.Node {
+ for _, node := range vol.Node {
if node.BlockSize != 4096 {
t.Errorf("blockSize mismatch %v and 4096 expected", node.BlockSize)
}
}
- if vol.Volume.Node[0].SizeFree != 19517558784 {
- t.Errorf("SizeFree doesn't match 19517558784: %v", vol.Volume.Node[0].SizeFree)
+ if vol.Node[0].SizeFree != 19517558784 {
+ t.Errorf("SizeFree doesn't match 19517558784: %v", vol.Node[0].SizeFree)
}
- if vol.Volume.Node[0].SizeTotal != 20507914240 {
- t.Errorf("SizeFree doesn't match 20507914240: %v", vol.Volume.Node[0].SizeTotal)
+ if vol.Node[0].SizeTotal != 20507914240 {
+ t.Errorf("SizeFree doesn't match 20507914240: %v", vol.Node[0].SizeTotal)
}
}
+
+ if volumeStatus.VolStatus.Volumes.Volume[0].VolName != "gv_test" {
+ t.Errorf("VolName of first volume doesn't match gv_test: %v", volumeStatus.VolStatus.Volumes.Volume[0].VolName)
+ }
+
+ if volumeStatus.VolStatus.Volumes.Volume[1].VolName != "gv_test2" {
+ t.Errorf("VolName of first volume doesn't match gv_test2: %v", volumeStatus.VolStatus.Volumes.Volume[1].VolName)
+ }
}
func TestVolumeProfileGvInfoCumulativeXMLUnmarshall(t *testing.T) {
@@ -245,13 +253,13 @@ func TestVolumeQuotaListXMLUnmarshall(t *testing.T) {
}
nb_limits := len(volumeQuotaXML.VolQuota.QuotaLimits)
if nb_limits != nodeCount {
- t.Error("Expected %v Limits and len is %v", nodeCount, nb_limits)
+ t.Errorf("Expected %v Limits and len is %v", nodeCount, nb_limits)
}
for _, limit := range volumeQuotaXML.VolQuota.QuotaLimits {
if limit.Path == "/foo" {
if limit.AvailSpace != 10309258240 {
- t.Error(
+ t.Errorf(
"Expected %v for available space in path %v, got %v",
1811939328,
limit.Path,
diff --git a/test/gluster_volume_status_all_detail.xml b/test/gluster_volume_status_all_detail.xml
index 4d32dbe..bb8b5a5 100644
--- a/test/gluster_volume_status_all_detail.xml
+++ b/test/gluster_volume_status_all_detail.xml
@@ -81,6 +81,82 @@
ext4
+
+ gv_test2
+ 4
+
+ node1.example.local
+ /mnt/gluster/gv_test2
+ a049c424-bd82-4436-abd4-ef3fc37c76ba
+ 1
+ 49153
+
+ 49153
+ N/A
+
+ 1342
+ 20507914240
+ 19517558784
+ /dev/loop0
+ 4096
+ rw,relatime,data=ordered
+ ext4
+
+
+ node2.example.local
+ /mnt/gluster/gv_test2
+ f6fa44e7-5139-4f6e-8404-6d2ce7d66231
+ 1
+ 49153
+
+ 49153
+ N/A
+
+ 1303
+ 20507914240
+ 19517558784
+ /dev/loop0
+ 4096
+ rw,relatime,data=ordered
+ ext4
+
+
+ node3.example.local
+ /mnt/gluster/gv_test2
+ 073c4354-f8eb-4474-95b3-c2bc235ca44d
+ 1
+ 49153
+
+ 49153
+ N/A
+
+ 1284
+ 20507914240
+ 19517558784
+ /dev/loop0
+ 4096
+ rw,relatime,data=ordered
+ ext4
+
+
+ node4.example.local
+ /mnt/gluster/gv_test2
+ 1d5d9c25-211c-4db6-8fd6-274cf3774d88
+ 1
+ 49153
+
+ 49153
+ N/A
+
+ 1312
+ 20507914240
+ 19517566976
+ /dev/loop0
+ 4096
+ rw,relatime,data=ordered
+ ext4
+
+
-
\ No newline at end of file
+