summaryrefslogtreecommitdiff
path: root/agent/gluster
blob: e7098cdf9c150ca6e5b7ce1d6d7910eb393241eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)