MySQL: chart active vs. max connections
Adalbert Michelic committed
Aug 2, 2018 at 12:29 UTC
68b5b5ed5e75594958d0f3beb0cdcd6609155903
1 file changed
+20
-2
python.d/mysql.chart.py
+20
-2
@@ -13,6 +13,7 @@ retries = 60
13
# query executed on MySQL server
14
QUERY_GLOBAL = 'SHOW GLOBAL STATUS;'
15
QUERY_SLAVE = 'SHOW SLAVE STATUS;'
16
+QUERY_VARIABLES = 'SHOW GLOBAL VARIABLES LIKE \'max_connections\';'
17
18
GLOBAL_STATS = [
19
'Bytes_received',
@@ -49,6 +50,7 @@ GLOBAL_STATS = [
50
'Created_tmp_tables',
51
'Connections',
52
'Aborted_connects',
53
+ 'Max_used_connections',
54
'Binlog_cache_disk_use',
55
'Binlog_cache_use',
56
'Threads_connected',
@@ -143,13 +145,16 @@ SLAVE_STATS = [
145
('Slave_IO_Running', slave_running)
146
]
147
148
+VARIABLES = [
149
+ 'max_connections']
150
+
151
ORDER = ['net',
152
'queries',
153
'handlers',
154
'table_locks',
155
'join_issues', 'sort_issues',
156
'tmp',
152
- 'connections', 'connection_errors',
157
+ 'connections', 'connections_active', 'connection_errors',
158
'binlog_cache', 'binlog_stmt_cache',
159
'threads', 'thread_cache_misses',
160
'innodb_io', 'innodb_io_ops', 'innodb_io_pending_ops', 'innodb_log', 'innodb_os_log', 'innodb_os_log_io',
@@ -227,6 +232,13 @@ CHARTS = {
232
['Connections', 'all', 'incremental'],
233
['Aborted_connects', 'aborted', 'incremental']
234
]},
235
+ 'connections_active': {
236
+ 'options': [None, 'mysql Connections Active', 'connections', 'connections', 'mysql.connections_active', 'line'],
237
+ 'lines': [
238
+ ['Threads_connected', 'active', 'absolute'],
239
+ ['max_connections', 'limit', 'absolute'],
240
+ ['Max_used_connections', 'max_active', 'absolute']
241
+ ]},
242
'binlog_cache': {
243
'options': [None, 'mysql Binlog Cache', 'transactions/s', 'binlog', 'mysql.binlog_cache', 'line'],
244
'lines': [
@@ -459,7 +471,7 @@ class Service(MySQLService):
471
MySQLService.__init__(self, configuration=configuration, name=name)
472
self.order = ORDER
473
self.definitions = CHARTS
462
- self.queries = dict(global_status=QUERY_GLOBAL, slave_status=QUERY_SLAVE)
474
+ self.queries = dict(global_status=QUERY_GLOBAL, slave_status=QUERY_SLAVE, variables=QUERY_VARIABLES)
475
476
def _get_data(self):
477
@@ -488,5 +500,11 @@ class Service(MySQLService):
500
else:
501
self.queries.pop('slave_status')
502
503
+ if 'variables' in raw_data:
504
+ variables = dict(raw_data['variables'][0])
505
+ for key in VARIABLES:
506
+ if key in variables:
507
+ to_netdata[key] = variables[key]
508
+
509
return to_netdata or None
510