Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
author=carlhu - Update plugins/dstat_mysql5_cmds.py -- reset counters…
Browse files Browse the repository at this point in the history
… to zero.

fixes issue #28
  • Loading branch information
trinitronx committed Nov 20, 2012
1 parent c5424a4 commit 53161f8
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions plugins/dstat_mysql5_cmds.py
Expand Up @@ -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.
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 53161f8

Please sign in to comment.