summaryrefslogtreecommitdiff
path: root/agent/gluster
diff options
context:
space:
mode:
Diffstat (limited to 'agent/gluster')
-rwxr-xr-xagent/gluster35
1 files changed, 35 insertions, 0 deletions
diff --git a/agent/gluster b/agent/gluster
new file mode 100755
index 0000000..e7098cd
--- /dev/null
+++ b/agent/gluster
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+from subprocess import check_output
+import xml.etree.ElementTree as ET
+
+print "<<<gluster>>>"
+
+print "[peers]"
+pl_xml = check_output(["gluster", "--mode=script", "--xml", "peer", "status" ])
+pl = ET.fromstring(pl_xml)
+for peer in pl.iter('peer'):
+ p = {}
+ for c in peer.iter():
+ p[c.tag] = c.text
+ print "%s %s %s %s %s" % (p['uuid'], p['hostname'], p['connected'], p['state'], p['stateStr'])
+
+
+vl_xml = check_output(["gluster", "--mode=script", "--xml", "volume", "list" ])
+vl = ET.fromstring(vl_xml)
+for vol in vl.iter('volume'):
+ print "[volstatus:%s]" % vol.text
+ vs_xml = check_output(["gluster", "--mode=script", "--xml", "volume", "status", vol.text, "detail" ])
+ vs = ET.fromstring(vs_xml)
+ for node in vs.iter('node'):
+ n = {}
+ for c in node.iter():
+ n[c.tag] = c.text
+ print "%s %s %s %s %s %s" % (n['peerid'], n['hostname'], n['status'], n['sizeTotal'], n['sizeFree'], n['path'] )
+
+# heal info has no xml output so far... :(
+#
+# print "[heal:%s]" % vol.text
+# hi_xml = check_output(["gluster", "--mode=script", "--xml", "volume", "heal", vol.text, "info" ])
+# hi = ET.fromstring(hi_xml)
+