Last active
December 12, 2015 12:18
-
-
Save ziguzagu/4770780 to your computer and use it in GitHub Desktop.
https://github.com/ganglia/gmond_python_modules の mysqld モジュール MySQL 5.5 対応パッチ
This file contains hidden or 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
| diff --git a/mysqld/python_modules/DBUtil.py b/mysqld/python_modules/DBUtil.py | |
| index 21b7522..db2bfbb 100644 | |
| --- a/mysqld/python_modules/DBUtil.py | |
| +++ b/mysqld/python_modules/DBUtil.py | |
| @@ -86,7 +86,7 @@ def parse_innodb_status(innodb_status_raw): | |
| innodb_status['active_transactions'] | |
| for line in innodb_status_raw: | |
| - istatus = line.split() | |
| + istatus = line.replace(',', '').split() | |
| isum = sumof(istatus) | |
| @@ -97,15 +97,15 @@ def parse_innodb_status(innodb_status_raw): | |
| 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]) # isum(2,8) | |
| + innodb_status['os_waits'] += longish(istatus[7]) # isum(5,11) | |
| # TRANSACTIONS | |
| elif "Trx id counter" in line: | |
| - innodb_status['transactions'] += isum(3,4) | |
| + innodb_status['transactions'] += int(istatus[3], 16) # isum(3,4) | |
| elif "Purge done for trx" in line: | |
| - innodb_status['transactions_purged'] += isum(6,7) | |
| + innodb_status['transactions_purged'] += int(istatus[6], 16) # isum(6,7) | |
| elif "History list length" in line: | |
| innodb_status['history_list'] = longish(istatus[3]) | |
| @@ -155,10 +155,10 @@ def parse_innodb_status(innodb_status_raw): | |
| 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]) #isum(3,4) | |
| elif "Log flushed up to" in line: | |
| - innodb_status['log_bytes_flushed'] = isum(4,5) | |
| + innodb_status['log_bytes_flushed'] = longish(istatus[4]) #isum(4,5) | |
| # BUFFER POOL AND MEMORY | |
| elif "Buffer pool size" in line: | |
| @@ -172,6 +172,10 @@ def parse_innodb_status(innodb_status_raw): | |
| 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]) | |
| @@ -209,7 +213,7 @@ if __name__ == '__main__': | |
| 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() |
This file contains hidden or 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
| diff --git a/mysqld/python_modules/mysql.py b/mysqld/python_modules/mysql.py | |
| index d68153f..cd5d32b 100644 | |
| --- a/mysqld/python_modules/mysql.py | |
| +++ b/mysqld/python_modules/mysql.py | |
| @@ -124,7 +124,7 @@ def update_stats(get_innodb=True, get_master=True, get_slave=True): | |
| if get_innodb: | |
| 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() | |
| logging.debug('innodb_status: ' + str(innodb_status)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment