[svn] r5922 - in trunk/tools/dstat: . plugins

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Mon Oct 15 14:42:18 CEST 2007


Author: dag
Date: 2007-10-15 14:42:17 +0200 (Mon, 15 Oct 2007)
New Revision: 5922

Added:
   trunk/tools/dstat/plugins/dstat_mysql5_com.py
   trunk/tools/dstat/plugins/dstat_mysql5_conn.py
   trunk/tools/dstat/plugins/dstat_mysql5_io.py
   trunk/tools/dstat/plugins/dstat_mysql5_keys.py
Modified:
   trunk/tools/dstat/ChangeLog
Log:
Updates

Modified: trunk/tools/dstat/ChangeLog
===================================================================
--- trunk/tools/dstat/ChangeLog	2007-10-15 00:28:21 UTC (rev 5921)
+++ trunk/tools/dstat/ChangeLog	2007-10-15 12:42:17 UTC (rev 5922)
@@ -1,4 +1,4 @@
-* 0.6.6svn - ... - released 28/04/2007
+* 0.6.6svn - ... - released 15/10/2007
 - Only rewrite xterm title when XTERM_SHELL is set to bash
 - Added more Dbt (Debian bug tracker) ids in the ChangeLog and TODO
 - Use sys.exit() instead of exit() before color support is detected
@@ -15,6 +15,7 @@
 - Added greppipe() and matchpipe() to improve performance on pipe-handling
 - Added external dstat_topio and dstat_topbio plugins
 - Added external dstat_topoom plugin to show top out-of-memory score
+- Added external dstat_mysql5_* plugins (Frederic Descamps)
 
 * 0.6.6 - Unemployed - released 28/04/2007
 - Removed SwapCached from the Cached counter (Dbt 418326, Peter Rabbitson)

Added: trunk/tools/dstat/plugins/dstat_mysql5_com.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_mysql5_com.py	                        (rev 0)
+++ trunk/tools/dstat/plugins/dstat_mysql5_com.py	2007-10-15 12:42:17 UTC (rev 5922)
@@ -0,0 +1,47 @@
+# dstat plugin for MySQL 5 Commands 
+# 2007-09-04 - lefred at inuits.be
+global MySQLdb
+import MySQLdb
+global string, select
+import string, select
+
+global mysql_user
+global mysql_pwd
+mysql_user = os.getenv('DSTAT_MYSQL_USER') or os.getenv('USER')
+mysql_pwd = os.getenv('DSTAT_MYSQL_PWD')
+
+class dstat_mysql5_com(dstat):
+    def __init__(self):
+        self.name = 'mysql5 com'
+        self.format = ('i', 5, 1)
+        self.vars = ('Com_select', 'Com_insert','Com_update','Com_delete')
+        self.nick = ('sel', 'ins','upd','del')
+        self.init(self.vars, 1)
+
+    def check(self): 
+            try:
+                self.db=MySQLdb.connect(user=mysql_user, passwd=mysql_pwd)
+            except:
+                raise Exception, 'Cannot interface with MySQL server'
+            return True
+
+    def extract(self):
+        try:
+            c = self.db.cursor()
+            for name in self.vars:
+              c.execute("""show global status like '%s';""" % name)
+              line = c.fetchone()
+              if line[0] in self.vars:
+                    self.cn2[line[0]] = int(line[1])
+
+            for name in self.vars:
+                self.val[name] = self.cn2[name] * 1.0 / tick
+
+            if step == op.delay:
+                self.cn1.update(self.cn2)
+
+        except Exception, e:
+            for name in self.vars:
+                self.val[name] = -1
+
+# vim:ts=4:sw=4:et

Added: trunk/tools/dstat/plugins/dstat_mysql5_conn.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_mysql5_conn.py	                        (rev 0)
+++ trunk/tools/dstat/plugins/dstat_mysql5_conn.py	2007-10-15 12:42:17 UTC (rev 5922)
@@ -0,0 +1,49 @@
+# dstat plugin for MySQL 5 connections 
+# 2007-09-04 - lefred at inuits.be
+global MySQLdb
+import MySQLdb
+global string, select
+import string, select
+
+global mysql_user
+global mysql_pwd
+mysql_user = os.getenv('DSTAT_MYSQL_USER') or os.getenv('USER')
+mysql_pwd = os.getenv('DSTAT_MYSQL_PWD')
+
+class dstat_mysql5_conn(dstat):
+    def __init__(self):
+        self.name = 'mysql5 conn'
+        self.format = ('f', 4, 1)
+        self.vars = ('Threads_connected', 'Threads')
+        self.nick = ('ThCon', '%Con')
+        self.init(self.vars, 1)
+
+    def check(self): 
+            try:
+                self.db=MySQLdb.connect(user=mysql_user, passwd=mysql_pwd)
+            except:
+                raise Exception, 'Cannot interface with MySQL server'
+            return True
+
+    def extract(self):
+        try:
+            c = self.db.cursor()
+            c.execute("""show global variables like 'max_connections';""")
+            max = c.fetchone()
+            c.execute("""show global status like 'Threads_connected';""")
+            thread = c.fetchone()
+            if thread[0] in self.vars:
+                    self.cn2[thread[0]] = float(thread[1])
+                    self.cn2['Threads'] = (float(thread[1]) / float(max[1]) * float(100)) 
+
+            for name in self.vars:
+                self.val[name] = self.cn2[name] * 1.0 /tick
+
+            if step == op.delay:
+                self.cn1.update(self.cn2)
+
+        except Exception, e:
+            for name in self.vars:
+                self.val[name] = -1
+
+# vim:ts=4:sw=4:et

Added: trunk/tools/dstat/plugins/dstat_mysql5_io.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_mysql5_io.py	                        (rev 0)
+++ trunk/tools/dstat/plugins/dstat_mysql5_io.py	2007-10-15 12:42:17 UTC (rev 5922)
@@ -0,0 +1,48 @@
+# dstat plugin for MySQL 5 I/O 
+# 2007-09-04 - lefred at inuits.be
+global MySQLdb
+import MySQLdb
+global string, select
+import string, select
+
+global mysql_user
+global mysql_pwd
+mysql_user = os.getenv('DSTAT_MYSQL_USER') or os.getenv('USER')
+mysql_pwd = os.getenv('DSTAT_MYSQL_PWD')
+
+class dstat_mysql5_io(dstat):
+    def __init__(self):
+        self.name = 'mysql5 io'
+        self.format = ('f', 5, 1024)
+        self.vars = ('Bytes_received', 'Bytes_sent')
+        self.nick = ('recv', 'sent')
+        self.init(self.vars, 1)
+
+    def check(self): 
+            try:
+                self.db=MySQLdb.connect(user=mysql_user, passwd=mysql_pwd)
+            except:
+                raise Exception, 'Cannot interface with MySQL server'
+            return True
+
+    def extract(self):
+        try:
+            c = self.db.cursor()
+            c.execute("""show global status like 'Bytes_%';""")
+            lines = c.fetchall()
+            for line in lines:
+                if len(line[1]) < 2: continue
+                if line[0] in self.vars:
+                    self.cn2[line[0]] = float(line[1])
+
+            for name in self.vars:
+                self.val[name] = self.cn2[name] * 1.0 / tick
+
+            if step == op.delay:
+                self.cn1.update(self.cn2)
+
+        except Exception, e:
+            for name in self.vars:
+                self.val[name] = -1
+
+# vim:ts=4:sw=4:et

Added: trunk/tools/dstat/plugins/dstat_mysql5_keys.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_mysql5_keys.py	                        (rev 0)
+++ trunk/tools/dstat/plugins/dstat_mysql5_keys.py	2007-10-15 12:42:17 UTC (rev 5922)
@@ -0,0 +1,48 @@
+# dstat plugin for MySQL 5 Keys 
+# 2007-09-04 - lefred at inuits.be
+global MySQLdb
+import MySQLdb
+global string, select
+import string, select
+
+global mysql_user
+global mysql_pwd
+mysql_user = os.getenv('DSTAT_MYSQL_USER') or os.getenv('USER')
+mysql_pwd = os.getenv('DSTAT_MYSQL_PWD') 
+
+class dstat_mysql5_keys(dstat):
+    def __init__(self):
+        self.name = 'mysql5 key status'
+        self.format = ('f', 4, 1000)
+        self.vars = ('Key_blocks_used', 'Key_reads', 'Key_writes', 'Key_read_requests', 'Key_write_requests')
+        self.nick = ('used', 'read', 'writ', 'rreq', 'wreq')
+        self.init(self.vars, 1)
+
+    def check(self): 
+            try:
+                self.db=MySQLdb.connect(user=mysql_user, passwd=mysql_pwd)
+            except:
+                raise Exception, 'Cannot interface with MySQL server'
+            return True
+
+    def extract(self):
+        try:
+            c = self.db.cursor()
+            c.execute("""show global status like 'Key_%';""")
+            lines = c.fetchall()
+            for line in lines:
+                if len(line[1]) < 2: continue
+                if line[0] in self.vars:
+                    self.cn2[line[0]] = float(line[1])
+
+            for name in self.vars:
+                self.val[name] = self.cn2[name] * 1.0 / tick
+
+            if step == op.delay:
+                self.cn1.update(self.cn2)
+
+        except 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