Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# assuming we are running a vstart cluster
import subprocess
import time
import sys
def system(cmd):
output = subprocess.check_output(cmd, shell=True).decode(sys.stdout.encoding).strip()
return output
prev_rgw_sum = 0
prev_count = 0
while True:
pid = system('pgrep radosgw | head -1')
cpu = system('top -p '+pid+' -b -n 1 | ag radosgw | awk \'{print $9}\'')
qlen = system('./bin/ceph --admin-daemon out/radosgw.8000.asok perf dump 2>/dev/null | jq .rgw.qlen')
obj_lat_sum = float(system('./bin/ceph --admin-daemon out/radosgw.8000.asok perf dump 2>/dev/null | jq .objecter.op_latency.sum'))
obj_inflight = int(system('./bin/ceph --admin-daemon out/radosgw.8000.asok perf dump 2>/dev/null | jq .objecter.op_inflight'))
lat_count = int(system('./bin/ceph --admin-daemon out/radosgw.8000.asok perf dump 2>/dev/null | jq .rgw.put_initial_lat.avgcount'))
lat_sum = float(system('./bin/ceph --admin-daemon out/radosgw.8000.asok perf dump 2>/dev/null | jq .rgw.put_initial_lat.sum'))
rgw_sum = lat_sum - obj_lat_sum
diff_sum = rgw_sum - prev_rgw_sum
diff_count = lat_count - prev_count
if diff_count == 0:
latency = 0.0
else:
latency = diff_sum/diff_count
prev_rgw_sum = rgw_sum
prev_count = lat_count
print(qlen, '%.4f'%latency, cpu, obj_inflight)
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment