summaryrefslogtreecommitdiff
path: root/agent/gluster
blob: da7dcc5a635dfa1e5a1a626371b647b39e05e2c6 (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
#!/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)