Skip to content

Commit

Permalink
Merge "Stats daemon changes merge"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Sep 23, 2015
2 parents eb209c0 + 5b29c97 commit 353e714
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/storage/stats-daemon/stats_daemon/storage_nodemgr.py
Expand Up @@ -100,6 +100,12 @@ def __init__(self, node_type):
pattern = 'rm -rf ceph.conf; ln -s /etc/ceph/ceph.conf ceph.conf'
self.call_subprocess(pattern)

def exec_local(self, arg):
ret = subprocess.Popen('%s' %(arg), shell=True,
stdout=subprocess.PIPE).stdout.read()
ret = ret[:-1]
return ret

def init_units(self):
units = dict();
units['K'] = 1024
Expand Down Expand Up @@ -424,7 +430,8 @@ def create_and_send_osd_stats(self):
cmd = "cat /var/lib/ceph/osd/" + arr[linecount] + "/active"
is_active = self.call_subprocess(cmd)
if is_active is None:
return
linecount = linecount + 1
continue
#instantiate osd and its state
cs_osd = ComputeStorageOsd()
cs_osd_state = ComputeStorageOsdState()
Expand All @@ -448,15 +455,17 @@ def create_and_send_osd_stats(self):
if is_active == "ok\n":
cs_osd_state.status = "active"
num = arr[linecount].split('-')[1]
osd_name = "osd." + num
cmd = "ceph osd dump | grep " + \
osd_name + " | cut -d \" \" -f22"
uuid = self.call_subprocess(cmd)
if uuid is None:
return
uuid = self.exec_local('ceph --admin-daemon \
/var/run/ceph/ceph-osd.%s.asok status 2>/dev/null | \
grep osd_fsid | awk \'{print $2}\' | \
cut -d \'"\' -f 2' %(num))
if uuid is '':
linecount = linecount + 1
continue
cs_osd.uuid = uuid.rstrip("\n")
osd_prev_stats = self.dict_of_osds.get(
cs_osd.uuid)
osd_name = "osd." + num
cs_osd.name = self._hostname + ':' + osd_name
if osd_prev_stats is None:
no_prev_osd = 1
Expand All @@ -470,12 +479,14 @@ def create_and_send_osd_stats(self):
temp_osd_stats,
osd_prev_stats)
if rval == False:
return
linecount = linecount + 1
continue
rval = self.populate_osd_latency_stats(osd_name,
osd_stats,
prev_osd_latency)
if rval == False:
return
linecount = linecount + 1
continue
else:
cs_osd_state.status = "inactive"
if no_prev_osd == 0:
Expand Down Expand Up @@ -627,7 +638,7 @@ def create_and_send_disk_stats(self):
cmd = "cat /sys/block/"+ arr1[0] +"/stat"
res = self.call_subprocess(cmd)
if res is None:
return
continue
arr = re.sub('\s+', ' ', res).strip().split()
disk_stats.reads = int(arr[0])
disk_stats.writes = int(arr[4])
Expand Down

0 comments on commit 353e714

Please sign in to comment.