Created
December 22, 2014 02:22
-
-
Save n0ts/4415925ced7e67a57824 to your computer and use it in GitHub Desktop.
Patch gmond/python_modules/db/DBUtil.py
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
--- ./gmond/python_modules/db/DBUtil.py-org 2014-10-23 10:24:40.000000000 +0900 | |
+++ ./gmond/python_modules/db/DBUtil.py 2014-10-23 10:35:23.000000000 +0900 | |
@@ -86,7 +86,7 @@ | |
innodb_status['active_transactions'] | |
for line in innodb_status_raw: | |
- istatus = line.split() | |
+ istatus = line.replace(',', '').replace(';', '').split() | |
isum = sumof(istatus) | |
@@ -97,15 +97,15 @@ | |
innodb_status['os_waits'] += longish(istatus[8]) | |
elif "RW-shared spins" in line: | |
- innodb_status['spin_waits'] += isum(2,8) | |
- innodb_status['os_waits'] += isum(5,11) | |
+ innodb_status['spin_waits'] += longish(istatus[2]) | |
+ innodb_status['os_waits'] += longish(istatus[5]) | |
# TRANSACTIONS | |
elif "Trx id counter" in line: | |
- innodb_status['transactions'] += isum(3,4) | |
+ innodb_status['transactions'] += int(istatus[3], 16) | |
elif "Purge done for trx" in line: | |
- innodb_status['transactions_purged'] += isum(6,7) | |
+ innodb_status['transactions_purged'] += int(istatus[6], 16) | |
elif "History list length" in line: | |
innodb_status['history_list'] = longish(istatus[3]) | |
@@ -155,10 +155,10 @@ | |
innodb_status['pending_chkp_writes'] = longish(istatus[4]) | |
elif "Log sequence number" in line: | |
- innodb_status['log_bytes_written'] = isum(3,4) | |
+ innodb_status['log_bytes_written'] = longish(istatus[3]) | |
elif "Log flushed up to" in line: | |
- innodb_status['log_bytes_flushed'] = isum(4,5) | |
+ innodb_status['log_bytes_flushed'] = longish(istatus[4]) | |
# BUFFER POOL AND MEMORY | |
elif "Buffer pool size" in line: | |
@@ -172,7 +172,11 @@ | |
elif "Modified db pages" in line: | |
innodb_status['buffer_pool_pages_dirty'] = longish(istatus[3]) | |
- | |
+ | |
+ elif "Pages read ahead" in line: | |
+ # XXX: prevent to match next rule by this line | |
+ 0 | |
+ | |
elif "Pages read" in line: | |
innodb_status['pages_read'] = longish(istatus[2]) | |
innodb_status['pages_created'] = longish(istatus[4]) | |
@@ -202,14 +206,15 @@ | |
parser.add_option("-H", "--Host", dest="host", help="Host running mysql", default="localhost") | |
parser.add_option("-u", "--user", dest="user", help="user to connect as", default="") | |
parser.add_option("-p", "--password", dest="passwd", help="password", default="") | |
+ parser.add_option("-s", "--socket", dest="socket", help="socket", default="") | |
(options, args) = parser.parse_args() | |
try: | |
- conn = MySQLdb.connect(user=options.user, host=options.host, passwd=options.passwd) | |
+ conn = MySQLdb.connect(user=options.user, host=options.host, passwd=options.passwd, unix_socket=options.socket) | |
cursor = conn.cursor(MySQLdb.cursors.Cursor) | |
cursor.execute("SHOW /*!50000 ENGINE*/ INNODB STATUS") | |
- innodb_status = parse_innodb_status(cursor.fetchone()[0].split('\n')) | |
+ innodb_status = parse_innodb_status(cursor.fetchone()[2].split('\n')) | |
cursor.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment