Skip to content

Commit

Permalink
Custom mysql port and timeout integer fix
Browse files Browse the repository at this point in the history
When mysql.pyconf configured with custom port:

    param port {
      value = 3307
    }

gmond gives into log:
[PYTHON] Can't call the metric_init function in the python module [mysql].#12

and further investigation with
*gmond -d 1*
shows

[PYTHON] Can't call the metric_init function in the python module [mysql].
Traceback (most recent call last):
  File "/usr/lib64/ganglia/python_modules/mysql.py", line 1005, in metric_init
    update_stats(REPORT_INNODB, REPORT_MASTER, REPORT_SLAVE)
  File "/usr/lib64/ganglia/python_modules/mysql.py", line 86, in update_stats
    conn = MySQLdb.connect(**mysql_conn_opts)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
TypeError: an integer is required

Method params.get converted explicitly as integer with timeout and port option.
  • Loading branch information
tomasruprich committed Mar 26, 2014
1 parent ff02e90 commit b4060c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mysqld/python_modules/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ def metric_init(params):
host = params.get('host', 'localhost'),
user = params.get('user'),
passwd = params.get('passwd'),
port = params.get('port', 3306),
connect_timeout = params.get('timeout', 30),
port = int(params.get('port', 3306)),
connect_timeout = int(params.get('timeout', 30)),
)
if params.get('unix_socket', '') != '':
mysql_conn_opts['unix_socket'] = params.get('unix_socket')
Expand Down

0 comments on commit b4060c1

Please sign in to comment.