summaryrefslogtreecommitdiffstats
path: root/python.d/mysql.chart.py
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2016-11-23 15:49:10 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2016-11-23 15:49:10 +0000
commit87649cf32bd0e14d5a903fb85b01e9f41a253540 (patch)
treebbefda6dac074aeb87529592e8e5064f69cbe024 /python.d/mysql.chart.py
parentImported Upstream version 1.3.0+dfsg (diff)
downloadnetdata-87649cf32bd0e14d5a903fb85b01e9f41a253540.tar.xz
netdata-87649cf32bd0e14d5a903fb85b01e9f41a253540.zip
New upstream version 1.4.0+dfsgupstream/1.4.0+dfsg
Diffstat (limited to 'python.d/mysql.chart.py')
-rw-r--r--python.d/mysql.chart.py33
1 files changed, 11 insertions, 22 deletions
diff --git a/python.d/mysql.chart.py b/python.d/mysql.chart.py
index 7c3931acf..dab6fad3b 100644
--- a/python.d/mysql.chart.py
+++ b/python.d/mysql.chart.py
@@ -317,40 +317,29 @@ class Service(SimpleService):
:param configuration: dict
:return: dict
"""
+ parameters = {}
if self.name is None:
self.name = 'local'
- if 'user' not in configuration:
- self.configuration['user'] = 'root'
- if 'pass' not in configuration:
- self.configuration['pass'] = ''
+ if 'user' in configuration:
+ parameters['user'] = self.configuration['user']
+ if 'pass' in configuration:
+ parameters['passwd'] = self.configuration['pass']
if 'my.cnf' in configuration:
- self.configuration['socket'] = ''
- self.configuration['host'] = ''
- self.configuration['port'] = 0
+ parameters['read_default_file'] = self.configuration['my.cnf']
elif 'socket' in configuration:
- self.configuration['my.cnf'] = ''
- self.configuration['host'] = ''
- self.configuration['port'] = 0
+ parameters['unix_socket'] = self.configuration['socket']
elif 'host' in configuration:
- self.configuration['my.cnf'] = ''
- self.configuration['socket'] = ''
+ parameters['host'] = self.configuration['host']
if 'port' in configuration:
- self.configuration['port'] = int(configuration['port'])
- else:
- self.configuration['port'] = 3306
+ parameters['port'] = int(self.configuration['port'])
+ self.connection_parameters = parameters
def _connect(self):
"""
Try to connect to MySQL server
"""
try:
- self.connection = MySQLdb.connect(user=self.configuration['user'],
- passwd=self.configuration['pass'],
- read_default_file=self.configuration['my.cnf'],
- unix_socket=self.configuration['socket'],
- host=self.configuration['host'],
- port=self.configuration['port'],
- connect_timeout=self.update_every)
+ self.connection = MySQLdb.connect(connect_timeout=self.update_every, **self.connection_parameters)
except MySQLdb.OperationalError as e:
self.error("Cannot establish connection to MySQL.")
self.debug(str(e))