[svn] r5705 - in trunk/tools/dstat: . plugins
packagers at lists.rpmforge.net
packagers at lists.rpmforge.net
Fri Aug 10 18:05:26 CEST 2007
Author: dag
Date: 2007-08-10 18:05:25 +0200 (Fri, 10 Aug 2007)
New Revision: 5705
Added:
trunk/tools/dstat/plugins/dstat_innodb_buffer.py
trunk/tools/dstat/plugins/dstat_innodb_io.py
trunk/tools/dstat/plugins/dstat_innodb_ops.py
Modified:
trunk/tools/dstat/LINKS
trunk/tools/dstat/dstat
Log:
Added innodb plugins, improvements to dpopen and pipe handling.
Modified: trunk/tools/dstat/LINKS
===================================================================
--- trunk/tools/dstat/LINKS 2007-08-09 20:45:45 UTC (rev 5704)
+++ trunk/tools/dstat/LINKS 2007-08-10 16:05:25 UTC (rev 5705)
@@ -3,3 +3,7 @@
NFS
http://www.hn.edu.cn/book/NetWork/NetworkingBookshelf_2ndEd/nfs/ch14_02.htm
+
+MySQL performance counters
+http://www.mysql.com/news-and-events/newsletter/2004-01/a0000000301.html
+
Modified: trunk/tools/dstat/dstat
===================================================================
--- trunk/tools/dstat/dstat 2007-08-09 20:45:45 UTC (rev 5704)
+++ trunk/tools/dstat/dstat 2007-08-10 16:05:25 UTC (rev 5705)
@@ -1432,8 +1432,38 @@
while select.select([file.fileno()], [], [], tmout)[0]:
ret = ret + file.read(1)
return ret.split('\n')
-# return ret
+def greppipe(file, str, tmout = 0.001):
+ "Grep available data from pipe in a non-blocking fashion"
+ ret = ''
+ while not select.select([file.fileno()], [], [], tmout)[0]:
+ pass
+ while select.select([file.fileno()], [], [], tmout)[0]:
+ char = file.read(1)
+ if char != '\n':
+ ret = ret + char
+ elif ret.startswith(str):
+ return ret
+ else:
+ ret = ''
+ return None
+
+def matchpipe(file, string, tmout = 0.001):
+ "Match available data from pipe in a non-blocking fashion"
+ ret = ''
+ regexp = re.compile(string)
+ while not select.select([file.fileno()], [], [], tmout)[0]:
+ pass
+ while select.select([file.fileno()], [], [], tmout)[0]:
+ char = file.read(1)
+ if char != '\n':
+ ret = ret + char
+ elif regexp.match(ret):
+ return ret
+ else:
+ ret = ''
+ return None
+
def dchg(var, max, base):
"Convert decimal to string given base and length"
c = 0
Added: trunk/tools/dstat/plugins/dstat_innodb_buffer.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_innodb_buffer.py (rev 0)
+++ trunk/tools/dstat/plugins/dstat_innodb_buffer.py 2007-08-10 16:05:25 UTC (rev 5705)
@@ -0,0 +1,48 @@
+global string, select
+import string, select
+
+class dstat_innodb_buffer(dstat):
+ def __init__(self):
+ self.name = 'innodb pool'
+ self.format = ('f', 3, 1000)
+ self.vars = ('read', 'created', 'written')
+ self.nick = ('crt', 'rea', 'wri')
+ self.init(self.vars, 1)
+
+ def check(self):
+ if os.access('/usr/bin/mysql', os.X_OK):
+ try:
+ self.stdin, self.stdout, self.stderr = dpopen('/usr/bin/mysql -n')
+ except IOError:
+ raise Exception, 'Cannot interface with MySQL binary'
+ return True
+ raise Exception, 'Needs MySQL binary'
+
+ def extract(self):
+ try:
+ self.stdin.write('show engine innodb status\G\n')
+ line = greppipe(self.stdout, 'Pages read ')
+
+ if line:
+ l = line.split()
+ self.cn2['read'] = int(l[2].rstrip(','))
+ self.cn2['created'] = int(l[4].rstrip(','))
+ self.cn2['written'] = int(l[6])
+
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+
+ if step == op.delay:
+ self.cn1.update(self.cn2)
+
+ except IOError, e:
+ if op.debug:
+ print 'dstat_innodb_buffer: lost pipe to mysql,', e
+ for name in self.vars: self.val[name] = -1
+
+ except Exception, e:
+ if op.debug:
+ print 'dstat_innodb_buffer: exception', e
+ for name in self.vars: self.val[name] = -1
+
+# vim:ts=4:sw=4:et
Added: trunk/tools/dstat/plugins/dstat_innodb_io.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_innodb_io.py (rev 0)
+++ trunk/tools/dstat/plugins/dstat_innodb_io.py 2007-08-10 16:05:25 UTC (rev 5705)
@@ -0,0 +1,48 @@
+global string, select
+import string, select
+
+class dstat_innodb_io(dstat):
+ def __init__(self):
+ self.name = 'innodb io ops '
+ self.format = ('f', 3, 1000)
+ self.vars = ('rea', 'wri', 'syn')
+ self.nick = self.vars
+ self.init(self.vars, 1)
+
+ def check(self):
+ if os.access('/usr/bin/mysql', os.X_OK):
+ try:
+ self.stdin, self.stdout, self.stderr = dpopen('/usr/bin/mysql -n')
+ except IOError:
+ raise Exception, 'Cannot interface with MySQL binary'
+ return True
+ raise Exception, 'Needs MySQL binary'
+
+ def extract(self):
+ try:
+ self.stdin.write('show engine innodb status\G\n')
+ line = greppipe(self.stdout, 'OS file reads ')
+
+ if line:
+ l = line.split()
+ self.cn2['read'] = l[0].rstrip(',')
+ self.cn2['write'] = l[4].rstrip(',')
+ self.cn2['sync'] = l[8]
+
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+
+ if step == op.delay:
+ self.cn1.update(self.cn2)
+
+ except IOError, e:
+ if op.debug:
+ print 'dstat_innodb_buffer: lost pipe to mysql,', e
+ for name in self.vars: self.val[name] = -1
+
+ except Exception, e:
+ if op.debug:
+ print 'dstat_innodb_buffer: exception', e
+ for name in self.vars: self.val[name] = -1
+
+# vim:ts=4:sw=4:et
Added: trunk/tools/dstat/plugins/dstat_innodb_ops.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_innodb_ops.py (rev 0)
+++ trunk/tools/dstat/plugins/dstat_innodb_ops.py 2007-08-10 16:05:25 UTC (rev 5705)
@@ -0,0 +1,49 @@
+global string, select
+import string, select
+
+class dstat_innodb_ops(dstat):
+ def __init__(self):
+ self.name = 'innodb ops'
+ self.format = ('f', 3, 1000)
+ self.vars = ('inserted', 'updated', 'deleted', 'read')
+ self.nick = ('ins', 'upd', 'del', 'rea')
+ self.init(self.vars, 1)
+
+ def check(self):
+ if os.access('/usr/bin/mysql', os.X_OK):
+ try:
+ self.stdin, self.stdout, self.stderr = dpopen('/usr/bin/mysql -n')
+ except IOError:
+ raise Exception, 'Cannot interface with MySQL binary'
+ return True
+ raise Exception, 'Needs MySQL binary'
+
+ def extract(self):
+ try:
+ self.stdin.write('show engine innodb status\G\n')
+ line = greppipe(self.stdout, 'OS file reads ')
+
+ if line:
+ l = line.split()
+ self.cn2['inserted'] = l[4].rstrip(',')
+ self.cn2['updated'] = l[6].rstrip(',')
+ self.cn2['deleted'] = l[8].rstrip(',')
+ self.cn2['read'] = l[10]
+
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+
+ if step == op.delay:
+ self.cn1.update(self.cn2)
+
+ except IOError, e:
+ if op.debug:
+ print 'dstat_innodb_buffer: lost pipe to mysql,', e
+ for name in self.vars: self.val[name] = -1
+
+ except Exception, e:
+ if op.debug:
+ print 'dstat_innodb_buffer: exception', e
+ for name in self.vars: self.val[name] = -1
+
+# vim:ts=4:sw=4:et
More information about the svn-commits
mailing list