Permalink
Browse files

Updates

  • Loading branch information...
1 parent 1a00a4b commit ec9abec3ca1a93cb9a80c292a15eb228131e654a @dagwieers committed Oct 15, 2007
Showing with 194 additions and 1 deletion.
  1. +2 −1 ChangeLog
  2. +47 −0 plugins/dstat_mysql5_com.py
  3. +49 −0 plugins/dstat_mysql5_conn.py
  4. +48 −0 plugins/dstat_mysql5_io.py
  5. +48 −0 plugins/dstat_mysql5_keys.py
View
@@ -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)
@@ -0,0 +1,47 @@
+# dstat plugin for MySQL 5 Commands
+# 2007-09-04 - lefred@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
@@ -0,0 +1,49 @@
+# dstat plugin for MySQL 5 connections
+# 2007-09-04 - lefred@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
View
@@ -0,0 +1,48 @@
+# dstat plugin for MySQL 5 I/O
+# 2007-09-04 - lefred@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
@@ -0,0 +1,48 @@
+# dstat plugin for MySQL 5 Keys
+# 2007-09-04 - lefred@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

0 comments on commit ec9abec

Please sign in to comment.