From e3bad92b21328757e55c6c4dace1328a6a291dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell-Magne=20=C3=98ierud?= Date: Sat, 14 May 2011 10:15:33 +0200 Subject: [PATCH] Cleaned up the graph files a bit --- lib/Munin/MySQL/Graph/InnoDB.pm | 518 +++++++------- lib/Munin/MySQL/Graph/MyISAM.pm | 128 ++-- lib/Munin/MySQL/Graph/QueryCache.pm | 88 ++- lib/Munin/MySQL/Graph/ReplicationSlave.pm | 59 +- lib/Munin/MySQL/Graph/Standard.pm | 793 +++++++++++----------- 5 files changed, 785 insertions(+), 801 deletions(-) diff --git a/lib/Munin/MySQL/Graph/InnoDB.pm b/lib/Munin/MySQL/Graph/InnoDB.pm index 09e045c..6b32ebd 100644 --- a/lib/Munin/MySQL/Graph/InnoDB.pm +++ b/lib/Munin/MySQL/Graph/InnoDB.pm @@ -3,291 +3,287 @@ package Munin::MySQL::Graph::InnoDB; use warnings; use strict; -my %graphs = (); - -#--------------------------------------------------------------------- - -$graphs{innodb_bpool} = { - config => { - global_attrs => { - title => 'InnoDB Buffer Pool', - vlabel => 'Pages', - args => "--base 1024", - }, - data_source_attrs => { - draw => 'LINE1', - type => 'GAUGE', +sub graphs { return { + innodb_bpool => { + config => { + global_attrs => { + title => 'InnoDB Buffer Pool', + vlabel => 'Pages', + args => "--base 1024", + }, + data_source_attrs => { + draw => 'LINE1', + type => 'GAUGE', + }, }, + data_sources => [ + {name => 'ib_bpool_size', label => 'Buffer pool size', + draw => 'AREA', + colour => 'ffd660', + info => 'The total number of buffer pool pages'}, + {name => 'ib_bpool_dbpages', label => 'Database pages', + draw => 'AREA', + colour => 'cdcfc4', + info => 'The number of used buffer pool pages'}, + {name => 'ib_bpool_free', label => 'Free pages', + info => 'The number of unused buffer pool pages'}, + {name => 'ib_bpool_modpages', label => 'Modified pages', + info => 'The number of "dirty" database pages'}, + ], }, - data_sources => [ - {name => 'ib_bpool_size', label => 'Buffer pool size', - draw => 'AREA', - colour => 'ffd660', - info => 'The total number of buffer pool pages'}, - {name => 'ib_bpool_dbpages', label => 'Database pages', - draw => 'AREA', - colour => 'cdcfc4', - info => 'The number of used buffer pool pages'}, - {name => 'ib_bpool_free', label => 'Free pages', - info => 'The number of unused buffer pool pages'}, - {name => 'ib_bpool_modpages', label => 'Modified pages', - info => 'The number of "dirty" database pages'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_bpool_act} = { - config => { - global_attrs => { - title => 'InnoDB Buffer Pool Activity', - vlabel => 'Activity per ${graph_period}', - total => 'Total', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + innodb_bpool_act => { + config => { + global_attrs => { + title => 'InnoDB Buffer Pool Activity', + vlabel => 'Activity per ${graph_period}', + total => 'Total', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'ib_bpool_read', label => 'Pages read', + info => 'Pages read into the buffer pool from disk.'}, + {name => 'ib_bpool_created', label => 'Pages created', + info => 'Pages created in the buffer pool without reading the corresponding disk page.'}, + {name => 'ib_bpool_written', label => 'Pages written', + info => 'Pages written to disk from the buffer pool.'}, + ], }, - data_sources => [ - {name => 'ib_bpool_read', label => 'Pages read', - info => 'Pages read into the buffer pool from disk.'}, - {name => 'ib_bpool_created', label => 'Pages created', - info => 'Pages created in the buffer pool without reading the corresponding disk page.'}, - {name => 'ib_bpool_written', label => 'Pages written', - info => 'Pages written to disk from the buffer pool.'}, - ], -}; - - -#--------------------------------------------------------------------- - -$graphs{innodb_checkpoint_age} = { - config => { - global_attrs => { - title => 'InnoDB Checkpoint Age', - vlabel => 'Bytes', - args => "--base 1024 -l 0", - }, - data_source_attrs => { - draw => 'AREA', - type => 'GAUGE', + + + #--------------------------------------------------------------------- + + innodb_checkpoint_age => { + config => { + global_attrs => { + title => 'InnoDB Checkpoint Age', + vlabel => 'Bytes', + args => "--base 1024 -l 0", + }, + data_source_attrs => { + draw => 'AREA', + type => 'GAUGE', + }, }, + data_sources => [ + {name => 'innodb_log_size', label => 'InnoDB log size', + colour => 'cdcfc4', + info => 'The size in bytes of InnoDB log space.', + value => sub { + $_[0]->{innodb_log_file_size} * $_[0]->{innodb_log_files_in_group} + }}, + {name => 'ib_log_chkpt_age', label => 'Uncheckpointed bytes', + colour => 'ffd660', + info => 'The age in bytes of InnoDB checkpoint.', + value => sub { + $_[0]->{ib_log_flush} - $_[0]->{ib_log_checkpoint} + }}, + ], }, - data_sources => [ - {name => 'innodb_log_size', label => 'InnoDB log size', - colour => 'cdcfc4', - info => 'The size in bytes of InnoDB log space.', - value => sub { - $_[0]->{innodb_log_file_size} * $_[0]->{innodb_log_files_in_group} - }}, - {name => 'ib_log_chkpt_age', label => 'Uncheckpointed bytes', - colour => 'ffd660', - info => 'The age in bytes of InnoDB checkpoint.', - value => sub { - $_[0]->{ib_log_flush} - $_[0]->{ib_log_checkpoint} - }}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_history_length} = { - config => { - global_attrs => { - title => 'InnoDB History List', - vlabel => 'Transactions', - }, - data_source_attrs => { - draw => 'LINE1', - type => 'GAUGE', + + #--------------------------------------------------------------------- + + innodb_history_length => { + config => { + global_attrs => { + title => 'InnoDB History List', + vlabel => 'Transactions', + }, + data_source_attrs => { + draw => 'LINE1', + type => 'GAUGE', + }, }, + data_sources => [ + {name => 'ib_tnx_hist', label => 'History list length', + info => 'Number of unpurged transactions in undo space.'}, + ], }, - data_sources => [ - {name => 'ib_tnx_hist', label => 'History list length', - info => 'Number of unpurged transactions in undo space.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_insert_buf} = { - config => { - global_attrs => { - title => 'InnoDB Insert Buffer', - vlabel => 'Activity per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + innodb_insert_buf => { + config => { + global_attrs => { + title => 'InnoDB Insert Buffer', + vlabel => 'Activity per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'ib_ibuf_inserts', label => 'Inserts', + info => 'These values shows statistics about how many buffer operations InnoDB has done. The ratio of merges to inserts gives a good idea of how efficient the buffer is.'}, + {name => 'ib_ibuf_merged_rec', label => 'Merged Records'}, + {name => 'ib_ibuf_merges', label => 'Merges'}, + ], }, - data_sources => [ - {name => 'ib_ibuf_inserts', label => 'Inserts', - info => 'These values shows statistics about how many buffer operations InnoDB has done. The ratio of merges to inserts gives a good idea of how efficient the buffer is.'}, - {name => 'ib_ibuf_merged_rec', label => 'Merged Records'}, - {name => 'ib_ibuf_merges', label => 'Merges'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_insert_buf_size} = { - config => { - global_attrs => { - title => 'InnoDB Insert Buffer Size', - vlabel => 'Pages', - args => "-l 0", - }, - data_source_attrs => { - draw => 'LINE1', - type => 'GAUGE', + + #--------------------------------------------------------------------- + + innodb_insert_buf_size => { + config => { + global_attrs => { + title => 'InnoDB Insert Buffer Size', + vlabel => 'Pages', + args => "-l 0", + }, + data_source_attrs => { + draw => 'LINE1', + type => 'GAUGE', + }, }, + data_sources => [ + {name => 'ib_ibuf_seg_size', label => 'Segment size', + draw => 'AREA', + colour => 'cdcfc4', + info => 'Allocated size of insert buffer segment.'}, + {name => 'ib_ibuf_size', label => 'Unmerged pages', + colour => '0022ff', + info => 'Number of pages containing unmerged records.'}, + {name => 'ib_ibuf_free_len', label => 'Free pages', + info => 'Number of pages which are free.'}, + ], }, - data_sources => [ - {name => 'ib_ibuf_seg_size', label => 'Segment size', - draw => 'AREA', - colour => 'cdcfc4', - info => 'Allocated size of insert buffer segment.'}, - {name => 'ib_ibuf_size', label => 'Unmerged pages', - colour => '0022ff', - info => 'Number of pages containing unmerged records.'}, - {name => 'ib_ibuf_free_len', label => 'Free pages', - info => 'Number of pages which are free.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_io} = { - config => { - global_attrs => { - title => 'InnoDB IO', - vlabel => 'IO operations per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + innodb_io => { + config => { + global_attrs => { + title => 'InnoDB IO', + vlabel => 'IO operations per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'ib_io_read', label => 'File reads', + info => 'The number of calls to the OS read function.'}, + {name => 'ib_io_write', label => 'File writes', + info => 'The number of calls to the OS write function.'}, + {name => 'ib_io_log', label => 'Log writes', + info => 'The number of calls to the OS write function that is caused by the log subsystem.'}, + {name => 'ib_io_fsync', label => 'File syncs', + info => 'The number of calls to the OS fsync function.'}, + ], }, - data_sources => [ - {name => 'ib_io_read', label => 'File reads', - info => 'The number of calls to the OS read function.'}, - {name => 'ib_io_write', label => 'File writes', - info => 'The number of calls to the OS write function.'}, - {name => 'ib_io_log', label => 'Log writes', - info => 'The number of calls to the OS write function that is caused by the log subsystem.'}, - {name => 'ib_io_fsync', label => 'File syncs', - info => 'The number of calls to the OS fsync function.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_io_pend} = { - config => { - global_attrs => { - title => 'InnoDB IO Pending', - vlabel => 'Pending operations', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + innodb_io_pend => { + config => { + global_attrs => { + title => 'InnoDB IO Pending', + vlabel => 'Pending operations', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'ib_iop_log', label => 'AIO Log'}, + {name => 'ib_iop_sync', label => 'AIO Sync'}, + {name => 'ib_iop_flush_bpool', label => 'Buf Pool Flush'}, + {name => 'ib_iop_flush_log', label => 'Log Flushes'}, + {name => 'ib_iop_ibuf_aio', label => 'Insert Buf AIO Read'}, + {name => 'ib_iop_aioread', label => 'Normal AIO Reads'}, + {name => 'ib_iop_aiowrite', label => 'Normal AIO Writes'}, + ], }, - data_sources => [ - {name => 'ib_iop_log', label => 'AIO Log'}, - {name => 'ib_iop_sync', label => 'AIO Sync'}, - {name => 'ib_iop_flush_bpool', label => 'Buf Pool Flush'}, - {name => 'ib_iop_flush_log', label => 'Log Flushes'}, - {name => 'ib_iop_ibuf_aio', label => 'Insert Buf AIO Read'}, - {name => 'ib_iop_aioread', label => 'Normal AIO Reads'}, - {name => 'ib_iop_aiowrite', label => 'Normal AIO Writes'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_log} = { - config => { - global_attrs => { - title => 'InnoDB Log', - vlabel => 'Log activity per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + innodb_log => { + config => { + global_attrs => { + title => 'InnoDB Log', + vlabel => 'Log activity per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'innodb_log_buffer_size', label => 'Buffer Size', + type => 'GAUGE', + draw => 'AREA', + colour => 'fafd9e', + info => 'The size in bytes of the buffer that InnoDB uses to write to the log files on disk.'}, + {name => 'ib_log_flush', label => 'KB Flushed', + info => 'Number of bytes flushed to the transaction log file.'}, + {name => 'ib_log_written', label => 'KB Written', + info => 'Number of bytes written to the transaction log buffer.'}, + ], }, - data_sources => [ - {name => 'innodb_log_buffer_size', label => 'Buffer Size', - type => 'GAUGE', - draw => 'AREA', - colour => 'fafd9e', - info => 'The size in bytes of the buffer that InnoDB uses to write to the log files on disk.'}, - {name => 'ib_log_flush', label => 'KB Flushed', - info => 'Number of bytes flushed to the transaction log file.'}, - {name => 'ib_log_written', label => 'KB Written', - info => 'Number of bytes written to the transaction log buffer.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_rows} = { - config => { - global_attrs => { - title => 'InnoDB Row Operations', - vlabel => 'Operations per ${graph_period}', - total => 'Total', + + #--------------------------------------------------------------------- + + innodb_rows => { + config => { + global_attrs => { + title => 'InnoDB Row Operations', + vlabel => 'Operations per ${graph_period}', + total => 'Total', + }, + data_source_attrs => {}, }, - data_source_attrs => {}, + data_sources => [ + {name => 'Innodb_rows_deleted', label => 'Deletes', + info => 'The number of rows deleted from InnoDB tables.'}, + {name => 'Innodb_rows_inserted', label => 'Inserts', + info => 'The number of rows inserted into InnoDB tables.'}, + {name => 'Innodb_rows_read', label => 'Reads', + info => 'The number of rows read from InnoDB tables.'}, + {name => 'Innodb_rows_updated', label => 'Updates', + info => 'The number of rows updated in InnoDB tables.'}, + ], }, - data_sources => [ - {name => 'Innodb_rows_deleted', label => 'Deletes', - info => 'The number of rows deleted from InnoDB tables.'}, - {name => 'Innodb_rows_inserted', label => 'Inserts', - info => 'The number of rows inserted into InnoDB tables.'}, - {name => 'Innodb_rows_read', label => 'Reads', - info => 'The number of rows read from InnoDB tables.'}, - {name => 'Innodb_rows_updated', label => 'Updates', - info => 'The number of rows updated in InnoDB tables.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_semaphores} = { - config => { - global_attrs => { - title => 'InnoDB Semaphores', - vlabel => 'Semaphores per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + innodb_semaphores => { + config => { + global_attrs => { + title => 'InnoDB Semaphores', + vlabel => 'Semaphores per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'ib_spin_rounds', label => 'Spin Rounds'}, + {name => 'ib_spin_waits', label => 'Spin Waits'}, + {name => 'ib_os_waits', label => 'OS Waits'}, + ], }, - data_sources => [ - {name => 'ib_spin_rounds', label => 'Spin Rounds'}, - {name => 'ib_spin_waits', label => 'Spin Waits'}, - {name => 'ib_os_waits', label => 'OS Waits'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{innodb_tnx} = { - config => { - global_attrs => { - title => 'InnoDB Transactions', - vlabel => 'Transactions per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + innodb_tnx => { + config => { + global_attrs => { + title => 'InnoDB Transactions', + vlabel => 'Transactions per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'ib_tnx', label => 'Transactions created', + info => 'Number of transactions created.'}, + ], }, - data_sources => [ - {name => 'ib_tnx', label => 'Transactions created', - info => 'Number of transactions created.'}, - ], -}; - -sub graphs { return \%graphs; } +}} 1; diff --git a/lib/Munin/MySQL/Graph/MyISAM.pm b/lib/Munin/MySQL/Graph/MyISAM.pm index 2fbfd1e..2d3d5b0 100644 --- a/lib/Munin/MySQL/Graph/MyISAM.pm +++ b/lib/Munin/MySQL/Graph/MyISAM.pm @@ -3,76 +3,72 @@ package Munin::MySQL::Graph::MyISAM; use warnings; use strict; -my %graphs = (); - -#--------------------------------------------------------------------- - -$graphs{myisam_indexes} = { - config => { - global_attrs => { - title => 'MyISAM Indexes', - vlabel => 'Requests per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', - min => '', +sub graphs { return { + myisam_indexes => { + config => { + global_attrs => { + title => 'MyISAM Indexes', + vlabel => 'Requests per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + min => '', + }, }, + data_sources => [ + {name => 'Key_read_requests', label => 'Key read requests', + info => 'The number of requests to read a key block from the cache.', + draw => 'AREA', + colour => '008800', + min => '0'}, + {name => 'Key_reads', label => 'Key reads', + info => 'The number of physical reads of a key block from disk.', + colour => '00FF00', + min => '0'}, + # plot as negative as long as munin does not support different colours for above and below the line + {name => 'Key_write_requests', label => 'Key write requests', + info => 'The number of requests to write a key block to the cache.', + cdef => 'Key_write_requests,-1,*', + draw => 'AREA', + colour => '880000'}, + {name => 'Key_writes', label => 'Key writes', + info => 'The number of physical writes of a key block to disk.', + cdef => 'Key_writes,-1,*', + colour => 'FF0000'}, + ], }, - data_sources => [ - {name => 'Key_read_requests', label => 'Key read requests', - info => 'The number of requests to read a key block from the cache.', - draw => 'AREA', - colour => '008800', - min => '0'}, - {name => 'Key_reads', label => 'Key reads', - info => 'The number of physical reads of a key block from disk.', - colour => '00FF00', - min => '0'}, - # plot as negative as long as munin does not support different colours for above and below the line - {name => 'Key_write_requests', label => 'Key write requests', - info => 'The number of requests to write a key block to the cache.', - cdef => 'Key_write_requests,-1,*', - draw => 'AREA', - colour => '880000'}, - {name => 'Key_writes', label => 'Key writes', - info => 'The number of physical writes of a key block to disk.', - cdef => 'Key_writes,-1,*', - colour => 'FF0000'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{myisam_key_cache} = { - config => { - global_attrs => { - title => 'MyISAM Key Cache', - vlabel => 'Bytes', - }, - data_source_attrs => { - type => 'GAUGE', + + #--------------------------------------------------------------------- + + myisam_key_cache => { + config => { + global_attrs => { + title => 'MyISAM Key Cache', + vlabel => 'Bytes', + }, + data_source_attrs => { + type => 'GAUGE', + }, }, + data_sources => [ + {name => 'key_buffer_size', label => 'Key buffer size', + draw => 'AREA', + colour => '99B898'}, + {name => 'Key_buf_unused', label => 'Key buffer bytes unused', + draw => 'AREA', + colour => '2A363B', + value => sub { + $_[0]->{Key_blocks_unused} * $_[0]->{key_cache_block_size} + }}, + {name => 'Key_buf_unflush', label => 'Key buffer bytes unflushed', + draw => 'AREA', + colour => 'FECEA8', + value => sub { + $_[0]->{Key_blocks_not_flushed} * $_[0]->{key_cache_block_size} + }}, + ], }, - data_sources => [ - {name => 'key_buffer_size', label => 'Key buffer size', - draw => 'AREA', - colour => '99B898'}, - {name => 'Key_buf_unused', label => 'Key buffer bytes unused', - draw => 'AREA', - colour => '2A363B', - value => sub { - $_[0]->{Key_blocks_unused} * $_[0]->{key_cache_block_size} - }}, - {name => 'Key_buf_unflush', label => 'Key buffer bytes unflushed', - draw => 'AREA', - colour => 'FECEA8', - value => sub { - $_[0]->{Key_blocks_not_flushed} * $_[0]->{key_cache_block_size} - }}, - ], -}; - -sub graphs { return \%graphs; } +}} 1; diff --git a/lib/Munin/MySQL/Graph/QueryCache.pm b/lib/Munin/MySQL/Graph/QueryCache.pm index 9592398..a7db9ef 100644 --- a/lib/Munin/MySQL/Graph/QueryCache.pm +++ b/lib/Munin/MySQL/Graph/QueryCache.pm @@ -3,56 +3,54 @@ package Munin::MySQL::Graph::QueryCache; use warnings; use strict; -my %graphs = (); - -$graphs{qcache} = { - config => { - global_attrs => { - title => 'Query Cache', - vlabel => 'Commands per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', +sub graphs { return { + qcache => { + config => { + global_attrs => { + title => 'Query Cache', + vlabel => 'Commands per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'Qcache_queries_in_cache', label => 'Queries in cache (K)', + info => 'The number of queries registered in the query cache.', + cdef => 'he_queries_in_cache,1024,/', + type => 'GAUGE'}, + {name => 'Qcache_hits', label => 'Cache hits', + info => 'The number of query cache hits.'}, + {name => 'Qcache_inserts', label => 'Inserts', + info => 'The number of queries added to the query cache.'}, + {name => 'Qcache_not_cached', label => 'Not cached', + info => 'The number of noncached queries (not cacheable, or not cached due to the query_cache_type setting).'}, + {name => 'Qcache_lowmem_prunes', label => 'Low-memory prunes', + info => 'The number of queries that were deleted from the query cache because of low memory.'}, + ], }, - data_sources => [ - {name => 'Qcache_queries_in_cache', label => 'Queries in cache (K)', - info => 'The number of queries registered in the query cache.', - cdef => 'he_queries_in_cache,1024,/', - type => 'GAUGE'}, - {name => 'Qcache_hits', label => 'Cache hits', - info => 'The number of query cache hits.'}, - {name => 'Qcache_inserts', label => 'Inserts', - info => 'The number of queries added to the query cache.'}, - {name => 'Qcache_not_cached', label => 'Not cached', - info => 'The number of noncached queries (not cacheable, or not cached due to the query_cache_type setting).'}, - {name => 'Qcache_lowmem_prunes', label => 'Low-memory prunes', - info => 'The number of queries that were deleted from the query cache because of low memory.'}, - ], -}; -#--------------------------------------------------------------------- + #--------------------------------------------------------------------- -$graphs{qcache_mem} = { - config => { - global_attrs => { - title => 'Query Cache Memory', - vlabel => 'Bytes', - args => "--base 1024 --lower-limit 0", - }, - data_source_attrs => { - draw => 'AREA', - type => 'GAUGE', + qcache_mem => { + config => { + global_attrs => { + title => 'Query Cache Memory', + vlabel => 'Bytes', + args => "--base 1024 --lower-limit 0", + }, + data_source_attrs => { + draw => 'AREA', + type => 'GAUGE', + }, }, + data_sources => [ + {name => 'query_cache_size', label => 'Cache size', + info => 'The amount of memory allocated for caching query results.'}, + {name => 'Qcache_free_memory', label => 'Free mem', + info => 'The amount of free memory for the query cache.'}, + ], }, - data_sources => [ - {name => 'query_cache_size', label => 'Cache size', - info => 'The amount of memory allocated for caching query results.'}, - {name => 'Qcache_free_memory', label => 'Free mem', - info => 'The amount of free memory for the query cache.'}, - ], -}; - -sub graphs { return \%graphs; } +}} 1; diff --git a/lib/Munin/MySQL/Graph/ReplicationSlave.pm b/lib/Munin/MySQL/Graph/ReplicationSlave.pm index 4c0dbfc..2a47ef8 100644 --- a/lib/Munin/MySQL/Graph/ReplicationSlave.pm +++ b/lib/Munin/MySQL/Graph/ReplicationSlave.pm @@ -3,39 +3,36 @@ package Munin::MySQL::Graph::ReplicationSlave; use warnings; use strict; -my %graphs = (); - -$graphs{replication} = { - config => { - global_attrs => { - title => 'Replication', - vlabel => 'Activity', - }, - data_source_attrs => { - draw => 'LINE1', +sub graphs { return { + replication => { + config => { + global_attrs => { + title => 'Replication', + vlabel => 'Activity', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'slave_running', label => 'Slave Running', + type => 'GAUGE', + draw => 'AREA', + colour=> '00AA00'}, + {name => 'slave_stopped', label => 'Slave Stopped', + type => 'GAUGE', + draw => 'AREA', + colour=> 'DD0000'}, + {name => 'Slave_retried_transactions', label => 'Retried Transactions', + info => 'The total number of times since startup that the replication slave SQL thread has retried transactions.'}, + {name => 'Slave_open_temp_tables', label => 'Open Temp Tables', + info => 'The number of temporary tables that the slave SQL thread currently has open.'}, + {name => 'seconds_behind_master', label => 'Secs Behind Master', + type => 'GAUGE', + info => 'http://dev.mysql.com/doc/refman/5.1/en/show-slave-status.html'}, + ], }, - data_sources => [ - {name => 'slave_running', label => 'Slave Running', - type => 'GAUGE', - draw => 'AREA', - colour=> '00AA00'}, - {name => 'slave_stopped', label => 'Slave Stopped', - type => 'GAUGE', - draw => 'AREA', - colour=> 'DD0000'}, - {name => 'Slave_retried_transactions', label => 'Retried Transactions', - info => 'The total number of times since startup that the replication slave SQL thread has retried transactions.'}, - {name => 'Slave_open_temp_tables', label => 'Open Temp Tables', - info => 'The number of temporary tables that the slave SQL thread currently has open.'}, - {name => 'seconds_behind_master', label => 'Secs Behind Master', - type => 'GAUGE', - info => 'http://dev.mysql.com/doc/refman/5.1/en/show-slave-status.html'}, - ], -}; - - -sub graphs { return \%graphs; } +}} 1; diff --git a/lib/Munin/MySQL/Graph/Standard.pm b/lib/Munin/MySQL/Graph/Standard.pm index 15e3fa2..c6c1037 100644 --- a/lib/Munin/MySQL/Graph/Standard.pm +++ b/lib/Munin/MySQL/Graph/Standard.pm @@ -5,433 +5,430 @@ use strict; use POSIX qw(floor); -my %graphs = (); - -#--------------------------------------------------------------------- - -$graphs{bin_relay_log} = { - config => { - global_attrs => { - title => 'Binary/Relay Logs', - vlabel => 'Log activity', - }, - data_source_attrs => { - draw => 'LINE1', +sub graphs { return { + + bin_relay_log => { + config => { + global_attrs => { + title => 'Binary/Relay Logs', + vlabel => 'Log activity', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'Binlog_cache_disk_use', label => 'Binlog Cache Disk Use', + info => '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.'}, + {name => 'Binlog_cache_use', label => 'Binlog Cache Use', + info => 'The number of transactions that used the temporary binary log cache.'}, + {name => 'ma_binlog_size', label => 'Binary Log Space (GB)', + info => 'The total combined size of all existing binary logs in GB', + type => 'GAUGE', + cdef => 'ma_binlog_size,1024,/,1024,/,1024,/'}, + {name => 'relay_log_space', label => 'Relay Log Space (GB)', + info => 'The total combined size of all existing relay logs in GB.', + type => 'GAUGE', + cdef => 'relay_log_space,1024,/,1024,/,1024,/'}, + ], }, - data_sources => [ - {name => 'Binlog_cache_disk_use', label => 'Binlog Cache Disk Use', - info => '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.'}, - {name => 'Binlog_cache_use', label => 'Binlog Cache Use', - info => 'The number of transactions that used the temporary binary log cache.'}, - {name => 'ma_binlog_size', label => 'Binary Log Space (GB)', - info => 'The total combined size of all existing binary logs in GB', - type => 'GAUGE', - cdef => 'ma_binlog_size,1024,/,1024,/,1024,/'}, - {name => 'relay_log_space', label => 'Relay Log Space (GB)', - info => 'The total combined size of all existing relay logs in GB.', - type => 'GAUGE', - cdef => 'relay_log_space,1024,/,1024,/,1024,/'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{commands} = { - config => { - global_attrs => { - title => 'Command Counters', - vlabel => 'Commands per ${graph_period}', - total => 'Questions', + + #--------------------------------------------------------------------- + + commands => { + config => { + global_attrs => { + title => 'Command Counters', + vlabel => 'Commands per ${graph_period}', + total => 'Questions', + }, + data_source_attrs => {}, }, - data_source_attrs => {}, + data_sources => [ + {name => 'Com_replace_select', label => 'Replace select', colour=>'00B99B'}, + {name => 'Com_update_multi', label => 'Update multi', colour=>'D8ACE0'}, + {name => 'Com_insert_select', label => 'Insert select', colour=>'AAABA1'}, + {name => 'Com_delete_multi', label => 'Delete multi', colour=>'942D0C'}, + {name => 'Com_load', label => 'Load Data', colour=>'55009D'}, + {name => 'Com_delete', label => 'Delete', colour=>'FF7D00'}, + {name => 'Com_replace', label => 'Replace', colour=>'2175D9'}, + {name => 'Com_update', label => 'Update', colour=>'00CF00'}, + {name => 'Com_insert', label => 'Insert', colour=>'FFF200'}, + {name => 'Com_select', label => 'Select', colour=>'FF0000'}, + ], }, - data_sources => [ - {name => 'Com_replace_select', label => 'Replace select', colour=>'00B99B'}, - {name => 'Com_update_multi', label => 'Update multi', colour=>'D8ACE0'}, - {name => 'Com_insert_select', label => 'Insert select', colour=>'AAABA1'}, - {name => 'Com_delete_multi', label => 'Delete multi', colour=>'942D0C'}, - {name => 'Com_load', label => 'Load Data', colour=>'55009D'}, - {name => 'Com_delete', label => 'Delete', colour=>'FF7D00'}, - {name => 'Com_replace', label => 'Replace', colour=>'2175D9'}, - {name => 'Com_update', label => 'Update', colour=>'00CF00'}, - {name => 'Com_insert', label => 'Insert', colour=>'FFF200'}, - {name => 'Com_select', label => 'Select', colour=>'FF0000'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{connections} = { - config => { - global_attrs => { - title => 'Connections', - vlabel => 'Connections per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + connections => { + config => { + global_attrs => { + title => 'Connections', + vlabel => 'Connections per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'max_connections', label => 'Max connections', + type => 'GAUGE', + draw => 'AREA', + colour => 'cdcfc4', + info => 'The number of simultaneous client connections allowed.'}, + {name => 'Max_used_connections', label => 'Max used', + type => 'GAUGE', + draw => 'AREA', + colour => 'ffd660', + info => 'The maximum number of connections that have been in use simultaneously since the server started.'}, + {name => 'Aborted_clients', label => 'Aborted clients', + info => 'The number of connections that were aborted because the client died without closing the connection properly.'}, + {name => 'Aborted_connects', label => 'Aborted connects', + info => 'The number of failed attempts to connect to the MySQL server.'}, + {name => 'Threads_connected', label => 'Threads connected', + type => 'GAUGE', + info => 'The number of currently open connections.'}, + {name => 'Connections', label => 'New connections', + info => 'The number of connection attempts (successful or not) to the MySQL server.'}, + ], }, - data_sources => [ - {name => 'max_connections', label => 'Max connections', - type => 'GAUGE', + + #--------------------------------------------------------------------- + + files_tables => { + config => { + global_attrs => { + title => 'Files and tables', + vlabel => 'Tables', + }, + data_source_attrs => { + type => 'GAUGE', + draw => 'LINE1', + }, + }, + data_sources => [ + {name => 'table_open_cache', label => 'Table cache', draw => 'AREA', colour => 'cdcfc4', - info => 'The number of simultaneous client connections allowed.'}, - {name => 'Max_used_connections', label => 'Max used', - type => 'GAUGE', - draw => 'AREA', - colour => 'ffd660', - info => 'The maximum number of connections that have been in use simultaneously since the server started.'}, - {name => 'Aborted_clients', label => 'Aborted clients', - info => 'The number of connections that were aborted because the client died without closing the connection properly.'}, - {name => 'Aborted_connects', label => 'Aborted connects', - info => 'The number of failed attempts to connect to the MySQL server.'}, - {name => 'Threads_connected', label => 'Threads connected', - type => 'GAUGE', - info => 'The number of currently open connections.'}, - {name => 'Connections', label => 'New connections', - info => 'The number of connection attempts (successful or not) to the MySQL server.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{files_tables} = { - config => { - global_attrs => { - title => 'Files and tables', - vlabel => 'Tables', - }, - data_source_attrs => { - type => 'GAUGE', - draw => 'LINE1', - }, + info => 'The number of open tables for all threads.'}, + {name => 'Open_files', label => 'Open files', + info => 'The number of files that are open.'}, + {name => 'Open_tables', label => 'Open tables', + info => 'The number of tables that are open.'}, + {name => 'Opened_tables', label => 'Opened tables', + type => 'DERIVE', + info => 'The number of tables that have been opened.'}, + ], }, - data_sources => [ - {name => 'table_open_cache', label => 'Table cache', - draw => 'AREA', - colour => 'cdcfc4', - info => 'The number of open tables for all threads.'}, - {name => 'Open_files', label => 'Open files', - info => 'The number of files that are open.'}, - {name => 'Open_tables', label => 'Open tables', - info => 'The number of tables that are open.'}, - {name => 'Opened_tables', label => 'Opened tables', - type => 'DERIVE', - info => 'The number of tables that have been opened.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{handlers} = { - config => { - global_attrs => { - title => 'Handlers', - }, - data_source_attrs => { - draw => 'AREASTACK', + + #--------------------------------------------------------------------- + + handlers => { + config => { + global_attrs => { + title => 'Handlers', + }, + data_source_attrs => { + draw => 'AREASTACK', + }, }, + data_sources => [ + {name => 'Handler_write', label => 'Handler write', + colour => '4D4A47', + info => 'The number of requests to insert a row in a table.'}, + {name => 'Handler_update', label => 'Handler update', + colour => 'C79F71', + info => 'The number of requests to update a row in a table.'}, + {name => 'Handler_delete', label => 'Handler delete', + colour => 'BDB8B3', + info => 'The number of requests to delete a row in a table.'}, + {name => 'Handler_read_first', label => 'Handler Read First', + colour => '8C286E', + info => 'The number of times the first entry was read from an index. If this is high, it suggests that the server is doing a lot of full index scans.'}, + {name => 'Handler_read_key', label => 'Handler Read Key', + colour => 'BAB27F', + info => 'The number of requests to read a row based on a key. If this is high, it is a good indication that your queries and tables are properly indexed.'}, + {name => 'Handler_read_next', label => 'Handler Read Next', + colour => 'C02942', + info => 'The number of requests to read the next row in key order. This is incremented if you are querying an index column with a range constraint or if you are doing an index scan.'}, + {name => 'Handler_read_prev', label => 'Handler Read Prev', + colour => 'FA6900', + info => 'The number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.'}, + {name => 'Handler_read_rnd', label => 'Handler Read Random', + colour => '5A3D31', + info => 'The number of requests to read a row based on a fixed position. This is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan whole tables or you have joins that don\'t use keys properly.'}, + {name => 'Handler_read_rnd_next',label => 'Handler Read Random Next', + colour => '69D2E7', + info => 'RThe number of requests to read the next row in the data file. This is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.'}, + + ], }, - data_sources => [ - {name => 'Handler_write', label => 'Handler write', - colour => '4D4A47', - info => 'The number of requests to insert a row in a table.'}, - {name => 'Handler_update', label => 'Handler update', - colour => 'C79F71', - info => 'The number of requests to update a row in a table.'}, - {name => 'Handler_delete', label => 'Handler delete', - colour => 'BDB8B3', - info => 'The number of requests to delete a row in a table.'}, - {name => 'Handler_read_first', label => 'Handler Read First', - colour => '8C286E', - info => 'The number of times the first entry was read from an index. If this is high, it suggests that the server is doing a lot of full index scans.'}, - {name => 'Handler_read_key', label => 'Handler Read Key', - colour => 'BAB27F', - info => 'The number of requests to read a row based on a key. If this is high, it is a good indication that your queries and tables are properly indexed.'}, - {name => 'Handler_read_next', label => 'Handler Read Next', - colour => 'C02942', - info => 'The number of requests to read the next row in key order. This is incremented if you are querying an index column with a range constraint or if you are doing an index scan.'}, - {name => 'Handler_read_prev', label => 'Handler Read Prev', - colour => 'FA6900', - info => 'The number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.'}, - {name => 'Handler_read_rnd', label => 'Handler Read Random', - colour => '5A3D31', - info => 'The number of requests to read a row based on a fixed position. This is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan whole tables or you have joins that don\'t use keys properly.'}, - {name => 'Handler_read_rnd_next',label => 'Handler Read Random Next', - colour => '69D2E7', - info => 'RThe number of requests to read the next row in the data file. This is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.'}, - - ], -}; - - -#--------------------------------------------------------------------- - -$graphs{network_traffic} = { - config => { - global_attrs => { - title => 'Network Traffic', - args => "--base 1024", - vlabel => 'Bytes received (-) / sent (+) per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + + #--------------------------------------------------------------------- + + network_traffic => { + config => { + global_attrs => { + title => 'Network Traffic', + args => "--base 1024", + vlabel => 'Bytes received (-) / sent (+) per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'Bytes_received', label => 'Bytes transfered', + graph => 'no', + info => 'The number of bytes received from all clients.'}, + {name => 'Bytes_sent', label => 'Bytes transfered', + negative => 'Bytes_received', + info => 'The number of bytes sent to all clients.'}, + ], }, - data_sources => [ - {name => 'Bytes_received', label => 'Bytes transfered', - graph => 'no', - info => 'The number of bytes received from all clients.'}, - {name => 'Bytes_sent', label => 'Bytes transfered', - negative => 'Bytes_received', - info => 'The number of bytes sent to all clients.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{processlist} = { - config => { - global_attrs => { - title => 'Processlist states', - vlabel => 'State count per ${graph_period}', - }, - data_source_attrs => { + + #--------------------------------------------------------------------- + + processlist => { + config => { + global_attrs => { + title => 'Processlist states', + vlabel => 'State count per ${graph_period}', + }, + data_source_attrs => { + }, }, + data_sources => [ + {name => 'State_closing_tables', label => 'Closing tables', + info => 'The thread is flushing the changed table data to disk and closing the used tables.', + colour=> 'DE0056'}, + {name => 'State_copying_to_tmp_table', label => 'Copying to tmp table', + info => 'The thread is processing an ALTER TABLE statement. This state occurs after the table with the new structure has been created but before rows are copied into it.', + colour=> '784890'}, + {name => 'State_end', label => 'End', + info => 'This occurs at the end but before the cleanup of ALTER TABLE, CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements.', + colour=> 'D1642E'}, + {name => 'State_freeing_items', label => 'Freeing items', + info => 'The thread has executed a command. This state is usually followed by cleaning up.', + colour=> '487860'}, + {name => 'State_init', label => 'Init', + info => 'This occurs before the initialization of ALTER TABLE, DELETE, INSERT, SELECT, or UPDATE statements.', + colour=> '907890'}, + {name => 'State_locked', label => 'Locked', + info => 'The query is locked by another query.', + colour=> 'DE0056'}, + {name => 'State_login', label => 'Login', + info => 'The initial state for a connection thread until the client has been authenticated successfully.', + colour=> '1693A7'}, + {name => 'State_preparing', label => 'Preparing', + info => 'This state occurs during query optimization.', + colour=> '783030'}, + {name => 'State_reading_from_net', label => 'Reading from net', + info => 'The server is reading a packet from the network.', + colour=> 'FF7F00'}, + {name => 'State_sending_data', label => 'Sending data', + info => 'The thread is processing rows for a SELECT statement and also is sending data to the client.', + colour=> '54382A'}, + {name => 'State_sorting_result', label => 'Sorting result', + info => 'For a SELECT statement, this is similar to Creating sort index, but for nontemporary tables.', + colour=> 'B83A04'}, + {name => 'State_statistics', label => 'Statistics', + info => 'The server is calculating statistics to develop a query execution plan. If a thread is in this state for a long time, the server is probably disk-bound performing other work.', + colour=> '6E3803'}, + {name => 'State_updating', label => 'Updating', + info => 'The thread is searching for rows to update and is updating them.', + colour=> 'B56414'}, + {name => 'State_writing_to_net', label => 'Writing to net', + info => 'The server is writing a packet to the network.', + colour=> '6E645A'}, + {name => 'State_none', label => 'None', + info => '', + colour=> '521808'}, + {name => 'State_other', label => 'Other', + info => '', + colour=> '194240'}, + ], }, - data_sources => [ - {name => 'State_closing_tables', label => 'Closing tables', - info => 'The thread is flushing the changed table data to disk and closing the used tables.', - colour=> 'DE0056'}, - {name => 'State_copying_to_tmp_table', label => 'Copying to tmp table', - info => 'The thread is processing an ALTER TABLE statement. This state occurs after the table with the new structure has been created but before rows are copied into it.', - colour=> '784890'}, - {name => 'State_end', label => 'End', - info => 'This occurs at the end but before the cleanup of ALTER TABLE, CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements.', - colour=> 'D1642E'}, - {name => 'State_freeing_items', label => 'Freeing items', - info => 'The thread has executed a command. This state is usually followed by cleaning up.', - colour=> '487860'}, - {name => 'State_init', label => 'Init', - info => 'This occurs before the initialization of ALTER TABLE, DELETE, INSERT, SELECT, or UPDATE statements.', - colour=> '907890'}, - {name => 'State_locked', label => 'Locked', - info => 'The query is locked by another query.', - colour=> 'DE0056'}, - {name => 'State_login', label => 'Login', - info => 'The initial state for a connection thread until the client has been authenticated successfully.', - colour=> '1693A7'}, - {name => 'State_preparing', label => 'Preparing', - info => 'This state occurs during query optimization.', - colour=> '783030'}, - {name => 'State_reading_from_net', label => 'Reading from net', - info => 'The server is reading a packet from the network.', - colour=> 'FF7F00'}, - {name => 'State_sending_data', label => 'Sending data', - info => 'The thread is processing rows for a SELECT statement and also is sending data to the client.', - colour=> '54382A'}, - {name => 'State_sorting_result', label => 'Sorting result', - info => 'For a SELECT statement, this is similar to Creating sort index, but for nontemporary tables.', - colour=> 'B83A04'}, - {name => 'State_statistics', label => 'Statistics', - info => 'The server is calculating statistics to develop a query execution plan. If a thread is in this state for a long time, the server is probably disk-bound performing other work.', - colour=> '6E3803'}, - {name => 'State_updating', label => 'Updating', - info => 'The thread is searching for rows to update and is updating them.', - colour=> 'B56414'}, - {name => 'State_writing_to_net', label => 'Writing to net', - info => 'The server is writing a packet to the network.', - colour=> '6E645A'}, - {name => 'State_none', label => 'None', - info => '', - colour=> '521808'}, - {name => 'State_other', label => 'Other', - info => '', - colour=> '194240'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{select_types} = { - config => { - global_attrs => { - title => 'Select types', - vlabel => 'Commands per ${graph_period}', - total => 'Total', + + #--------------------------------------------------------------------- + + select_types => { + config => { + global_attrs => { + title => 'Select types', + vlabel => 'Commands per ${graph_period}', + total => 'Total', + }, + data_source_attrs => {}, }, - data_source_attrs => {}, + data_sources => [ + {name => 'Select_full_join', label => 'Full join', + info => 'The number of joins that perform table scans because they do not use indexes.', + colour=> 'FF0000'}, + {name => 'Select_full_range_join', label => 'Full range', + info => 'The number of joins that used a range search on a reference table.', + colour=> 'FF7D00'}, + {name => 'Select_range', label => 'Range', + info => 'The number of joins that used ranges on the first table.', + colour=> 'FFF200'}, + {name => 'Select_range_check', label => 'Range check', + info => 'The number of joins without keys that check for key usage after each row.', + colour=> '7DFF7D'}, + {name => 'Select_scan', label => 'Scan', + info => 'The number of joins that did a full scan of the first table.', + colour=> '7D7DFF'}, + ], }, - data_sources => [ - {name => 'Select_full_join', label => 'Full join', - info => 'The number of joins that perform table scans because they do not use indexes.', - colour=> 'FF0000'}, - {name => 'Select_full_range_join', label => 'Full range', - info => 'The number of joins that used a range search on a reference table.', - colour=> 'FF7D00'}, - {name => 'Select_range', label => 'Range', - info => 'The number of joins that used ranges on the first table.', - colour=> 'FFF200'}, - {name => 'Select_range_check', label => 'Range check', - info => 'The number of joins without keys that check for key usage after each row.', - colour=> '7DFF7D'}, - {name => 'Select_scan', label => 'Scan', - info => 'The number of joins that did a full scan of the first table.', - colour=> '7D7DFF'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{slow} = { - config => { - global_attrs => { - title => 'Slow Queries', - vlabel => 'Slow queries per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + slow => { + config => { + global_attrs => { + title => 'Slow Queries', + vlabel => 'Slow queries per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'Slow_queries', label => 'Slow queries', + info => 'The number of queries that have taken more than long_query_time seconds.'}, + ], }, - data_sources => [ - {name => 'Slow_queries', label => 'Slow queries', - info => 'The number of queries that have taken more than long_query_time seconds.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{sorts} = { - config => { - global_attrs => { - title => 'Sorts', - vlabel => 'Sorts / ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + sorts => { + config => { + global_attrs => { + title => 'Sorts', + vlabel => 'Sorts / ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'Sort_rows', label => 'Rows sorted (K)', + info => 'The number of sorted rows.', + cdef => 'Sort_rows,1024,/', + draw => 'AREA', + colour=> 'FF7D00'}, + {name => 'Sort_range', label => 'Range', + info => 'The number of sorts that were done using ranges.', + colour=> '007D00'}, + {name => 'Sort_merge_passes', label => 'Merge passes', + info => 'The number of merge passes that the sort algorithm has had to do.', + colour=> '7D0000'}, + {name => 'Sort_scan', label => 'Scan', + info => 'The number of sorts that were done by scanning the table.', + colour=> '0000D0'}, + ], }, - data_sources => [ - {name => 'Sort_rows', label => 'Rows sorted (K)', - info => 'The number of sorted rows.', - cdef => 'Sort_rows,1024,/', - draw => 'AREA', - colour=> 'FF7D00'}, - {name => 'Sort_range', label => 'Range', - info => 'The number of sorts that were done using ranges.', - colour=> '007D00'}, - {name => 'Sort_merge_passes', label => 'Merge passes', - info => 'The number of merge passes that the sort algorithm has had to do.', - colour=> '7D0000'}, - {name => 'Sort_scan', label => 'Scan', - info => 'The number of sorts that were done by scanning the table.', - colour=> '0000D0'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{table_locks} = { - config => { - global_attrs => { - title => 'Table locks', - vlabel => 'locks per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + table_locks => { + config => { + global_attrs => { + title => 'Table locks', + vlabel => 'locks per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'Table_locks_immediate', label => 'Table locks immed', + info => 'The number of times that a request for a table lock could be granted immediately.'}, + {name => 'Table_locks_waited', label => 'Table locks waited', + info => 'The number of times that a request for a table lock could not be granted immediately and a wait was needed.'}, + ], }, - data_sources => [ - {name => 'Table_locks_immediate', label => 'Table locks immed', - info => 'The number of times that a request for a table lock could be granted immediately.'}, - {name => 'Table_locks_waited', label => 'Table locks waited', - info => 'The number of times that a request for a table lock could not be granted immediately and a wait was needed.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{threads} = { - config => { - global_attrs => { - title => 'Threads', - vlabel => 'Threads created', - }, - data_source_attrs => { + + #--------------------------------------------------------------------- + + threads => { + config => { + global_attrs => { + title => 'Threads', + vlabel => 'Threads created', + }, + data_source_attrs => { + }, }, + data_sources => [ + {name => 'thread_cache_size', label => 'Thread cache size', + draw => 'AREA', + type => 'GAUGE', + info => 'How many threads the server should cache for reuse', + colour=> '99ff99'}, + {name => 'Threads_created', label => 'Threads created', + draw => 'LINE1', + type => 'GAUGE', + info => 'The number of threads created to handle connections', + colour=> '0000ff'}, + {name => 'Threads_connected', label => 'Threads connected', + draw => 'LINE1', + type => 'GAUGE', + info => 'The number of currently open connections', + colour=> '7777ff'}, + {name => 'Threads_running', label => 'Threads running', + draw => 'LINE1', + type => 'GAUGE', + info => 'The number of threads that are not sleeping', + colour=> '7d0000'}, + ], }, - data_sources => [ - {name => 'thread_cache_size', label => 'Thread cache size', - draw => 'AREA', - type => 'GAUGE', - info => 'How many threads the server should cache for reuse', - colour=> '99ff99'}, - {name => 'Threads_created', label => 'Threads created', - draw => 'LINE1', - type => 'GAUGE', - info => 'The number of threads created to handle connections', - colour=> '0000ff'}, - {name => 'Threads_connected', label => 'Threads connected', - draw => 'LINE1', - type => 'GAUGE', - info => 'The number of currently open connections', - colour=> '7777ff'}, - {name => 'Threads_running', label => 'Threads running', - draw => 'LINE1', - type => 'GAUGE', - info => 'The number of threads that are not sleeping', - colour=> '7d0000'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{tmp_tables} = { - config => { - global_attrs => { - title => 'Temporary objects', - vlabel => 'Objects per ${graph_period}', - }, - data_source_attrs => { - draw => 'LINE1', + + #--------------------------------------------------------------------- + + tmp_tables => { + config => { + global_attrs => { + title => 'Temporary objects', + vlabel => 'Objects per ${graph_period}', + }, + data_source_attrs => { + draw => 'LINE1', + }, }, + data_sources => [ + {name => 'Created_tmp_disk_tables', label => 'Temp disk tables', + info => 'The number of internal on-disk temporary tables created by the server while executing statements.'}, + {name => 'Created_tmp_tables', label => 'Temp tables', + info => 'The number of internal temporary tables created by the server while executing statements.'}, + {name => 'Created_tmp_files', label => 'Temp files', + info => 'How many temporary files mysqld has created.'}, + ], }, - data_sources => [ - {name => 'Created_tmp_disk_tables', label => 'Temp disk tables', - info => 'The number of internal on-disk temporary tables created by the server while executing statements.'}, - {name => 'Created_tmp_tables', label => 'Temp tables', - info => 'The number of internal temporary tables created by the server while executing statements.'}, - {name => 'Created_tmp_files', label => 'Temp files', - info => 'How many temporary files mysqld has created.'}, - ], -}; - -#--------------------------------------------------------------------- - -$graphs{uptime} = { - config => { - global_attrs => { - title => 'Uptime', - vlabel => 'Uptime in days', - }, - data_source_attrs => { - draw => 'AREA', - type => 'GAUGE', + + #--------------------------------------------------------------------- + + uptime => { + config => { + global_attrs => { + title => 'Uptime', + vlabel => 'Uptime in days', + }, + data_source_attrs => { + draw => 'AREA', + type => 'GAUGE', + }, }, + data_sources => [ + {name => 'Uptime_days', label => 'Uptime', + info => 'Server uptime in days.', + value => sub { + floor($_[0]->{Uptime} / 86400); # seconds in a day + }, + }, + ], }, - data_sources => [ - {name => 'Uptime_days', label => 'Uptime', - info => 'Server uptime in days.', - value => sub { - floor($_[0]->{Uptime} / 86400); # seconds in a day - }, - }, - ], -}; - -sub graphs { return \%graphs; } +}} 1;