-
Notifications
You must be signed in to change notification settings - Fork 352
/
Copy pathmysql.py
1177 lines (987 loc) · 30.2 KB
/
mysql.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
The MIT License
Copyright (c) 2008 Gilad Raphaelli <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
### Changelog:
### v1.0.1 - 2010-07-21
### * Initial version
###
### v1.0.2 - 2010-08-04
### * Added system variables: max_connections and query_cache_size
### * Modified some innodb status variables to become deltas
###
### v1.0.3 - 2011-12-02
### * Support custom UNIX sockets
###
### Requires:
### * yum install MySQL-python
### * DBUtil.py
### Copyright Jamie Isaacs. 2010
### License to use, modify, and distribute under the GPL
### http://www.gnu.org/licenses/gpl.txt
import time
import MySQLdb
from DBUtil import parse_innodb_status, defaultdict
import logging
descriptors = []
logging.basicConfig(level=logging.ERROR, format="%(asctime)s - %(name)s - %(levelname)s\t Thread-%(thread)d - %(message)s", filename='/tmp/mysqlstats.log', filemode='w')
logging.debug('starting up')
last_update = 0
mysql_conn_opts = {}
mysql_stats = {}
mysql_stats_last = {}
delta_per_second = False
REPORT_INNODB = True
REPORT_MASTER = True
REPORT_SLAVE = True
MAX_UPDATE_TIME = 15
def update_stats(get_innodb=True, get_master=True, get_slave=True):
"""
"""
logging.debug('updating stats')
global last_update
global mysql_stats, mysql_stats_last
cur_time = time.time()
time_delta = cur_time - last_update
if time_delta <= 0:
#we went backward in time.
logging.debug(" system clock set backwards, probably ntp")
if cur_time - last_update < MAX_UPDATE_TIME:
logging.debug(' wait ' + str(int(MAX_UPDATE_TIME - (cur_time - last_update))) + ' seconds')
return True
else:
last_update = cur_time
logging.debug('refreshing stats')
mysql_stats = {}
# Get info from DB
try:
conn = MySQLdb.connect(**mysql_conn_opts)
cursor = conn.cursor(MySQLdb.cursors.DictCursor)
cursor.execute("SELECT GET_LOCK('gmetric-mysql', 0) as ok")
lock_stat = cursor.fetchone()
cursor.close()
if lock_stat['ok'] == 0:
return False
cursor = conn.cursor(MySQLdb.cursors.Cursor)
cursor.execute("SHOW VARIABLES")
#variables = dict(((k.lower(), v) for (k,v) in cursor))
variables = {}
for (k,v) in cursor:
variables[k.lower()] = v
cursor.close()
cursor = conn.cursor(MySQLdb.cursors.Cursor)
cursor.execute("SHOW /*!50002 GLOBAL */ STATUS")
#global_status = dict(((k.lower(), v) for (k,v) in cursor))
global_status = {}
for (k,v) in cursor:
global_status[k.lower()] = v
cursor.close()
cursor = conn.cursor(MySQLdb.cursors.Cursor)
cursor.execute("SELECT PLUGIN_STATUS, PLUGIN_VERSION FROM `information_schema`.Plugins WHERE PLUGIN_NAME LIKE '%innodb%' AND PLUGIN_TYPE LIKE 'STORAGE ENGINE';")
have_innodb = False
innodb_version = 1.0
row = cursor.fetchone()
if row[0] == "ACTIVE":
have_innodb = True
innodb_version = row[1]
cursor.close()
# try not to fail ?
get_innodb = get_innodb and have_innodb
get_master = get_master and variables['log_bin'].lower() == 'on'
innodb_status = defaultdict(int)
if get_innodb:
cursor = conn.cursor(MySQLdb.cursors.Cursor)
cursor.execute("SHOW /*!50000 ENGINE*/ INNODB STATUS")
innodb_status = parse_innodb_status(cursor.fetchone()[2].split('\n'), innodb_version)
cursor.close()
logging.debug('innodb_status: ' + str(innodb_status))
master_logs = tuple
if get_master:
cursor = conn.cursor(MySQLdb.cursors.Cursor)
cursor.execute("SHOW MASTER LOGS")
master_logs = cursor.fetchall()
cursor.close()
slave_status = {}
if get_slave:
cursor = conn.cursor(MySQLdb.cursors.DictCursor)
cursor.execute("SHOW SLAVE STATUS")
res = cursor.fetchone()
if res:
for (k,v) in res.items():
slave_status[k.lower()] = v
else:
get_slave = False
cursor.close()
cursor = conn.cursor(MySQLdb.cursors.DictCursor)
cursor.execute("SELECT RELEASE_LOCK('gmetric-mysql') as ok")
cursor.close()
conn.close()
except MySQLdb.OperationalError, (errno, errmsg):
logging.error('error updating stats')
logging.error(errmsg)
return False
# process variables
# http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
mysql_stats['version'] = variables['version']
mysql_stats['max_connections'] = variables['max_connections']
mysql_stats['query_cache_size'] = variables['query_cache_size']
# process global status
# http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
interesting_global_status_vars = (
'aborted_clients',
'aborted_connects',
'binlog_cache_disk_use',
'binlog_cache_use',
'bytes_received',
'bytes_sent',
'com_delete',
'com_delete_multi',
'com_insert',
'com_insert_select',
'com_load',
'com_replace',
'com_replace_select',
'com_select',
'com_update',
'com_update_multi',
'connections',
'created_tmp_disk_tables',
'created_tmp_files',
'created_tmp_tables',
'key_reads',
'key_read_requests',
'key_writes',
'key_write_requests',
'max_used_connections',
'open_files',
'open_tables',
'opened_tables',
'qcache_free_blocks',
'qcache_free_memory',
'qcache_hits',
'qcache_inserts',
'qcache_lowmem_prunes',
'qcache_not_cached',
'qcache_queries_in_cache',
'qcache_total_blocks',
'questions',
'select_full_join',
'select_full_range_join',
'select_range',
'select_range_check',
'select_scan',
'slave_open_temp_tables',
'slave_retried_transactions',
'slow_launch_threads',
'slow_queries',
'sort_range',
'sort_rows',
'sort_scan',
'table_locks_immediate',
'table_locks_waited',
'threads_cached',
'threads_connected',
'threads_created',
'threads_running',
'uptime',
)
non_delta = (
'max_used_connections',
'open_files',
'open_tables',
'qcache_free_blocks',
'qcache_free_memory',
'qcache_total_blocks',
'slave_open_temp_tables',
'threads_cached',
'threads_connected',
'threads_running',
'uptime'
)
# don't put all of global_status in mysql_stats b/c it's so big
for key in interesting_global_status_vars:
if key in non_delta:
mysql_stats[key] = global_status[key]
else:
# Calculate deltas for counters
if time_delta <= 0:
#systemclock was set backwards, nog updating values.. to smooth over the graphs
pass
elif key in mysql_stats_last:
if delta_per_second:
mysql_stats[key] = (int(global_status[key]) - int(mysql_stats_last[key])) / time_delta
else:
mysql_stats[key] = int(global_status[key]) - int(mysql_stats_last[key])
else:
mysql_stats[key] = float(0)
mysql_stats_last[key] = global_status[key]
mysql_stats['open_files_used'] = int(global_status['open_files']) / int(variables['open_files_limit'])
innodb_delta = (
'data_fsyncs',
'data_reads',
'data_writes',
'log_writes'
)
# process innodb status
if get_innodb:
for istat in innodb_status:
key = 'innodb_' + istat
if istat in innodb_delta:
# Calculate deltas for counters
if time_delta <= 0:
#systemclock was set backwards, nog updating values.. to smooth over the graphs
pass
elif key in mysql_stats_last:
if delta_per_second:
mysql_stats[key] = (int(innodb_status[istat]) - int(mysql_stats_last[key])) / time_delta
else:
mysql_stats[key] = int(innodb_status[istat]) - int(mysql_stats_last[key])
else:
mysql_stats[key] = float(0)
mysql_stats_last[key] = innodb_status[istat]
else:
mysql_stats[key] = innodb_status[istat]
# process master logs
if get_master:
mysql_stats['binlog_count'] = len(master_logs)
mysql_stats['binlog_space_current'] = master_logs[-1][1]
#mysql_stats['binlog_space_total'] = sum((long(s[1]) for s in master_logs))
mysql_stats['binlog_space_total'] = 0
for s in master_logs:
mysql_stats['binlog_space_total'] += int(s[1])
mysql_stats['binlog_space_used'] = float(master_logs[-1][1]) / float(variables['max_binlog_size']) * 100
# process slave status
if get_slave:
mysql_stats['slave_exec_master_log_pos'] = slave_status['exec_master_log_pos']
#mysql_stats['slave_io'] = 1 if slave_status['slave_io_running'].lower() == "yes" else 0
if slave_status['slave_io_running'].lower() == "yes":
mysql_stats['slave_io'] = 1
else:
mysql_stats['slave_io'] = 0
#mysql_stats['slave_sql'] = 1 if slave_status['slave_sql_running'].lower() =="yes" else 0
if slave_status['slave_sql_running'].lower() == "yes":
mysql_stats['slave_sql'] = 1
else:
mysql_stats['slave_sql'] = 0
mysql_stats['slave_lag'] = slave_status['seconds_behind_master']
mysql_stats['slave_relay_log_pos'] = slave_status['relay_log_pos']
mysql_stats['slave_relay_log_space'] = slave_status['relay_log_space']
logging.debug('success updating stats')
logging.debug('mysql_stats: ' + str(mysql_stats))
def get_stat(name):
logging.info("getting stat: %s" % name)
global mysql_stats
#logging.debug(mysql_stats)
global REPORT_INNODB
global REPORT_MASTER
global REPORT_SLAVE
ret = update_stats(REPORT_INNODB, REPORT_MASTER, REPORT_SLAVE)
if ret:
if name.startswith('mysql_'):
label = name[6:]
else:
label = name
logging.debug("fetching %s" % name)
try:
return mysql_stats[label]
except:
logging.error("failed to fetch %s" % name)
return 0
else:
return 0
def metric_init(params):
global descriptors
global mysql_conn_opts
global mysql_stats
global delta_per_second
global REPORT_INNODB
global REPORT_MASTER
global REPORT_SLAVE
REPORT_INNODB = str(params.get('get_innodb', True)) == "True"
REPORT_MASTER = str(params.get('get_master', True)) == "True"
REPORT_SLAVE = str(params.get('get_slave', True)) == "True"
logging.debug("init: " + str(params))
mysql_conn_opts = dict(
host = params.get('host', 'localhost'),
user = params.get('user'),
passwd = params.get('passwd'),
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')
if params.get("delta_per_second", '') != '':
delta_per_second = True
master_stats_descriptions = {}
innodb_stats_descriptions = {}
slave_stats_descriptions = {}
misc_stats_descriptions = dict(
aborted_clients = {
'description': 'The number of connections that were aborted because the client died without closing the connection properly',
'value_type': 'float',
'units': 'clients',
},
aborted_connects = {
'description': 'The number of failed attempts to connect to the MySQL server',
'value_type': 'float',
'units': 'conns',
},
binlog_cache_disk_use = {
'description': 'The number of transactions that used the temporary binary log cache but that exceeded the value of binlog_cache_size and used a temporary file to store statements from the transaction',
'value_type': 'float',
'units': 'txns',
},
binlog_cache_use = {
'description': ' The number of transactions that used the temporary binary log cache',
'value_type': 'float',
'units': 'txns',
},
bytes_received = {
'description': 'The number of bytes received from all clients',
'value_type': 'float',
'units': 'bytes',
},
bytes_sent = {
'description': ' The number of bytes sent to all clients',
'value_type': 'float',
'units': 'bytes',
},
com_delete = {
'description': 'The number of DELETE statements',
'value_type': 'float',
'units': 'stmts',
},
com_delete_multi = {
'description': 'The number of multi-table DELETE statements',
'value_type': 'float',
'units': 'stmts',
},
com_insert = {
'description': 'The number of INSERT statements',
'value_type': 'float',
'units': 'stmts',
},
com_insert_select = {
'description': 'The number of INSERT ... SELECT statements',
'value_type': 'float',
'units': 'stmts',
},
com_load = {
'description': 'The number of LOAD statements',
'value_type': 'float',
'units': 'stmts',
},
com_replace = {
'description': 'The number of REPLACE statements',
'value_type': 'float',
'units': 'stmts',
},
com_replace_select = {
'description': 'The number of REPLACE ... SELECT statements',
'value_type': 'float',
'units': 'stmts',
},
com_select = {
'description': 'The number of SELECT statements',
'value_type': 'float',
'units': 'stmts',
},
com_update = {
'description': 'The number of UPDATE statements',
'value_type': 'float',
'units': 'stmts',
},
com_update_multi = {
'description': 'The number of multi-table UPDATE statements',
'value_type': 'float',
'units': 'stmts',
},
connections = {
'description': 'The number of connection attempts (successful or not) to the MySQL server',
'value_type': 'float',
'units': 'conns',
},
created_tmp_disk_tables = {
'description': 'The number of temporary tables on disk created automatically by the server while executing statements',
'value_type': 'float',
'units': 'tables',
},
created_tmp_files = {
'description': 'The number of temporary files mysqld has created',
'value_type': 'float',
'units': 'files',
},
created_tmp_tables = {
'description': 'The number of in-memory temporary tables created automatically by the server while executing statement',
'value_type': 'float',
'units': 'tables',
},
#TODO in graphs: key_read_cache_miss_rate = key_reads / key_read_requests
key_read_requests = {
'description': 'The number of requests to read a key block from the cache',
'value_type': 'float',
'units': 'reqs',
},
key_reads = {
'description': 'The number of physical reads of a key block from disk',
'value_type': 'float',
'units': 'reads',
},
key_write_requests = {
'description': 'The number of requests to write a key block to the cache',
'value_type': 'float',
'units': 'reqs',
},
key_writes = {
'description': 'The number of physical writes of a key block to disk',
'value_type': 'float',
'units': 'writes',
},
max_used_connections = {
'description': 'The maximum number of connections that have been in use simultaneously since the server started',
'units': 'conns',
'slope': 'both',
},
open_files = {
'description': 'The number of files that are open',
'units': 'files',
'slope': 'both',
},
open_tables = {
'description': 'The number of tables that are open',
'units': 'tables',
'slope': 'both',
},
# If Opened_tables is big, your table_cache value is probably too small.
opened_tables = {
'description': 'The number of tables that have been opened',
'value_type': 'float',
'units': 'tables',
},
qcache_free_blocks = {
'description': 'The number of free memory blocks in the query cache',
'units': 'blocks',
'slope': 'both',
},
qcache_free_memory = {
'description': 'The amount of free memory for the query cache',
'units': 'bytes',
'slope': 'both',
},
qcache_hits = {
'description': 'The number of query cache hits',
'value_type': 'float',
'units': 'hits',
},
qcache_inserts = {
'description': 'The number of queries added to the query cache',
'value_type': 'float',
'units': 'queries',
},
qcache_lowmem_prunes = {
'description': 'The number of queries that were deleted from the query cache because of low memory',
'value_type': 'float',
'units': 'queries',
},
qcache_not_cached = {
'description': 'The number of non-cached queries (not cacheable, or not cached due to the query_cache_type setting)',
'value_type': 'float',
'units': 'queries',
},
qcache_queries_in_cache = {
'description': 'The number of queries registered in the query cache',
'value_type': 'float',
'units': 'queries',
},
qcache_total_blocks = {
'description': 'The total number of blocks in the query cache',
'units': 'blocks',
},
questions = {
'description': 'The number of statements that clients have sent to the server',
'value_type': 'float',
'units': 'stmts',
},
# If this value is not 0, you should carefully check the indexes of your tables.
select_full_join = {
'description': 'The number of joins that perform table scans because they do not use indexes',
'value_type': 'float',
'units': 'joins',
},
select_full_range_join = {
'description': 'The number of joins that used a range search on a reference table',
'value_type': 'float',
'units': 'joins',
},
select_range = {
'description': 'The number of joins that used ranges on the first table',
'value_type': 'float',
'units': 'joins',
},
# If this is not 0, you should carefully check the indexes of your tables.
select_range_check = {
'description': 'The number of joins without keys that check for key usage after each row',
'value_type': 'float',
'units': 'joins',
},
select_scan = {
'description': 'The number of joins that did a full scan of the first table',
'value_type': 'float',
'units': 'joins',
},
slave_open_temp_tables = {
'description': 'The number of temporary tables that the slave SQL thread currently has open',
'value_type': 'float',
'units': 'tables',
'slope': 'both',
},
slave_retried_transactions = {
'description': 'The total number of times since startup that the replication slave SQL thread has retried transactions',
'value_type': 'float',
'units': 'count',
},
slow_launch_threads = {
'description': 'The number of threads that have taken more than slow_launch_time seconds to create',
'value_type': 'float',
'units': 'threads',
},
slow_queries = {
'description': 'The number of queries that have taken more than long_query_time seconds',
'value_type': 'float',
'units': 'queries',
},
sort_range = {
'description': 'The number of sorts that were done using ranges',
'value_type': 'float',
'units': 'sorts',
},
sort_rows = {
'description': 'The number of sorted rows',
'value_type': 'float',
'units': 'rows',
},
sort_scan = {
'description': 'The number of sorts that were done by scanning the table',
'value_type': 'float',
'units': 'sorts',
},
table_locks_immediate = {
'description': 'The number of times that a request for a table lock could be granted immediately',
'value_type': 'float',
'units': 'count',
},
# If this is high and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.
table_locks_waited = {
'description': 'The number of times that a request for a table lock could not be granted immediately and a wait was needed',
'value_type': 'float',
'units': 'count',
},
threads_cached = {
'description': 'The number of threads in the thread cache',
'units': 'threads',
'slope': 'both',
},
threads_connected = {
'description': 'The number of currently open connections',
'units': 'threads',
'slope': 'both',
},
#TODO in graphs: The cache miss rate can be calculated as Threads_created/Connections
# Threads_created is big, you may want to increase the thread_cache_size value.
threads_created = {
'description': 'The number of threads created to handle connections',
'value_type': 'float',
'units': 'threads',
},
threads_running = {
'description': 'The number of threads that are not sleeping',
'units': 'threads',
'slope': 'both',
},
uptime = {
'description': 'The number of seconds that the server has been up',
'units': 'secs',
'slope': 'both',
},
version = {
'description': "MySQL Version",
'value_type': 'string',
'format': '%s',
},
max_connections = {
'description': "The maximum permitted number of simultaneous client connections",
'slope': 'zero',
},
query_cache_size = {
'description': "The amount of memory allocated for caching query results",
'slope': 'zero',
}
)
if REPORT_MASTER:
master_stats_descriptions = dict(
binlog_count = {
'description': "Number of binary logs",
'units': 'logs',
'slope': 'both',
},
binlog_space_current = {
'description': "Size of current binary log",
'units': 'bytes',
'slope': 'both',
},
binlog_space_total = {
'description': "Total space used by binary logs",
'units': 'bytes',
'slope': 'both',
},
binlog_space_used = {
'description': "Current binary log size / max_binlog_size",
'value_type': 'float',
'units': 'percent',
'slope': 'both',
},
)
if REPORT_SLAVE:
slave_stats_descriptions = dict(
slave_exec_master_log_pos = {
'description': "The position of the last event executed by the SQL thread from the master's binary log",
'units': 'bytes',
'slope': 'both',
},
slave_io = {
'description': "Whether the I/O thread is started and has connected successfully to the master",
'value_type': 'uint8',
'units': 'True/False',
'slope': 'both',
},
slave_lag = {
'description': "Replication Lag",
'units': 'secs',
'slope': 'both',
},
slave_relay_log_pos = {
'description': "The position up to which the SQL thread has read and executed in the current relay log",
'units': 'bytes',
'slope': 'both',
},
slave_sql = {
'description': "Slave SQL Running",
'value_type': 'uint8',
'units': 'True/False',
'slope': 'both',
},
)
if REPORT_INNODB:
innodb_stats_descriptions = dict(
innodb_active_transactions = {
'description': "Active InnoDB transactions",
'value_type':'uint',
'units': 'txns',
'slope': 'both',
},
innodb_current_transactions = {
'description': "Current InnoDB transactions",
'value_type':'uint',
'units': 'txns',
'slope': 'both',
},
innodb_buffer_pool_pages_data = {
'description': "InnoDB",
'value_type':'uint',
'units': 'pages',
},
innodb_data_fsyncs = {
'description': "The number of fsync() operations",
'value_type':'float',
'units': 'fsyncs',
},
innodb_data_reads = {
'description': "The number of data reads",
'value_type':'float',
'units': 'reads',
},
innodb_data_writes = {
'description': "The number of data writes",
'value_type':'float',
'units': 'writes',
},
innodb_buffer_pool_pages_free = {
'description': "InnoDB",
'value_type':'uint',
'units': 'pages',
'slope': 'both',
},
innodb_history_list = {
'description': "InnoDB",
'units': 'length',
'slope': 'both',
},
innodb_ibuf_inserts = {
'description': "InnoDB",
'value_type':'uint',
'units': 'inserts',
},
innodb_ibuf_merged = {
'description': "InnoDB",
'value_type':'uint',
'units': 'recs',
},
innodb_ibuf_merges = {
'description': "InnoDB",
'value_type':'uint',
'units': 'merges',
},
innodb_log_bytes_flushed = {
'description': "InnoDB",
'value_type':'uint',
'units': 'bytes',
},
innodb_log_bytes_unflushed = {
'description': "InnoDB",
'value_type':'uint',
'units': 'bytes',
'slope': 'both',
},
innodb_log_bytes_written = {
'description': "InnoDB",
'value_type':'uint',
'units': 'bytes',
},
innodb_log_writes = {
'description': "The number of physical writes to the log file",
'value_type':'float',
'units': 'writes',
},
innodb_buffer_pool_pages_dirty = {
'description': "InnoDB",
'value_type':'uint',
'units': 'pages',
'slope': 'both',
},
innodb_os_waits = {
'description': "InnoDB",
'value_type':'uint',
'units': 'waits',
},
innodb_pages_created = {
'description': "InnoDB",
'value_type':'uint',
'units': 'pages',
},
innodb_pages_read = {
'description': "InnoDB",
'value_type':'uint',
'units': 'pages',
},
innodb_pages_written = {
'description': "InnoDB",
'value_type':'uint',
'units': 'pages',
},
innodb_pending_aio_log_ios = {
'description': "InnoDB",
'value_type':'uint',
'units': 'ops',
},
innodb_pending_aio_sync_ios = {
'description': "InnoDB",
'value_type':'uint',
'units': 'ops',
},
innodb_pending_buffer_pool_flushes = {
'description': "The number of pending buffer pool page-flush requests",
'value_type':'uint',
'units': 'reqs',
'slope': 'both',
},
innodb_pending_chkp_writes = {
'description': "InnoDB",
'value_type':'uint',
'units': 'writes',
},
innodb_pending_ibuf_aio_reads = {
'description': "InnoDB",
'value_type':'uint',
'units': 'reads',
},
innodb_pending_log_flushes = {
'description': "InnoDB",
'value_type':'uint',
'units': 'reqs',
},
innodb_pending_log_writes = {
'description': "InnoDB",
'value_type':'uint',
'units': 'writes',
},
innodb_pending_normal_aio_reads = {
'description': "InnoDB",
'value_type':'uint',
'units': 'reads',
},
innodb_pending_normal_aio_writes = {
'description': "InnoDB",
'value_type':'uint',
'units': 'writes',
},