@cryptotaxi247 / netdata-1 / commits / d6d7cb59f

mysql module add ssl connection support (#5610)

<!-- Describe the change in summary section, including rationale and degin decisions. Include "Fixes #nnn" if you are fixing an existing issue. In "Component Name" section write which component is changed in this PR. This will help us review your PR quicker. If you have more information you want to add, write them in "Additional Information" section. This is usually used to help others understand your motivation behind this change. A step-by-step reproduction of the problem is helpful if there is no related issue. --> ##### Summary Fixes: #5608 Add ssl connection support to MySQLService > python-mysqlclient connection ``` :param dict ssl: dictionary or mapping contains SSL connection parameters; see the MySQL documentation for more details (mysql_ssl_set()). If this is set, and the client does not support SSL, NotSupportedError will be raised. ``` [SSL connection parameters:](https://dev.mysql.com/doc/refman/5.6/en/mysql-ssl-set.html) - **key**: The path name of the client private key file. - **cert**: The path name of the client public key certificate file. - **ca**: The path name of the Certificate Authority (CA) certificate file. This option, if used, must specify the same certificate used by the server. - **capath**: The path name of the directory that contains trusted SSL CA certificate files. - **cipher**: The list of permitted ciphers for SSL encryption. ##### Component Name [`collectors/python.d.plugin/python_modules/bases/FrameworkServices/MySQLService`](https://github.com/netdata/netdata/blob/master/collectors/python.d.plugin/python_modules/bases/FrameworkServices/MySQLService.py) ___ @woosley please test it ```yaml tcp: name : 'local' user : 'user' pass : 'pass' host : 'localhost' port : '3306' ssl: key: 'path/to/key' cert: 'path/to/cet' ca: 'path/to/ca' ```

Ilya Mashchenko committed Mar 12, 2019 at 13:10 UTC d6d7cb59fe118902bbc853ba4a6b0ce7b547f64b
3 files changed +200 -11
collectors/python.d.plugin/mysql/README.md
+186 -11
@@ -7,7 +7,7 @@ Module monitors one or more mysql servers
7
8 It will produce following charts (if data is available):
9
10 -1. **Bandwidth** in kbps
10 +1. **Bandwidth** in kilobits/s
11 * in
12 * out
13
@@ -16,9 +16,15 @@ It will produce following charts (if data is available):
16 * questions
17 * slow queries
18
19 -3. **Operations** in operations/sec
20 - * opened tables
21 - * flush
19 +3. **Queries By Type** in queries/s
20 + * select
21 + * delete
22 + * update
23 + * insert
24 + * cache hits
25 + * replace
26 +
27 +4. **Handlerse** in handlers/s
28 * commit
29 * delete
30 * prepare
@@ -26,29 +32,192 @@ It will produce following charts (if data is available):
32 * read key
33 * read next
34 * read prev
29 - * read random
30 - * read random next
35 + * read rnd
36 + * read rnd next
37 * rollback
32 - * save point
38 + * savepoint
39 + * savepoint rollback
40 * update
41 * write
42
36 -4. **Table Locks** in locks/sec
43 +4. **Table Locks** in locks/s
44 * immediate
45 * waited
46
40 -5. **Select Issues** in issues/sec
47 +5. **Table Select Join Issuess** in joins/s
48 * full join
49 * full range join
50 * range
51 * range check
52 * scan
53
47 -6. **Sort Issues** in issues/sec
54 +6. **Table Sort Issuess** in joins/s
55 * merge passes
56 * range
57 * scan
58
59 +7. **Tmp Operations** in created/s
60 + * disk tables
61 + * files
62 + * tables
63 +
64 +8. **Connections** in connections/s
65 + * all
66 + * aborted
67 +
68 +9. **Connections Active** in connections/s
69 + * active
70 + * limit
71 + * max active
72 +
73 +10. **Binlog Cache** in threads
74 + * disk
75 + * all
76 +
77 +11. **Threads** in transactions/s
78 + * connected
79 + * cached
80 + * running
81 +
82 +12. **Threads Creation Rate** in threads/s
83 + * created
84 +
85 +13. **Threads Cache Misses** in misses
86 + * misses
87 +
88 +14. **InnoDB I/O Bandwidth** in KiB/s
89 + * read
90 + * write
91 +
92 +15. **InnoDB I/O Operations** in operations/s
93 + * reads
94 + * writes
95 + * fsyncs
96 +
97 +16. **InnoDB Pending I/O Operations** in operations/s
98 + * reads
99 + * writes
100 + * fsyncs
101 +
102 +17. **InnoDB Log Operations** in operations/s
103 + * waits
104 + * write requests
105 + * writes
106 +
107 +18. **InnoDB OS Log Pending Operations** in operations
108 + * fsyncs
109 + * writes
110 +
111 +19. **InnoDB OS Log Operations** in operations/s
112 + * fsyncs
113 +
114 +20. **InnoDB OS Log Bandwidth** in KiB/s
115 + * write
116 +
117 +21. **InnoDB Current Row Locks** in operations
118 + * current waits
119 +
120 +22. **InnoDB Row Operations** in operations/s
121 + * inserted
122 + * read
123 + * updated
124 + * deleted
125 +
126 +23. **InnoDB Buffer Pool Pagess** in pages
127 + * data
128 + * dirty
129 + * free
130 + * misc
131 + * total
132 +
133 +24. **InnoDB Buffer Pool Flush Pages Requests** in requests/s
134 + * flush pages
135 +
136 +25. **InnoDB Buffer Pool Bytes** in MiB
137 + * data
138 + * dirty
139 +
140 +26. **InnoDB Buffer Pool Operations** in operations/s
141 + * disk reads
142 + * wait free
143 +
144 +27. **QCache Operations** in queries/s
145 + * hits
146 + * lowmem prunes
147 + * inserts
148 + * no caches
149 +
150 +28. **QCache Queries in Cache** in queries
151 + * queries
152 +
153 +29. **QCache Free Memory** in MiB
154 + * free
155 +
156 +30. **QCache Memory Blocks** in blocks
157 + * free
158 + * total
159 +
160 +31. **MyISAM Key Cache Blocks** in blocks
161 + * unused
162 + * used
163 + * not flushed
164 +
165 +32. **MyISAM Key Cache Requests** in requests/s
166 + * reads
167 + * writes
168 +
169 +33. **MyISAM Key Cache Requests** in requests/s
170 + * reads
171 + * writes
172 +
173 +34. **MyISAM Key Cache Disk Operations** in operations/s
174 + * reads
175 + * writes
176 +
177 +35. **Open Files** in files
178 + * files
179 +
180 +36. **Opened Files Rate** in files/s
181 + * files
182 +
183 +37. **Binlog Statement Cache** in statements/s
184 + * disk
185 + * all
186 +
187 +38. **Connection Errors** in errors/s
188 + * accept
189 + * internal
190 + * max
191 + * peer addr
192 + * select
193 + * tcpwrap
194 +
195 +39. **Slave Behind Seconds** in seconds
196 + * time
197 +
198 +40. **I/O / SQL Thread Running State** in bool
199 + * sql
200 + * io
201 +
202 +41. **Replicated Writesets** in writesets/s
203 + * rx
204 + * tx
205 +
206 +42. **Replicated Bytes** in KiB/s
207 + * rx
208 + * tx
209 +
210 +43. **Galera Queue** in writesets
211 + * rx
212 + * tx
213 +
214 +44. **Replication Conflicts** in transactions
215 + * bf aborts
216 + * cert fails
217 +
218 +45. **Flow Control** in ms
219 + * paused
220 +
221 ### configuration
222
223 You can provide, per server, the following:
@@ -59,7 +228,13 @@ You can provide, per server, the following:
228 4. mysql socket (optional)
229 5. mysql host (ip or hostname)
230 6. mysql port (defaults to 3306)
62 -
231 +7. ssl connection parameters
232 + - key: the path name of the client private key file.
233 + - cert: the path name of the client public key certificate file.
234 + - ca: the path name of the Certificate Authority (CA) certificate file. This option, if used, must specify the same certificate used by the server.
235 + - capath: the path name of the directory that contains trusted SSL CA certificate files.
236 + - cipher: the list of permitted ciphers for SSL encryption.
237 +
238 Here is an example for 3 servers:
239
240 ```yaml
collectors/python.d.plugin/mysql/mysql.conf
+8
@@ -73,6 +73,14 @@
73 # user: 'username' # the mysql username to use
74 # pass: 'password' # the mysql password to use
75 #
76 +# ssl connection parameters
77 +#
78 +# ssl:
79 +# key: 'key' # the path name of the client private key file.
80 +# cert: 'cert' # the path name of the client public key certificate file.
81 +# ca: 'ca' # the path name of the Certificate Authority (CA) certificate file. This option, if used, must specify the same certificate used by the server.
82 +# capath: 'capath' # the path name of the directory that contains trusted SSL CA certificate files.
83 +# cipher: [ciphers] # the list of permitted ciphers for SSL encryption.
84
85 # ----------------------------------------------------------------------
86 # mySQL CONFIGURATION
collectors/python.d.plugin/python_modules/bases/FrameworkServices/MySQLService.py
+6
@@ -44,6 +44,7 @@ class MySQLService(SimpleService):
44 properties['user'] = conf['user']
45 if conf.get('pass'):
46 properties['passwd'] = conf['pass']
47 +
48 if conf.get('socket'):
49 properties['unix_socket'] = conf['socket']
50 elif conf.get('host'):
@@ -51,9 +52,14 @@ class MySQLService(SimpleService):
52 properties['port'] = int(conf.get('port', 3306))
53 elif conf.get('my.cnf'):
54 if MySQLdb.__name__ == 'pymysql':
55 + # TODO: this is probablt wrong, it depends on version
56 self.error('"my.cnf" parsing is not working for pymysql')
57 else:
58 properties['read_default_file'] = conf['my.cnf']
59 +
60 + if conf.get('ssl'):
61 + properties['ssl'] = conf['ssl']
62 +
63 if isinstance(extra_conf, dict) and extra_conf:
64 properties.update(extra_conf)
65