Skip to content

Commit

Permalink
DB-717 add iterations limit to tokustat
Browse files Browse the repository at this point in the history
  • Loading branch information
prohaska committed Sep 2, 2014
1 parent f7ee3d4 commit 561edb1
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions scripts/tokustat.py
Expand Up @@ -9,10 +9,10 @@ def usage():
print "diff the tokudb engine status"
print "--host=HOSTNAME (default: localhost)"
print "--port=PORT"
print "--sleeptime=SLEEPTIME (default: 10 seconds)"
print "--interations=MAX_ITERATIONS (default: forever)"
print "--interval=TIME_BETWEEN_SAMPLES (default: 10 seconds)"
print "--q='show engine tokudb status'"
print "--q='select * from information_schema.global_status'"

return 1

def convert(v):
Expand All @@ -23,14 +23,11 @@ def convert(v):
v = float(v)
return v

def printit(stats, rs, sleeptime):
# print rs
def printit(stats, rs, interval):
for t in rs:
l = len(t) # grab the last 2 fields in t
k = t[l-2]
v = t[l-1]
# print k, v # debug
# try to convert v
try:
v = convert(v)
except:
Expand All @@ -41,11 +38,11 @@ def printit(stats, rs, sleeptime):
print k, "|", oldv, "|", v,
try:
d = v - oldv
if sleeptime != 1:
if d >= sleeptime:
e = d / sleeptime
if interval != 1:
if d >= interval:
e = d / interval
else:
e = float(d) / sleeptime
e = float(d) / interval
print "|", d, "|", e
else:
print "|", d
Expand All @@ -59,7 +56,9 @@ def main():
port = None
user = None
passwd = None
sleeptime = 10
interval = 10
iterations = 0

q = 'show engine tokudb status'

for a in sys.argv[1:]:
Expand All @@ -71,6 +70,9 @@ def main():
continue
return usage()

iterations = int(iterations)
interval = int(interval)

connect_parameters = {}
if host is not None:
if host[0] == '/':
Expand All @@ -93,7 +95,9 @@ def main():
print "connected"

stats = {}
while 1:
i = 0
while iterations == 0 or i <= iterations:
i += 1
try:
c = db.cursor()
n = c.execute(q)
Expand All @@ -105,8 +109,8 @@ def main():
return 2

try:
printit(stats, rs, int(sleeptime))
time.sleep(int(sleeptime))
printit(stats, rs, interval)
time.sleep(interval)
except:
print "printit", sys.exc_info()
return 3
Expand Down

0 comments on commit 561edb1

Please sign in to comment.