Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

The new mysql 5.5 sql commands do not reset to zero. #28

Merged
merged 1 commit into from

3 participants

@carlhu

Added tracking to the mysql plugin of previous value.

@trinitronx

Fixes the issue & seems to work well for me ^_^

@dagwieers
Owner

Looks good, however I prefer if the vim indentation rule at the bottom remains though.

@trinitronx trinitronx referenced this pull request from a commit in trinitronx/dstat
@trinitronx trinitronx author=carlhu - Update plugins/dstat_mysql5_cmds.py -- reset counters…
… to zero.

fixes issue #28
53161f8
@dagwieers dagwieers merged commit 5593ba3 into dagwieers:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 17, 2012
  1. @carlhu
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 25 deletions.
  1. +4 −25 plugins/dstat_mysql5_cmds.py
View
29 plugins/dstat_mysql5_cmds.py
@@ -6,15 +6,6 @@
global mysql_pwd
mysql_pwd = os.getenv('DSTAT_MYSQL_PWD')
-global mysql_host
-mysql_host = os.getenv('DSTAT_MYSQL_HOST')
-
-global mysql_port
-mysql_port = os.getenv('DSTAT_MYSQL_PORT')
-
-global mysql_socket
-mysql_socket = os.getenv('DSTAT_MYSQL_SOCKET')
-
class dstat_plugin(dstat):
"""
Plugin for MySQL 5 commands.
@@ -31,19 +22,7 @@ def check(self):
global MySQLdb
import MySQLdb
try:
- args = {}
- if mysql_user:
- args['user'] = mysql_user
- if mysql_pwd:
- args['passwd'] = mysql_pwd
- if mysql_host:
- args['host'] = mysql_host
- if mysql_port:
- args['port'] = mysql_port
- if mysql_socket:
- args['unix_socket'] = mysql_socket
-
- self.db = MySQLdb.connect(**args)
+ self.db = MySQLdb.connect(user=mysql_user, passwd=mysql_pwd)
except Exception, e:
raise Exception, 'Cannot interface with MySQL server: %s' % e
@@ -54,7 +33,9 @@ def extract(self):
c.execute("""show global status like '%s';""" % name)
line = c.fetchone()
if line[0] in self.vars:
- self.set2[line[0]] = long(line[1])
+ if line[0] + 'raw' in self.set2:
+ self.set2[line[0]] = long(line[1]) - self.set2[line[0] + 'raw']
+ self.set2[line[0] + 'raw'] = long(line[1])
for name in self.vars:
self.val[name] = self.set2[name] * 1.0 / elapsed
@@ -65,5 +46,3 @@ def extract(self):
except Exception, e:
for name in self.vars:
self.val[name] = -1
-
-# vim:ts=4:sw=4:et
Something went wrong with that request. Please try again.