"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/dstat_mysql_keys.py" between
dstat-0.7.3.tar.gz and dstat-0.7.4.tar.gz

About: dstat is a versatile resource statistic tool and a replacement for vmstat, iostat and ifstat (using Python).

dstat_mysql_keys.py  (dstat-0.7.3):dstat_mysql_keys.py  (dstat-0.7.4)
skipping to change at line 15 skipping to change at line 15
def __init__(self): def __init__(self):
self.name = 'mysql key status' self.name = 'mysql key status'
self.nick = ('used', 'read', 'writ', 'rreq', 'wreq') self.nick = ('used', 'read', 'writ', 'rreq', 'wreq')
self.vars = ('Key_blocks_used', 'Key_reads', 'Key_writes', 'Key_read_req uests', 'Key_write_requests') self.vars = ('Key_blocks_used', 'Key_reads', 'Key_writes', 'Key_read_req uests', 'Key_write_requests')
self.type = 'f' self.type = 'f'
self.width = 4 self.width = 4
self.scale = 1000 self.scale = 1000
def check(self): def check(self):
if not os.access('/usr/bin/mysql', os.X_OK): if not os.access('/usr/bin/mysql', os.X_OK):
raise Exception, 'Needs MySQL binary' raise Exception('Needs MySQL binary')
try: try:
self.stdin, self.stdout, self.stderr = dpopen('/usr/bin/mysql -n %s' % mysql_options) self.stdin, self.stdout, self.stderr = dpopen('/usr/bin/mysql -n %s' % mysql_options)
except IOError: except IOError:
raise Exception, 'Cannot interface with MySQL binary' raise Exception('Cannot interface with MySQL binary')
def extract(self): def extract(self):
try: try:
self.stdin.write("show status like 'Key_%';\n") self.stdin.write("show status like 'Key_%';\n")
for line in readpipe(self.stdout): for line in readpipe(self.stdout):
l = line.split() l = line.split()
if len(l) < 2: continue if len(l) < 2: continue
if l[0] in self.vars: if l[0] in self.vars:
self.set2[l[0]] = float(l[1]) self.set2[l[0]] = float(l[1])
for name in self.vars: for name in self.vars:
self.val[name] = (self.set2[name] - self.set1[name]) * 1.0 / ela psed self.val[name] = (self.set2[name] - self.set1[name]) * 1.0 / ela psed
if step == op.delay: if step == op.delay:
self.set1.update(self.set2) self.set1.update(self.set2)
except IOError, e: except IOError as e:
if op.debug > 1: print '%s: lost pipe to mysql, %s' % (self.filename if op.debug > 1: print('%s: lost pipe to mysql, %s' % (self.filename
, e) , e))
for name in self.vars: self.val[name] = -1 for name in self.vars: self.val[name] = -1
except Exception, e: except Exception as e:
if op.debug > 1: print '%s: exception' (self.filename, e) if op.debug > 1: print('%s: exception' (self.filename, e))
for name in self.vars: self.val[name] = -1 for name in self.vars: self.val[name] = -1
# vim:ts=4:sw=4:et # vim:ts=4:sw=4:et
 End of changes. 4 change blocks. 
7 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)