"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/dstat_mysql_io.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_io.py  (dstat-0.7.3):dstat_mysql_io.py  (dstat-0.7.4)
skipping to change at line 12 skipping to change at line 12
mysql_options = os.getenv('DSTAT_MYSQL') mysql_options = os.getenv('DSTAT_MYSQL')
class dstat_plugin(dstat): class dstat_plugin(dstat):
def __init__(self): def __init__(self):
self.name = 'mysql io' self.name = 'mysql io'
self.nick = ('recv', 'sent') self.nick = ('recv', 'sent')
self.vars = ('Bytes_received', 'Bytes_sent') self.vars = ('Bytes_received', 'Bytes_sent')
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 'Bytes_%';\n") self.stdin.write("show status like 'Bytes_%';\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 'dstat_innodb_buffer: exception', e if op.debug > 1: print('dstat_innodb_buffer: exception', 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)