This repository has been archived by the owner on Nov 26, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
194 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |