Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. $ cat gluster-check.py
  2. #!/usr/bin/env python
  3. # -*- coding: iso-8859-15 -*-
  4.  
  5. import os
  6.  
  7. data = os.popen("gluster v status").readlines()
  8.  
  9. # first we'll parse through the raw data looking for brick information
  10. for x in data:
  11.   if 'Brick' in x:
  12.     d = x.rstrip().split('\t')
  13.     if d[5] == 'Y':
  14.       status = 'ONLINE'
  15.     else:
  16.         status = 'OFFLINE'
  17.     pid = d[6]
  18.     name = d[0].split(' ')[1]
  19.  
  20.     # and output it with a little formatting
  21.     print "Volume: %s\t(PID %s)\t\tStatus: %s" % (name, pid, status)
  22.  
  23.  
  24. [jduncan@laptop ~]$ sudo python gluster-check.py
  25. Volume: 192.168.1.140:/gluster2 (PID 5629)      Status: ONLINE
  26. Volume: 192.168.1.140:/gluster  (PID 5603)      Status: ONLINE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement