@cryptotaxi247 / netdata-1 / commits / 62ef6b1f8

increase verbosity of mysql.chart.py

paulfantom committed Jun 14, 2016 at 20:12 UTC 62ef6b1f8577498a0d3fa6c5687b55cd4d3e927e
1 file changed +9 -5
python.d/mysql.chart.py
+9 -5
@@ -1,11 +1,12 @@
1 #!/usr/bin/python3 -u
2
3 +NAME = "mysql.chart.py"
4 +from sys import stderr
5 try:
6 import pymysql.cursors
7 # https://github.com/PyMySQL/PyMySQL
8 except ImportError:
7 - import sys
8 - sys.stderr.write("mysql.chart.d: You need to install PyMySQL module to use mysql.chart.py plugin")
9 + stderr.write(NAME + ": You need to install PyMySQL module to use mysql.chart.py plugin\n")
10
11 config = [
12 {
@@ -308,7 +309,8 @@ def get_data(config):
309 global connections
310 try:
311 cnx = connections[config['name']]
311 - except KeyError:
312 + except KeyError as e:
313 + stderr.write(NAME + ": reconnecting\n")
314 cnx = pymysql.connect(user=config['user'],
315 password=config['password'],
316 unix_socket=config['socket'],
@@ -321,7 +323,8 @@ def get_data(config):
323 with cnx.cursor() as cursor:
324 cursor.execute(QUERY)
325 raw_data = cursor.fetchall()
324 - except Exception:
326 + except Exception as e:
327 + stderr.write(NAME + ": cannot execute query." + str(e) + "\n")
328 cnx.close()
329 del connections[config['name']]
330 return None
@@ -365,7 +368,8 @@ def check():
368 port=srv['port'],
369 connect_timeout=int(update_every))
370 cnx.close()
368 - except:
371 + except Exception as e:
372 + stderr.write(NAME + " has problem connecting to server: "+str(e)+"\n")
373 config.remove(srv)
374
375 if len(config) == 0: