[Pkg-mysql-commits] r980 - in branches/sid-5.1/debian: . additions/innotop
Norbert Tretkowski
nobse at alioth.debian.org
Fri Nov 9 19:12:55 UTC 2007
tags 421026 pending
thanks
Author: nobse
Date: 2007-11-09 19:12:55 +0000 (Fri, 09 Nov 2007)
New Revision: 980
Modified:
branches/sid-5.1/debian/additions/innotop/InnoDBParser.pm
branches/sid-5.1/debian/additions/innotop/changelog.innotop
branches/sid-5.1/debian/additions/innotop/innotop
branches/sid-5.1/debian/additions/innotop/innotop.1
branches/sid-5.1/debian/changelog
branches/sid-5.1/debian/control
Log:
Merge with 5.0 r978.
Modified: branches/sid-5.1/debian/additions/innotop/InnoDBParser.pm
===================================================================
--- branches/sid-5.1/debian/additions/innotop/InnoDBParser.pm 2007-11-09 19:08:33 UTC (rev 979)
+++ branches/sid-5.1/debian/additions/innotop/InnoDBParser.pm 2007-11-09 19:12:55 UTC (rev 980)
@@ -19,7 +19,7 @@
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
-our $VERSION = '1.4.3';
+our $VERSION = '1.6.0';
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
@@ -218,7 +218,7 @@
reads_pending pages_total buf_pool_hits writes_pending_single_page
page_writes_sec pages_read pages_written page_reads_sec
writes_pending_flush_list buf_pool_size add_pool_alloc
- pages_created buf_free complete )),
+ dict_mem_alloc pages_created buf_free complete )),
(map { 'IB_tx_' . $_ => $innodb_status->{'sections'}->{'tx'}->{$_} }
qw( num_lock_structs history_list_len purge_done_for transactions
purge_undo_for is_truncated trx_id_counter complete )),
@@ -548,12 +548,9 @@
if ( $what eq 'TRANSACTION' ) {
$txn->{'tx'} = parse_tx_text( $body, $complete, $debug, $full );
}
- elsif ( $what eq 'HOLDS THE LOCK(S)' ) {
- $txn->{'holds'} = parse_innodb_record_locks( $body, $complete, $debug, $full );
+ else {
+ push @{$txn->{'locks'}}, parse_innodb_record_locks( $body, $complete, $debug, $full );
}
- elsif ( $what eq 'WAITING FOR THIS LOCK TO BE GRANTED' ) {
- $txn->{'waits_for'} = parse_innodb_record_locks( $body, $complete, $debug, $full );
- }
}
@{ $dl }{ qw(rolled_back) }
@@ -568,36 +565,28 @@
sub parse_innodb_record_locks {
my ( $text, $complete, $debug, $full ) = @_;
- my $result = {
- locks => [],
- fulltext => $text,
- };
+ my @result;
- @{$result}{ qw(lock_type space_id page_no n_bits index db table txn_id lock_mode) }
- = $text
- =~ m{^(RECORD|TABLE) LOCKS? (?:space id $d page no $d n bits $d index `?$n`? of )?table `$n/$n` trx id $t lock.mode (\S+)}m;
- ( $result->{'special'} )
- = $text =~ m/^(?:RECORD|TABLE) .*? locks (rec but not gap|gap before rec)/m;
- $result->{'insert_intention'}
- = $text =~ m/^(?:RECORD|TABLE) .*? insert intention/m ? 1 : 0;
- $result->{'waiting'}
- = $text =~ m/^(?:RECORD|TABLE) .*? waiting/m ? 1 : 0;
+ foreach my $lock ( $text =~ m/(^(?:RECORD|TABLE) LOCKS?.*$)/gm ) {
+ my $hash = {};
+ @{$hash}{ qw(lock_type space_id page_no n_bits index db table txn_id lock_mode) }
+ = $lock
+ =~ m{^(RECORD|TABLE) LOCKS? (?:space id $d page no $d n bits $d index `?$n`? of )?table `$n(?:/|`\.`)$n` trx id $t lock.mode (\S+)}m;
+ ( $hash->{'special'} )
+ = $lock =~ m/^(?:RECORD|TABLE) .*? locks (rec but not gap|gap before rec)/m;
+ $hash->{'insert_intention'}
+ = $lock =~ m/^(?:RECORD|TABLE) .*? insert intention/m ? 1 : 0;
+ $hash->{'waiting'}
+ = $lock =~ m/^(?:RECORD|TABLE) .*? waiting/m ? 1 : 0;
- my @locks = $text =~ m/(^Record lock.*\n.*?$)/gm;
- if ( $full ) {
- foreach my $lock ( @locks ) {
- push @{$result->{'locks'}}, parse_innodb_record_dump( $lock, $complete, $debug );
- }
+ # Some things may not be in the text, so make sure they are not
+ # undef.
+ map { $hash->{$_} ||= 0 } qw(n_bits page_no space_id);
+ map { $hash->{$_} ||= "" } qw(index special);
+ push @result, $hash;
}
- $result->{'num_locks'} = scalar(@locks);
- # Some things may not be in the text, so make sure they are not
- # undef.
- map { $result->{$_} ||= 0 } qw(n_bits page_no space_id);
- map { $result->{$_} ||= "" } qw(index special);
-
- delete $result->{'fulltext'} unless $debug;
- return $result;
+ return @result;
}
sub parse_tx_text {
@@ -651,17 +640,17 @@
}
}
- my ( $lock_wait_status, $lock_structs, $heap_size, $undo_log_entries )
+ my ( $lock_wait_status, $lock_structs, $heap_size, $row_locks, $undo_log_entries )
= $txn
- =~ m/^(?:(\D*) )?$d lock struct\(s\), heap size $d(?:, undo log entries $d)?$/m;
+ =~ m/^(?:(\D*) )?$d lock struct\(s\), heap size $d(?:, $d row lock\(s\))?(?:, undo log entries $d)?$/m;
my ( $lock_wait_time )
= $txn
=~ m/^------- TRX HAS BEEN WAITING $d SEC/m;
my $locks;
- # If the transaction is waiting for locks, grab the locks.
- if ( defined $lock_wait_time ) {
- $locks = parse_innodb_record_locks($txn, $complete, $debug, $full);
+ # If the transaction has locks, grab the locks.
+ if ( $txn =~ m/^TABLE LOCK|RECORD LOCKS/ ) {
+ $locks = [parse_innodb_record_locks($txn, $complete, $debug, $full)];
}
my ( $tables_in_use, $tables_locked )
@@ -675,17 +664,25 @@
# under some circumstances. Some versions include 300, some 600.
my ( $query_text )
= $txn
- =~ m/\nMySQL thread id .*\n((?s).*)/;
+ =~ m{
+ ^MySQL\sthread\sid\s[^\n]+\n # This comes before the query text
+ (.*?) # The query text
+ (?= # Followed by any of...
+ ^Trx\sread\sview
+ |^-------\sTRX\sHAS\sBEEN\sWAITING
+ |^TABLE\sLOCK
+ |^RECORD\sLOCKS\sspace\sid
+ |^(?:---)?TRANSACTION
+ |^\*\*\*\s\(\d\)
+ |\Z
+ )
+ }xms;
if ( $query_text ) {
- # I can't figure out how to make the above regex do this right, so I
- # am just deleting out text I don't want.
- $query_text =~ s/\n?Trx read view.*$//s;
- $query_text =~ s/\n?------- TRX HAS BEEN WAITING.*$//s;
+ $query_text =~ s/\s+$//;
}
else {
$query_text = '';
}
- $query_text =~ s/\s+$//;
my %stuff = (
active_secs => $active_secs,
@@ -702,6 +699,7 @@
query_id => $query_id,
query_status => $query_status,
query_text => $query_text,
+ row_locks => $row_locks,
tables_in_use => $tables_in_use,
tables_locked => $tables_locked,
thread_decl_inside => $thread_decl_inside,
@@ -714,13 +712,13 @@
user => $user,
);
$stuff{'fulltext'} = $txn if $debug;
- $stuff{'wait_locks'} = $locks if $locks;
+ $stuff{'locks'} = $locks if $locks;
# Some things may not be in the txn text, so make sure they are not
# undef.
map { $stuff{$_} ||= 0 } qw(active_secs heap_size lock_structs
tables_in_use undo_log_entries tables_locked has_read_view
- thread_decl_inside lock_wait_time proc_no);
+ thread_decl_inside lock_wait_time proc_no row_locks);
map { $stuff{$_} ||= "" } qw(thread_status txn_doesnt_see_ge
txn_sees_lt query_status ip query_text lock_wait_status user);
$stuff{'hostname'} ||= $stuff{'ip'};
@@ -905,6 +903,7 @@
# Grab the info
@{$section}{ 'total_mem_alloc', 'add_pool_alloc' }
= $fulltext =~ m/^Total memory allocated $d; in additional pool allocated $d$/m;
+ @{$section}{'dict_mem_alloc'} = $fulltext =~ m/Dictionary memory allocated $d/;
@{$section}{'awe_mem_alloc'} = $fulltext =~ m/$d MB of AWE memory/;
@{$section}{'buf_pool_size'} = $fulltext =~ m/^Buffer pool size\s*$d$/m;
@{$section}{'buf_free'} = $fulltext =~ m/^Free buffers\s*$d$/m;
@@ -929,7 +928,8 @@
= $fulltext =~ m/^Pending writes: LRU $d, flush list $d, single page $d$/m;
map { $section->{$_} ||= 0 }
- qw(writes_pending_lru writes_pending_flush_list writes_pending_single_page awe_mem_alloc);
+ qw(writes_pending_lru writes_pending_flush_list writes_pending_single_page
+ awe_mem_alloc dict_mem_alloc);
@{$section}{'writes_pending'} = List::Util::sum(
@{$section}{ qw(writes_pending_lru writes_pending_flush_list writes_pending_single_page) });
Modified: branches/sid-5.1/debian/additions/innotop/changelog.innotop
===================================================================
--- branches/sid-5.1/debian/additions/innotop/changelog.innotop 2007-11-09 19:08:33 UTC (rev 979)
+++ branches/sid-5.1/debian/additions/innotop/changelog.innotop 2007-11-09 19:12:55 UTC (rev 980)
@@ -1,5 +1,30 @@
Changelog for innotop and InnoDBParser:
+2007-11-09: version 1.6.0
+
+ * S mode crashed on non-numeric values.
+ * New user-defined columns crashed upon restart.
+ * Added --color option to control terminal coloring.
+
+2007-09-18: version 1.5.2
+
+ * Added the ability to monitor InnoDB status from a file.
+ * Changed W mode to L mode; it monitors all locks, not just lock waits.
+
+2007-09-16: version 1.5.1
+
+ * Added C (Command Summary) mode.
+ * Fixed a bug in the 'avg' aggregate function.
+
+2007-09-10: version 1.5.0
+
+ Changes:
+ * Added plugin functionality.
+ * Added group-by functionality.
+ * Moved the configuration file to a directory.
+ * Enhanced filtering and sorting on pivoted tables.
+ * Many small bug fixes.
+
2007-07-16: version 1.4.3
Changes:
Modified: branches/sid-5.1/debian/additions/innotop/innotop
===================================================================
--- branches/sid-5.1/debian/additions/innotop/innotop 2007-11-09 19:08:33 UTC (rev 979)
+++ branches/sid-5.1/debian/additions/innotop/innotop 2007-11-09 19:12:55 UTC (rev 980)
@@ -1,10 +1,6 @@
#!/usr/bin/perl
-# vim: foldmethod=marker:tw=160:nowrap:expandtab:tabstop=3:shiftwidth=3:softtabstop=3
-# vim users, set modeline to enable auto-folding and compatibility with my preferred
-# formatting. I use a very wide textwidth because there's tons of configuration
-# data that's much easier to manage when it's laid out in a (wide) tabular
-# format. I try to keep most real code to a textwidth of 80 or so.
+# vim: tw=160:nowrap:expandtab:tabstop=3:shiftwidth=3:softtabstop=3
use strict;
use warnings FATAL => 'all';
@@ -13,8 +9,9 @@
use Data::Dumper;
use DBI;
use English qw(-no_match_vars);
+use File::Basename qw(dirname);
use Getopt::Long;
-use List::Util qw(max min maxstr);
+use List::Util qw(max min maxstr sum);
use InnoDBParser;
use POSIX qw(ceil);
use Time::HiRes qw(time sleep);
@@ -22,9 +19,9 @@
# Version, license and warranty information. {{{1
# ###########################################################################
-our $VERSION = '1.4.3';
-our $SVN_REV = sprintf("%d", q$Revision: 291 $ =~ m/(\d+)/g);
-our $SVN_URL = sprintf("%s", q$URL: https://innotop.svn.sourceforge.net/svnroot/innotop/branches/1.4/innotop $ =~ m/URL: (\S+)/g);
+our $VERSION = '1.6.0';
+our $SVN_REV = sprintf("%d", q$Revision: 383 $ =~ m/(\d+)/g);
+our $SVN_URL = sprintf("%s", q$URL: https://innotop.svn.sourceforge.net/svnroot/innotop/trunk/innotop $ =~ m$svnroot/innotop/(\S+)$g);
my $innotop_license = <<"LICENSE";
@@ -62,21 +59,22 @@
# This defines expected properties and defaults for the column definitions that
# eventually end up in tbl_meta.
my %col_props = (
- hdr => '',
- just => '-',
- dec => 0, # Whether to align the column on the decimal point
- num => 0,
- label => '',
- user => 0,
- src => '',
- tbl => '', # Helps when writing/reading custom columns in config files
- minw => 0,
- maxw => 0,
- trans => [],
+ hdr => '',
+ just => '-',
+ dec => 0, # Whether to align the column on the decimal point
+ num => 0,
+ label => '',
+ user => 0,
+ src => '',
+ tbl => '', # Helps when writing/reading custom columns in config files
+ minw => 0,
+ maxw => 0,
+ trans => [],
+ agg => 'first', # Aggregate function
+ aggonly => 0, # Whether to show only when tbl_meta->{aggregate} is true
);
-# I use my own caching because I need to explicitly know when I actually get a new
-# connection. It's just easier to code it myself.
+# Actual DBI connections to MySQL servers.
my %dbhs;
# Command-line parameters {{{2
@@ -84,6 +82,7 @@
my @opt_spec = (
{ s => 'help', d => 'Show this help message' },
+ { s => 'color|C!', d => 'Use terminal coloring (default)', c => 'color' },
{ s => 'config|c=s', d => 'Config file to read' },
{ s => 'nonint|n', d => 'Non-interactive, output tab-separated fields' },
{ s => 'count=i', d => 'Number of updates before exiting' },
@@ -119,7 +118,7 @@
}
if ( $opts{'help'} ) {
- print "Usage: innotop <options>\n\n";
+ print "Usage: innotop <options> <innodb-status-file>\n\n";
my $maxw = max(map { length($_->{l}) + ($_->{n} ? 4 : 0)} @opt_spec);
foreach my $spec ( sort { $a->{l} cmp $b->{l} } @opt_spec ) {
my $long = $spec->{n} ? "[no]$spec->{l}" : $spec->{l};
@@ -194,6 +193,7 @@
child_index => { hdr => 'Child Index', num => 0, label => 'The index in the child table' },
child_table => { hdr => 'Child Table', num => 0, label => 'The child table' },
cmd => { hdr => 'Cmd', num => 0, label => 'Type of command being executed', },
+ cnt => { hdr => 'Cnt', num => 0, label => 'Count', agg => 'count', aggonly => 1 },
connect_retry => { hdr => 'Connect Retry', num => 1, label => 'Slave connect-retry timeout' },
cxn => { hdr => 'CXN', num => 0, label => 'Connection from which the data came', },
db => { hdr => 'DB', num => 0, label => 'Current database', },
@@ -234,6 +234,9 @@
last_s_line => { hdr => 'S-Line', num => 1, label => 'Line where last read locked' },
last_x_file_name => { hdr => 'X-File', num => 0, label => 'Filename where last write locked' },
last_x_line => { hdr => 'X-Line', num => 1, label => 'Line where last write locked' },
+ last_pct => { hdr => 'Pct', num => 1, label => 'Last Percentage' },
+ last_total => { hdr => 'Last Total', num => 1, label => 'Last Total' },
+ last_value => { hdr => 'Last Incr', num => 1, label => 'Last Value' },
load => { hdr => 'Load', num => 1, label => 'Server load' },
lock_cfile_name => { hdr => 'Crtd File', num => 0, label => 'Filename where lock created' },
lock_cline => { hdr => 'Crtd Line', num => 1, label => 'Line where lock created' },
@@ -269,13 +272,13 @@
mutex_spin_rounds => { hdr => 'Rounds', num => 1, label => 'Mutex Spin Rounds' },
mutex_spin_waits => { hdr => 'Spins', num => 1, label => 'Mutex Spin Waits' },
mysql_thread_id => { hdr => 'ID', num => 1, label => 'MySQL connection (thread) ID', },
+ name => { hdr => 'Name', num => 0, label => 'Variable Name' },
n_bits => { hdr => '# Bits', num => 1, label => 'Number of bits' },
non_hash_searches_s => { hdr => 'Non-Hash/Sec', num => 1, label => 'Non-hash searches/sec' },
num_deletes => { hdr => 'Del', num => 1, label => 'Number of deletes' },
num_deletes_sec => { hdr => 'Del/Sec', num => 1, label => 'Number of deletes' },
num_inserts => { hdr => 'Ins', num => 1, label => 'Number of inserts' },
num_inserts_sec => { hdr => 'Ins/Sec', num => 1, label => 'Number of inserts' },
- num_locks => { hdr => 'Row Locks', num => 1, label => 'Number of locks' },
num_readers => { hdr => 'Readers', num => 1, label => 'Number of readers' },
num_reads => { hdr => 'Read', num => 1, label => 'Number of reads' },
num_reads_sec => { hdr => 'Read/Sec', num => 1, label => 'Number of reads' },
@@ -313,6 +316,7 @@
parent_table => { hdr => 'Parent Table', num => 0, label => 'The parent table' },
part_id => { hdr => 'Part ID', num => 1, label => 'Sub-part ID of the query' },
partitions => { hdr => 'Partitions', num => 0, label => 'Query partitions used' },
+ pct => { hdr => 'Pct', num => 1, label => 'Percentage' },
pending_chkp_writes => { hdr => 'Chkpt Writes', num => 1, label => 'Pending log checkpoint writes' },
pending_log_writes => { hdr => 'Log Writes', num => 1, label => 'Pending log writes' },
port => { hdr => 'Port', num => 1, label => 'Client port number', },
@@ -371,6 +375,7 @@
time => { hdr => 'Time', num => 1, label => 'Time since the last event', },
time_behind_master => { hdr => 'TimeLag', num => 1, label => 'Time slave lags master' },
timestring => { hdr => 'Timestring', num => 0, label => 'Time the event occurred' },
+ total => { hdr => 'Total', num => 1, label => 'Total' },
total_mem_alloc => { hdr => 'Memory', num => 1, label => 'Total memory allocated' },
truncates => { hdr => 'Trunc', num => 0, label => 'Whether the deadlock is truncating InnoDB status' },
txn_doesnt_see_ge => { hdr => "Txn Won't See", num => 0, label => 'Where txn read view is limited' },
@@ -386,6 +391,7 @@
used_cells => { hdr => 'Cells Used', num => 1, label => 'Number of cells used' },
used_bufs => { hdr => 'Used Bufs', num => 1, label => 'Number of buffer pool pages used' },
user => { hdr => 'User', num => 0, label => 'Database username', },
+ value => { hdr => 'Value', num => 1, label => 'Value' },
versions => { hdr => 'Versions', num => 1, label => 'Number of InnoDB MVCC versions unpurged' },
victim => { hdr => 'Victim', num => 0, label => 'Whether this txn was the deadlock victim' },
wait_array_size => { hdr => 'Wait Array Size', num => 1, label => 'Wait Array Size' },
@@ -393,7 +399,7 @@
waited_at_filename => { hdr => 'File', num => 0, label => 'Filename at which thread waits' },
waited_at_line => { hdr => 'Line', num => 1, label => 'Line at which thread waits' },
waiters_flag => { hdr => 'Waiters', num => 1, label => 'Waiters Flag' },
- waiting => { hdr => 'Wait', num => 1, label => 'Whether txn is waiting for a lock' },
+ waiting => { hdr => 'Waiting', num => 1, label => 'Whether lock is being waited for' },
when => { hdr => 'When', num => 0, label => 'Time scale' },
writer_lock_mode => { hdr => 'Wrtr Lck Mode', num => 0, label => 'Writer lock mode' },
writer_thread => { hdr => 'Wrtr Thread', num => 1, label => 'Writer thread ID' },
@@ -675,6 +681,36 @@
'!~' => 'Negated pattern match',
);
+# ###########################################################################
+# Valid aggregate functions.
+# ###########################################################################
+my %agg_funcs = (
+ first => sub {
+ return $_[0]
+ },
+ count => sub {
+ return 0 + @_;
+ },
+ avg => sub {
+ my @args = grep { defined $_ } @_;
+ return (sum(map { m/([\d\.-]+)/g } @args) || 0) / (scalar(@args) || 1);
+ },
+ sum => \&sum,
+);
+
+# ###########################################################################
+# Valid functions for transformations.
+# ###########################################################################
+my %trans_funcs = (
+ shorten => \&shorten,
+ secs_to_time => \&secs_to_time,
+ no_ctrl_char => \&no_ctrl_char,
+ percent => \&percent,
+ commify => \&commify,
+ dulint_to_int => \&dulint_to_int,
+ set_precision => \&set_precision,
+);
+
# Table definitions {{{3
# This hash defines every table that can get displayed in every mode. Each
# table specifies columns and column data sources. The column is
@@ -707,6 +743,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'ib',
+ group_by => [],
+ aggregate => 0,
},
buffer_pool => {
capt => 'Buffer Pool',
@@ -741,7 +779,32 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'bp',
+ group_by => [],
+ aggregate => 0,
},
+ # TODO: a new step in set_to_tbl: join result to itself, grouped?
+ # TODO: this would also enable pulling Q and T data together.
+ # TODO: using a SQL-ish language would also allow pivots to be easier -- treat the pivoted data as a view and SELECT from it.
+ cmd_summary => {
+ capt => 'Command Summary',
+ cust => {},
+ cols => {
+ name => { src => 'name' },
+ total => { src => 'total' },
+ value => { src => 'value', agg => 'sum'},
+ pct => { src => 'value/total', trans => [qw(percent)] },
+ last_total => { src => 'last_total' },
+ last_value => { src => 'last_value', agg => 'sum'},
+ last_pct => { src => 'last_value/last_total', trans => [qw(percent)] },
+ },
+ visible => [qw(name value pct last_value last_pct)],
+ filters => [qw()],
+ sort_cols => '-value',
+ sort_dir => '1',
+ innodb => '',
+ group_by => [qw(name)],
+ aggregate => 1,
+ },
deadlock_locks => {
capt => 'Deadlock Locks',
cust => {},
@@ -749,7 +812,6 @@
cxn => { src => 'cxn' },
mysql_thread_id => { src => 'mysql_thread_id' },
dl_txn_num => { src => 'dl_txn_num' },
- txn_status => { src => 'txn_status' },
lock_type => { src => 'lock_type' },
space_id => { src => 'space_id' },
page_no => { src => 'page_no' },
@@ -762,13 +824,14 @@
special => { src => 'special' },
insert_intention => { src => 'insert_intention' },
waiting => { src => 'waiting' },
- num_locks => { src => 'num_locks' },
},
- visible => [ qw(cxn mysql_thread_id txn_status lock_mode db tbl index special insert_intention)],
+ visible => [ qw(cxn mysql_thread_id waiting lock_mode db tbl index special insert_intention)],
filters => [],
sort_cols => 'cxn mysql_thread_id',
sort_dir => '1',
innodb => 'dl',
+ group_by => [],
+ aggregate => 0,
},
deadlock_transactions => {
capt => 'Deadlock Transactions',
@@ -812,6 +875,8 @@
sort_cols => 'cxn mysql_thread_id',
sort_dir => '1',
innodb => 'dl',
+ group_by => [],
+ aggregate => 0,
},
explain => {
capt => 'EXPLAIN Results',
@@ -834,6 +899,8 @@
sort_cols => '',
sort_dir => '1',
innodb => '',
+ group_by => [],
+ aggregate => 0,
},
file_io_misc => {
capt => 'File I/O Misc',
@@ -854,6 +921,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'io',
+ group_by => [],
+ aggregate => 0,
},
fk_error => {
capt => 'Foreign Key Error Info',
@@ -875,6 +944,8 @@
sort_cols => '',
sort_dir => '1',
innodb => 'fk',
+ group_by => [],
+ aggregate => 0,
},
insert_buffers => {
capt => 'Insert Buffers',
@@ -893,7 +964,43 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'ib',
+ group_by => [],
+ aggregate => 0,
},
+ innodb_locks => {
+ capt => 'InnoDB Locks',
+ cust => {},
+ cols => {
+ cxn => { src => 'cxn' },
+ db => { src => 'db' },
+ index => { src => 'index' },
+ insert_intention => { src => 'insert_intention' },
+ lock_mode => { src => 'lock_mode' },
+ lock_type => { src => 'lock_type' },
+ lock_wait_time => { src => 'lock_wait_time', trans => [ qw(secs_to_time) ] },
+ mysql_thread_id => { src => 'mysql_thread_id' },
+ n_bits => { src => 'n_bits' },
+ page_no => { src => 'page_no' },
+ space_id => { src => 'space_id' },
+ special => { src => 'special' },
+ tbl => { src => 'table' },
+ 'time' => { src => 'active_secs', hdr => 'Active', trans => [ qw(secs_to_time) ] },
+ txn_id => { src => 'txn_id' },
+ waiting => { src => 'waiting' },
+ },
+ visible => [ qw(cxn mysql_thread_id lock_type waiting lock_wait_time time lock_mode db tbl index insert_intention special)],
+ filters => [],
+ sort_cols => 'cxn -lock_wait_time',
+ sort_dir => '1',
+ innodb => 'tx',
+ colors => [
+ { col => 'lock_wait_time', op => '>', arg => 60, color => 'red' },
+ { col => 'lock_wait_time', op => '>', arg => 30, color => 'yellow' },
+ { col => 'lock_wait_time', op => '>', arg => 10, color => 'green' },
+ ],
+ group_by => [],
+ aggregate => 0,
+ },
innodb_transactions => {
capt => 'InnoDB Transactions',
cust => {},
@@ -905,29 +1012,30 @@
hostname => { src => $exprs{Host} },
ip => { src => 'ip' },
wait_status => { src => 'lock_wait_status' },
- lock_wait_time => { src => 'lock_wait_time', trans => [ qw(secs_to_time) ] },
+ lock_wait_time => { src => 'lock_wait_time', trans => [ qw(secs_to_time) ] },
lock_structs => { src => 'lock_structs' },
mysql_thread_id => { src => 'mysql_thread_id' },
os_thread_id => { src => 'os_thread_id' },
proc_no => { src => 'proc_no' },
query_id => { src => 'query_id' },
query_status => { src => 'query_status' },
- query_text => { src => 'query_text', trans => [ qw(no_ctrl_char) ] },
+ query_text => { src => 'query_text', trans => [ qw(no_ctrl_char) ] },
txn_time_remain => { src => $exprs{TxnTimeRemain}, trans => [ qw(secs_to_time) ] },
row_locks => { src => 'row_locks' },
tables_in_use => { src => 'tables_in_use' },
tables_locked => { src => 'tables_locked' },
thread_decl_inside => { src => 'thread_decl_inside' },
thread_status => { src => 'thread_status' },
- 'time' => { src => 'active_secs', trans => [ qw(secs_to_time) ] },
+ 'time' => { src => 'active_secs', trans => [ qw(secs_to_time) ], agg => 'sum' },
txn_doesnt_see_ge => { src => 'txn_doesnt_see_ge' },
txn_id => { src => 'txn_id' },
txn_sees_lt => { src => 'txn_sees_lt' },
- txn_status => { src => 'txn_status', minw => 10, maxw => 10 },
+ txn_status => { src => 'txn_status', minw => 10, maxw => 10 },
undo_log_entries => { src => 'undo_log_entries' },
- user => { src => 'user', maxw => 10 },
+ user => { src => 'user', maxw => 10 },
+ cnt => { src => 'mysql_thread_id', minw => 0 },
},
- visible => [ qw(cxn mysql_thread_id user hostname txn_status time undo_log_entries query_text)],
+ visible => [ qw(cxn cnt mysql_thread_id user hostname txn_status time undo_log_entries query_text)],
filters => [ qw( hide_self hide_inactive ) ],
sort_cols => '-active_secs txn_status cxn mysql_thread_id',
sort_dir => '1',
@@ -941,6 +1049,8 @@
{ col => 'time', op => '>', arg => 30, color => 'cyan' },
{ col => 'txn_status', op => 'eq', arg => 'not started', color => 'white' },
],
+ group_by => [ qw(cxn txn_status) ],
+ aggregate => 0,
},
io_threads => {
capt => 'I/O Threads',
@@ -957,39 +1067,9 @@
sort_cols => 'cxn thread',
sort_dir => '1',
innodb => 'io',
+ group_by => [],
+ aggregate => 0,
},
- lock_waits => {
- capt => 'Lock Waits',
- cust => {},
- cols => {
- cxn => { src => 'cxn' },
- db => { src => 'db' },
- index => { src => 'index' },
- insert_intention => { src => 'insert_intention' },
- lock_mode => { src => 'lock_mode' },
- lock_type => { src => 'lock_type' },
- lock_wait_time => { src => 'lock_wait_time', trans => [ qw(secs_to_time) ] },
- mysql_thread_id => { src => 'mysql_thread_id' },
- n_bits => { src => 'n_bits' },
- num_locks => { src => 'num_locks' },
- page_no => { src => 'page_no' },
- space_id => { src => 'space_id' },
- special => { src => 'special' },
- tbl => { src => 'table' },
- 'time' => { src => 'active_secs', hdr => 'Active', trans => [ qw(secs_to_time) ] },
- txn_id => { src => 'txn_id' },
- },
- visible => [ qw(cxn mysql_thread_id lock_wait_time time lock_mode db tbl index insert_intention special)],
- filters => [],
- sort_cols => 'cxn -lock_wait_time',
- sort_dir => '1',
- innodb => 'tx',
- colors => [
- { col => 'lock_wait_time', op => '>', arg => 60, color => 'red' },
- { col => 'lock_wait_time', op => '>', arg => 30, color => 'yellow' },
- { col => 'lock_wait_time', op => '>', arg => 10, color => 'green' },
- ],
- },
log_statistics => {
capt => 'Log Statistics',
cust => {},
@@ -1008,6 +1088,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'lg',
+ group_by => [],
+ aggregate => 0,
},
master_status => {
capt => 'Master Status',
@@ -1025,6 +1107,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => '',
+ group_by => [],
+ aggregate => 0,
},
pending_io => {
capt => 'Pending I/O',
@@ -1046,6 +1130,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'io',
+ group_by => [],
+ aggregate => 0,
},
open_tables => {
capt => 'Open Tables',
@@ -1062,6 +1148,8 @@
sort_cols => '-num_times_open cxn db tbl',
sort_dir => '1',
innodb => '',
+ group_by => [],
+ aggregate => 0,
},
page_statistics => {
capt => 'Page Statistics',
@@ -1080,6 +1168,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'bp',
+ group_by => [],
+ aggregate => 0,
},
processlist => {
capt => 'MySQL Process List',
@@ -1093,11 +1183,12 @@
host_and_port => { src => 'host', minw => 0, maxw => 0 },
db => { src => 'db', minw => 6, maxw => 12 },
cmd => { src => 'command', minw => 5, maxw => 0 },
- time => { src => 'time', minw => 5, maxw => 0, trans => [ qw(secs_to_time) ] },
+ time => { src => 'time', minw => 5, maxw => 0, trans => [ qw(secs_to_time) ], agg => 'sum' },
state => { src => 'state', minw => 0, maxw => 0 },
info => { src => 'info', minw => 0, maxw => 0, trans => [ qw(no_ctrl_char) ] },
+ cnt => { src => 'id', minw => 0, maxw => 0 },
},
- visible => [ qw(cxn mysql_thread_id user hostname db time info)],
+ visible => [ qw(cxn cmd cnt mysql_thread_id user hostname db time info)],
filters => [ qw(hide_self hide_inactive hide_slave_io) ],
sort_cols => '-time cxn hostname mysql_thread_id',
sort_dir => '1',
@@ -1114,7 +1205,15 @@
{ col => 'time', op => '>', arg => 60, color => 'green' },
{ col => 'time', op => '>', arg => 30, color => 'cyan' },
],
+ group_by => [qw(cxn cmd)],
+ aggregate => 0,
},
+
+ # TODO: some more columns:
+ # kb_used=hdr='BufUsed' minw='0' num='0' src='percent(1 - ((Key_blocks_unused * key_cache_block_size) / (key_buffer_size||1)))' dec='0' trans='' tbl='q_header' just='-' user='1' maxw='0' label='User-defined'
+ # retries=hdr='Retries' minw='0' num='0' src='Slave_retried_transactions' dec='0' trans='' tbl='slave_sql_status' just='-' user='1' maxw='0' label='User-defined'
+ # thd=hdr='Thd' minw='0' num='0' src='Threads_connected' dec='0' trans='' tbl='slave_sql_status' just='-' user='1' maxw='0' label='User-defined'
+
q_header => {
capt => 'Q-mode Header',
cust => {},
@@ -1136,6 +1235,8 @@
sort_dir => '1',
innodb => '',
hide_caption => 1,
+ group_by => [],
+ aggregate => 0,
},
row_operations => {
capt => 'InnoDB Row Operations',
@@ -1157,6 +1258,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'ro',
+ group_by => [],
+ aggregate => 0,
},
row_operation_misc => {
capt => 'Row Operation Misc',
@@ -1176,6 +1279,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'ro',
+ group_by => [],
+ aggregate => 0,
},
semaphores => {
capt => 'InnoDB Semaphores',
@@ -1200,6 +1305,8 @@
sort_cols => 'cxn',
sort_dir => '1',
innodb => 'sm',
+ group_by => [],
+ aggregate => 0,
},
slave_io_status => {
capt => 'Slave I/O Status',
@@ -1230,6 +1337,8 @@
],
sort_dir => '1',
innodb => '',
+ group_by => [],
+ aggregate => 0,
},
slave_sql_status => {
capt => 'Slave SQL Status',
@@ -1271,6 +1380,8 @@
{ col => 'time_behind_master', op => '>', arg => 60, color => 'yellow' },
{ col => 'time_behind_master', op => '==', arg => 0, color => 'white' },
],
+ group_by => [],
+ aggregate => 0,
},
t_header => {
capt => 'T-Mode Header',
@@ -1293,6 +1404,8 @@
innodb => '',
colors => [],
hide_caption => 1,
+ group_by => [],
+ aggregate => 0,
},
var_status => {
capt => 'Variables & Status',
@@ -1306,6 +1419,8 @@
temp => 1, # Do not persist to config file.
hide_caption => 1,
pivot => 0,
+ group_by => [],
+ aggregate => 0,
},
wait_array => {
capt => 'InnoDB Wait Array',
@@ -1337,6 +1452,8 @@
sort_cols => 'cxn -time',
sort_dir => '1',
innodb => 'sm',
+ group_by => [],
+ aggregate => 0,
},
);
@@ -1359,12 +1476,24 @@
: $col_props{$prop};
}
}
+
+ # Ensure transformations and aggregate functions are valid
+ die "Unknown aggregate function '$col_def->{agg}' "
+ . "for column '$col_name' in table '$table_name'"
+ unless exists $agg_funcs{$col_def->{agg}};
+ foreach my $trans ( @{$col_def->{trans}} ) {
+ die "Unknown transformation '$trans' "
+ . "for column '$col_name' in table '$table_name'"
+ unless exists $trans_funcs{$trans};
+ }
}
- # Ensure each column in visible exists in cols
- foreach my $col_name ( @{$table->{visible}} ) {
- if ( !exists $cols->{$col_name} ) {
- die "Column '$col_name' is listed in visible for '$table_name', but doesn't exist";
+ # Ensure each column in visible and group_by exists in cols
+ foreach my $place ( qw(visible group_by) ) {
+ foreach my $col_name ( @{$table->{$place}} ) {
+ if ( !exists $cols->{$col_name} ) {
+ die "Column '$col_name' is listed in '$place' for '$table_name', but doesn't exist";
+ }
}
}
@@ -1383,19 +1512,6 @@
}
# ###########################################################################
-# Valid functions for transformations.
-# ###########################################################################
-my %trans_funcs = (
- shorten => \&shorten,
- secs_to_time => \&secs_to_time,
- no_ctrl_char => \&no_ctrl_char,
- percent => \&percent,
- commify => \&commify,
- dulint_to_int => \&dulint_to_int,
- set_precision => \&set_precision,
-);
-
-# ###########################################################################
# Operating modes {{{3
# ###########################################################################
my %modes = (
@@ -1416,6 +1532,23 @@
tables => [qw(buffer_pool page_statistics insert_buffers adaptive_hash_index)],
visible_tables => [qw(buffer_pool page_statistics insert_buffers adaptive_hash_index)],
},
+ C => {
+ hdr => 'Command Summary',
+ cust => {},
+ note => 'Shows relative magnitude of variables',
+ action_for => {
+ s => {
+ action => sub { get_config_interactive('cmd_filter') },
+ label => 'Choose variable prefix',
+ },
+ },
+ display_sub => \&display_C,
+ connections => [],
+ server_group => '',
+ one_connection => 0,
+ tables => [qw(cmd_summary)],
+ visible_tables => [qw(cmd_summary)],
+ },
D => {
hdr => 'InnoDB Deadlocks',
cust => {},
@@ -1466,6 +1599,27 @@
tables => [qw(io_threads pending_io file_io_misc log_statistics)],
visible_tables => [qw(io_threads pending_io file_io_misc log_statistics)],
},
+ L => {
+ hdr => 'Locks',
+ cust => {},
+ note => 'Shows transaction locks',
+ action_for => {
+ a => {
+ action => sub { send_cmd_to_servers('CREATE TABLE IF NOT EXISTS test.innodb_lock_monitor(a int) ENGINE=InnoDB', 0, '', []); },
+ label => 'Start the InnoDB Lock Monitor',
+ },
+ o => {
+ action => sub { send_cmd_to_servers('DROP TABLE IF EXISTS test.innodb_lock_monitor', 0, '', []); },
+ label => 'Stop the InnoDB Lock Monitor',
+ },
+ },
+ display_sub => \&display_L,
+ connections => [],
+ server_group => '',
+ one_connection => 0,
+ tables => [qw(innodb_locks)],
+ visible_tables => [qw(innodb_locks)],
+ },
M => {
hdr => 'Replication Status',
cust => {},
@@ -1639,7 +1793,7 @@
no_clear_screen => 1,
connections => [],
server_group => '',
- one_connection => 1,
+ one_connection => 0,
tables => [qw(var_status)],
visible_tables => [qw(var_status)],
},
@@ -1696,18 +1850,6 @@
tables => [qw(t_header innodb_transactions)],
visible_tables => [qw(t_header innodb_transactions)],
},
- W => {
- hdr => 'InnoDB Lock Waits',
- cust => {},
- note => 'Shows transaction lock waits and OS wait array info',
- action_for => { },
- display_sub => \&display_W,
- connections => [],
- server_group => '',
- one_connection => 0,
- tables => [qw(lock_waits wait_array)],
- visible_tables => [qw(lock_waits wait_array)],
- },
);
# ###########################################################################
@@ -1758,10 +1900,19 @@
label => 'Switch to the next server group',
key => 'TAB',
},
+ '=' => {
+ action => \&toggle_aggregate,
+ label => 'Toggle aggregation',
+ },
+ # TODO: can these be auto-generated from %modes?
B => {
action => sub { switch_mode('B') },
label => '',
},
+ C => {
+ action => sub { switch_mode('C') },
+ label => '',
+ },
D => {
action => sub { switch_mode('D') },
label => '',
@@ -1774,6 +1925,10 @@
action => sub { switch_mode('I') },
label => '',
},
+ L => {
+ action => sub { switch_mode('L') },
+ label => '',
+ },
M => {
action => sub { switch_mode('M') },
label => '',
@@ -1798,10 +1953,6 @@
action => sub { switch_mode('T') },
label => '',
},
- W => {
- action => sub { switch_mode('W') },
- label => '',
- },
d => {
action => sub { get_config_interactive('interval') },
label => 'Change refresh interval',
@@ -1832,6 +1983,10 @@
note => 'Edit row-coloring rules',
func => \&edit_color_rules,
},
+ p => {
+ note => 'Manage plugins',
+ func => \&edit_plugins,
+ },
s => {
note => 'Edit server groups',
func => \&edit_server_groups,
@@ -1963,6 +2118,35 @@
);
# ###########################################################################
+# Plugin editor key mappings {{{3
+# ###########################################################################
+my %plugin_editor_action = (
+ '*' => {
+ note => 'Toggle selected plugin active/inactive',
+ func => sub {
+ my ( $plugins, $idx ) = @_;
+ my $plugin = $plugins->[$idx];
+ $plugin->{active} = $plugin->{active} ? 0 : 1;
+ return $idx;
+ },
+ },
+ j => {
+ note => 'Move highlight down one',
+ func => sub {
+ my ( $plugins, $idx ) = @_;
+ return ($idx + 1) % scalar(@$plugins);
+ },
+ },
+ k => {
+ note => 'Move highlight up one',
+ func => sub {
+ my ( $plugins, $idx ) = @_;
+ return $idx == 0 ? @$plugins - 1 : $idx - 1;
+ },
+ },
+);
+
+# ###########################################################################
# Table editor key mappings {{{3
# ###########################################################################
my %tbl_editor_action = (
@@ -1992,8 +2176,8 @@
my ( $tbl, $col ) = @_;
$clear_screen_sub->();
- print word_wrap("Choose a name for the column. This name is not displayed, and is only used "
- . "for internal reference. It can only contain lowercase letters, numbers, "
+ print word_wrap("Choose a name for the column. This name is not displayed, and is used only "
+ . "for internal reference. It can contain only lowercase letters, numbers, "
. "and underscores.");
print "\n\n";
do {
@@ -2020,6 +2204,7 @@
}
} until ( !$err);
+ # TODO: this duplicates %col_props.
$tbl_meta{$tbl}->{cols}->{$col} = {
hdr => $hdr,
src => $src,
@@ -2033,6 +2218,8 @@
trans => [],
func => $sub,
dec => 0,
+ agg => 0,
+ aggonly => 0,
};
$tbl_meta{$tbl}->{visible} = [ unique(@{$tbl_meta{$tbl}->{visible}}, $col) ];
@@ -2062,7 +2249,7 @@
my ( $tbl, $col ) = @_;
$clear_screen_sub->();
my $meta = $tbl_meta{$tbl}->{cols}->{$col};
- my @prop = qw(hdr label src just num minw maxw trans); # TODO redundant
+ my @prop = qw(hdr label src just num minw maxw trans agg); # TODO redundant
my $answer;
do {
@@ -2194,6 +2381,14 @@
return $col;
},
},
+ g => {
+ note => 'Choose group-by (aggregate) columns',
+ func => sub {
+ my ( $tbl, $col ) = @_;
+ choose_group_cols($tbl);
+ return $col;
+ },
+ },
);
# ###########################################################################
@@ -2210,6 +2405,9 @@
my $int_regex = qr/^\d+$/;
my $bool_regex = qr/^[01]$/;
my $term = undef;
+my $file = undef; # File to watch for InnoDB monitor output
+my $file_mtime = undef; # Status of watched file
+my $file_data = undef; # Last chunk of text read from file
my $innodb_parser = InnoDBParser->new;
my $nonfatal_errs = join('|',
@@ -2239,8 +2437,6 @@
my @current_queries;
my $lines_printed = 0;
-my @innodb_files = ();
-my $innodb_file_counter = -1;
my $clock = 0; # Incremented with every wake-sleep cycle
my $clearing_deadlocks = 0;
@@ -2280,6 +2476,22 @@
# Config storage. {{{2
# ###########################################################################
my %config = (
+ color => {
+ val => $have_color,
+ note => 'Whether to use terminal coloring',
+ conf => 'ALL',
+ pat => $bool_regex,
+ },
+ cmd_filter => {
+ val => 'Com_',
+ note => 'Prefix for values in C mode',
+ conf => [qw(C)],
+ },
+ plugin_dir => {
+ val => "$homepath/.innotop/plugins",
+ note => 'Directory where plugins can be found',
+ conf => 'ALL',
+ },
show_percent => {
val => 1,
note => 'Show the % symbol after percentages',
@@ -2382,7 +2594,7 @@
conf => 'ALL',
},
debugfile => {
- val => "$homepath/.innotop_core_dump",
+ val => "$homepath/.innotop/core_dump",
note => 'A debug file in case you are interested in error output',
},
show_statusbar => {
@@ -2427,6 +2639,14 @@
# and writing them.
# ###########################################################################
my %config_file_sections = (
+ plugins => {
+ reader => \&load_config_plugins,
+ writer => \&save_config_plugins,
+ },
+ group_by => {
+ reader => \&load_config_group_by,
+ writer => \&save_config_group_by,
+ },
filters => {
reader => \&load_config_filters,
writer => \&save_config_filters,
@@ -2490,10 +2710,36 @@
);
# Config file sections have some dependencies, so they have to be read/written in order.
-my @ordered_config_file_sections = qw(general filters active_filters tbl_meta
+my @ordered_config_file_sections = qw(general plugins filters active_filters tbl_meta
connections active_connections server_groups active_server_groups max_values_seen
- active_columns sort_cols visible_tables varsets colors stmt_sleep_times);
+ active_columns sort_cols visible_tables varsets colors stmt_sleep_times
+ group_by);
+# All events for which plugins may register themselves. Entries are arrayrefs.
+my %event_listener_for = map { $_ => [] }
+ qw(
+ extract_values
+ set_to_tbl_pre_filter set_to_tbl_pre_sort set_to_tbl_pre_group
+ set_to_tbl_pre_colorize set_to_tbl_pre_transform set_to_tbl_pre_pivot
+ set_to_tbl_pre_create set_to_tbl_post_create
+ draw_screen
+ );
+
+# All variables to which plugins have access.
+my %pluggable_vars = (
+ action_for => \%action_for,
+ agg_funcs => \%agg_funcs,
+ config => \%config,
+ connections => \%connections,
+ dbhs => \%dbhs,
+ filters => \%filters,
+ modes => \%modes,
+ server_groups => \%server_groups,
+ tbl_meta => \%tbl_meta,
+ trans_funcs => \%trans_funcs,
+ var_sets => \%var_sets,
+);
+
# ###########################################################################
# Contains logic to generate prepared statements for a given function for a
# given DB connection. Returns a $sth.
@@ -2553,6 +2799,10 @@
},
);
+# Plugins!
+my %plugins = (
+);
+
# ###########################################################################
# Run the program {{{1
# ###########################################################################
@@ -2581,6 +2831,13 @@
eval {
+ # Open the file for InnoDB status
+ if ( @ARGV ) {
+ my $filename = shift @ARGV;
+ open $file, "<", $filename
+ or die "Cannot open '$filename': $OS_ERROR";
+ }
+
# In certain modes we might have to collect data for two cycles
# before printing anything out, so we need to bump up the count one.
if ( $opts{n} && $opts{count} && $config{status_inc}->{val}
@@ -2617,9 +2874,10 @@
# See whether there are any connections defined for this mode. If there's only one
# connection total, assume the user wants to just use innotop for a single server
- # and don't ask which server to connect to.
+ # and don't ask which server to connect to. Also, if we're monitoring from a file,
+ # we just use the first connection.
if ( !get_connections() ) {
- if ( 1 == scalar keys %connections ) {
+ if ( $file || 1 == scalar keys %connections ) {
$modes{$config{mode}->{val}}->{connections} = [ keys %connections ];
}
else {
@@ -3041,6 +3299,62 @@
draw_screen(\@display_lines);
}
+# display_C {{{3
+sub display_C {
+ my @display_lines;
+ my @cxns = get_connections();
+ get_status_info(@cxns);
+
+ my @cmd_summary;
+ my %rows_for = (
+ cmd_summary => \@cmd_summary,
+ );
+
+ my @visible = get_visible_tables();
+ my %wanted = map { $_ => 1 } @visible;
+
+ # For now, I'm manually pulling these variables out and pivoting. Eventually a SQL-ish
+ # dialect should let me join a table to a grouped and pivoted table and do this more easily.
+ # TODO: make it so.
+ my $prefix = qr/^$config{cmd_filter}->{val}/; # TODO: this is a total hack
+ my @values;
+ my ($total, $last_total) = (0, 0);
+ foreach my $cxn ( @cxns ) {
+ my $set = $vars{$cxn}->{$clock};
+ my $pre = $vars{$cxn}->{$clock-1} || $set;
+ foreach my $key ( keys %$set ) {
+ next unless $key =~ m/$prefix/i;
+ my $val = $set->{$key};
+ next unless defined $val && $val =~ m/^\d+$/;
+ my $last_val = $val - ($pre->{$key} || 0);
+ $total += $val;
+ $last_total += $last_val;
+ push @values, {
+ name => $key,
+ value => $val,
+ last_value => $last_val,
+ };
+ }
+ }
+
+ # Add aggregation and turn into a real set TODO: total hack
+ if ( $wanted{cmd_summary} ) {
+ foreach my $value ( @values ) {
+ @{$value}{qw(total last_total)} = ($total, $last_total);
+ push @cmd_summary, extract_values($value, $value, $value, 'cmd_summary');
+ }
+ }
+
+ my $first_table = 0;
+ foreach my $tbl ( @visible ) {
+ push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl);
+ push @display_lines, get_cxn_errors(@cxns)
+ if ( $config{debug}->{val} || !$first_table++ );
+ }
+
+ draw_screen(\@display_lines);
+}
+
# display_D {{{3
sub display_D {
my @display_lines;
@@ -3081,17 +3395,12 @@
}
if ( $wanted{deadlock_locks} ) {
- foreach my $what (qw(waits_for holds)) {
- my $locks = $txn->{$what};
- my $pre_l = $pre->{$what};
- if ( $locks ) {
- my $hash = extract_values($locks, $locks, $pre_l, 'deadlock_locks');
- $hash->{dl_txn_num} = $txn_id;
- $hash->{txn_status} = $what;
- $hash->{cxn} = $cxn;
- $hash->{mysql_thread_id} = $txn->{tx}->{mysql_thread_id};
- push @deadlock_locks, $hash;
- }
+ foreach my $lock ( @{$txn->{locks}} ) {
+ my $hash = extract_values($lock, $lock, $lock, 'deadlock_locks');
+ $hash->{dl_txn_num} = $txn_id;
+ $hash->{cxn} = $cxn;
+ $hash->{mysql_thread_id} = $txn->{tx}->{mysql_thread_id};
+ push @deadlock_locks, $hash;
}
}
@@ -3204,6 +3513,52 @@
draw_screen(\@display_lines);
}
+# display_L {{{3
+sub display_L {
+ my @display_lines;
+ my @cxns = get_connections();
+ get_innodb_status(\@cxns);
+
+ my @innodb_locks;
+ my %rows_for = (
+ innodb_locks => \@innodb_locks,
+ );
+
+ my @visible = get_visible_tables();
+ my %wanted = map { $_ => 1 } @visible;
+
+ # Get info on locks
+ foreach my $cxn ( @cxns ) {
+ my $set = $vars{$cxn}->{$clock} or next;
+ my $pre = $vars{$cxn}->{$clock-1} || $set;
+
+ if ( $wanted{innodb_locks} && defined $set->{IB_tx_transactions} && @{$set->{IB_tx_transactions}} ) {
+
+ my $cur_txns = $set->{IB_tx_transactions};
+ my $pre_txns = $pre->{IB_tx_transactions} || $cur_txns;
+ my %cur_txns = map { $_->{mysql_thread_id} => $_ } @$cur_txns;
+ my %pre_txns = map { $_->{mysql_thread_id} => $_ } @$pre_txns;
+ foreach my $txn ( @$cur_txns ) {
+ foreach my $lock ( @{$txn->{locks}} ) {
+ my %hash = map { $_ => $txn->{$_} } qw(txn_id mysql_thread_id lock_wait_time active_secs);
+ map { $hash{$_} = $lock->{$_} } qw(lock_type space_id page_no n_bits index db table txn_id lock_mode special insert_intention waiting);
+ $hash{cxn} = $cxn;
+ push @innodb_locks, extract_values(\%hash, \%hash, \%hash, 'innodb_locks');
+ }
+ }
+ }
+ }
+
+ my $first_table = 0;
+ foreach my $tbl ( @visible ) {
+ push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl);
+ push @display_lines, get_cxn_errors(@cxns)
+ if ( $config{debug}->{val} || !$first_table++ );
+ }
+
+ draw_screen(\@display_lines);
+}
+
# display_M {{{3
sub display_M {
my @display_lines;
@@ -3314,7 +3669,7 @@
# that get pushed to the screen.
@current_queries = map {
my %hash;
- @hash{ qw(cxn id db query) } = @{$_}{ qw(cxn mysql_thread_id db info) };
+ @hash{ qw(cxn id db query secs) } = @{$_}{ qw(cxn mysql_thread_id db info secs) };
\%hash;
} @{$rows_for{processlist}};
@@ -3439,7 +3794,7 @@
# that get pushed to the screen.
@current_queries = map {
my %hash;
- @hash{ qw(cxn id db query) } = @{$_}{ qw(cxn mysql_thread_id db query_text) };
+ @hash{ qw(cxn id db query secs) } = @{$_}{ qw(cxn mysql_thread_id db query_text active_secs) };
\%hash;
} @{$rows_for{innodb_transactions}};
@@ -3459,6 +3814,13 @@
}
else {
( $cols, $visible ) = compile_select_stmt($fmt);
+
+ # Apply missing values to columns. Always apply averages across all connections.
+ map {
+ $_->{agg} = 'avg';
+ $_->{label} = $_->{hdr};
+ } values %$cols;
+
$tbl_meta{var_status}->{cols} = $cols;
$tbl_meta{var_status}->{visible} = $visible;
$tbl_meta{var_status}->{fmt} = $fmt;
@@ -3479,19 +3841,36 @@
# Set up whether to pivot and how many sets to extract.
$tbl_meta{var_status}->{pivot} = $func eq 'v';
- my $num_sets = $func eq 'v' ? $config{num_status_sets}->{val} : 0;
- foreach my $cxn ( @cxns ) {
- foreach my $set ( 0 .. $num_sets ) {
+ my $num_sets
+ = $func eq 'v'
+ ? $config{num_status_sets}->{val}
+ : 0;
+ foreach my $set ( 0 .. $num_sets ) {
+ my @rows;
+ foreach my $cxn ( @cxns ) {
my $vars = $inc ? inc($set, $cxn) : $vars{$cxn}->{$clock - $set};
my $cur = $vars{$cxn}->{$clock-$set};
my $pre = $vars{$cxn}->{$clock-$set-1} || $cur;
next unless $vars && %$vars;
my $hash = extract_values($vars, $cur, $pre, 'var_status');
- push @var_status, $hash;
+ push @rows, $hash;
}
+ @rows = apply_group_by('var_status', [], @rows);
+ push @var_status, @rows;
}
+ # Recompile the sort func. TODO: avoid recompiling at every refresh.
+ # Figure out whether the data is all numeric and decide on a sort type.
+ # my $cmp
+ # = scalar(
+ # grep { !defined $_ || $_ !~ m/^\d+$/ }
+ # map { my $col = $_; map { $_->{$col} } @var_status }
+ # $tbl_meta{var_status}->{sort_cols} =~ m/(\w+)/g)
+ # ? 'cmp'
+ # : '<=>';
+ $tbl_meta{var_status}->{sort_func} = make_sort_func($tbl_meta{var_status});
+
# ################################################################
# Now there is specific display code based on $config{S_func}
# ################################################################
@@ -3581,73 +3960,6 @@
}
}
-# display_W {{{3
-sub display_W {
- my @display_lines;
- my @cxns = get_connections();
- get_innodb_status(\@cxns);
-
- my @lock_waits;
- my @wait_array;
- my %rows_for = (
- lock_waits => \@lock_waits,
- wait_array => \@wait_array,
- );
-
- my @visible = get_visible_tables();
- my %wanted = map { $_ => 1 } @visible;
-
- # Get info on lock waits and OS wait array
- foreach my $cxn ( @cxns ) {
- my $set = $vars{$cxn}->{$clock} or next;
- my $pre = $vars{$cxn}->{$clock-1} || $set;
-
- if ( $wanted{lock_waits} && defined $set->{IB_tx_transactions} && @{$set->{IB_tx_transactions}} ) {
-
- my $cur_txns = $set->{IB_tx_transactions};
- my $pre_txns = $pre->{IB_tx_transactions} || $cur_txns;
- my %cur_txns = map { $_->{mysql_thread_id} => $_ } @$cur_txns;
- my %pre_txns = map { $_->{mysql_thread_id} => $_ } @$pre_txns;
- foreach my $thd_id ( map { $_->{mysql_thread_id} } grep { $_->{lock_wait_status} } @$cur_txns ) {
- my $cur_txn = $cur_txns{$thd_id};
- my $pre_txn = $pre_txns{$thd_id} || $cur_txn;
-
- my %cur_lock_wait = map { $_ => $cur_txn->{$_} } qw(txn_id mysql_thread_id lock_wait_time active_secs);
- my $cur_wait_locks = $cur_txn->{wait_locks};
- map { $cur_lock_wait{$_} = $cur_wait_locks->{$_} } qw(lock_type space_id page_no n_bits index db table txn_id lock_mode special insert_intention waiting num_locks);
- $cur_lock_wait{cxn} = $cxn;
-
- my %pre_lock_wait = map { $_ => $pre_txn->{$_} } qw(txn_id mysql_thread_id lock_wait_time active_secs);
- my $pre_wait_locks = $pre_txn->{wait_locks};
- map { $pre_lock_wait{$_} = $pre_wait_locks->{$_} } qw(lock_type space_id page_no n_bits index db table txn_id lock_mode special insert_intention waiting num_locks);
- $pre_lock_wait{cxn} = $cxn;
-
- push @lock_waits, extract_values(\%cur_lock_wait, \%cur_lock_wait, \%pre_lock_wait, 'lock_waits');
- }
- }
-
- if ( $wanted{wait_array} && $set->{IB_sm_complete} ) {
- if ( $set->{IB_sm_wait_array_size} ) {
- foreach my $wait ( @{$set->{IB_sm_waits}} ) {
- # TODO: try to get prev values...
- my $hash = extract_values($wait, $wait, $wait, 'wait_array');
- $hash->{cxn} = $cxn;
- push @wait_array, $hash;
- }
- }
- }
- }
-
- my $first_table = 0;
- foreach my $tbl ( @visible ) {
- push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl);
- push @display_lines, get_cxn_errors(@cxns)
- if ( $config{debug}->{val} || !$first_table++ );
- }
-
- draw_screen(\@display_lines);
-}
-
# display_explain {{{3
sub display_explain {
my $info = shift;
@@ -3682,7 +3994,11 @@
};
if ( $EVAL_ERROR ) {
- push @display_lines, '', "The query could not be explained: $EVAL_ERROR";
+ push @display_lines,
+ '',
+ "The query could not be explained. Only SELECT queries can be "
+ . "explained; innotop tries to rewrite certain REPLACE and INSERT queries "
+ . "into SELECT, but this doesn't always succeed.";
}
}
@@ -3699,8 +4015,6 @@
}
# rewrite_for_explain {{{3
-# TODO: Some replace/create/insert...select can be rewritten easily.
-# TODO: update foo inner join bar can also be rewritten.
sub rewrite_for_explain {
my $query = shift;
@@ -3833,25 +4147,6 @@
# Formatting functions {{{2
-# create_grid {{{3
-sub create_grid {
- my @vals = @_;
- my @result;
-
- # Slice and stack, baby.
- my $i = 0;
- while ($i < @vals) {
- # Do 5 at a time
- my $max_index = min( scalar(@vals), $i + 5 );
- my @slice = @vals[$i..$max_index - 1];
- my $max_width = max( map{ length($_) } @slice );
- @slice = map { sprintf("%-${max_width}s", $_) } @slice;
- @result = stack_next(\@result, \@slice);
- $i += 5;
- }
- return @result;
-}
-
# create_table2 {{{3
# Makes a two-column table, labels on left, data on right.
# Takes refs of @cols, %labels and %data, %user_prefs
@@ -3972,7 +4267,7 @@
else {
# Color is supported, so we can use terminal underlining.
- if ( $have_color ) {
+ if ( $config{color}->{val} ) {
my $left = int(($width - $cap_len) / 2);
unshift @rows, [
(" " x $left) . $caption . (" " x ($width - $left - $cap_len)),
@@ -4067,7 +4362,7 @@
push @rows, $opts{n}
? join( $col_sep, @$cols )
: join( $col_sep, map { sprintf( "%-$width_for{$_}s", trunc($info->{$_}->{hdr}, $width_for{$_}) ) } @$cols );
- if ( $have_color && $config{header_highlight}->{val} ) {
+ if ( $config{color}->{val} && $config{header_highlight}->{val} ) {
push @rows, [ pop @rows, $config{header_highlight}->{val} ];
}
elsif ( !$opts{n} ) {
@@ -4086,7 +4381,7 @@
map { "%$info->{$_}->{just}$width_for{$_}s" } @$cols );
foreach my $item ( @$data ) {
my $row = sprintf($format, map { trunc($item->{$_}, $width_for{$_}) } @$cols );
- if ( $have_color && $item->{_color} ) {
+ if ( $config{color}->{val} && $item->{_color} ) {
push @rows, [ $row, $item->{_color} ];
}
else {
@@ -4099,25 +4394,73 @@
return @rows;
}
+# Aggregates a table. If $group_by is an arrayref of columns, the grouping key
+# is the specified columns; otherwise it's just the empty string (e.g.
+# everything is grouped as one group).
+sub apply_group_by {
+ my ( $tbl, $group_by, @rows ) = @_;
+ my $meta = $tbl_meta{$tbl};
+ my %is_group = map { $_ => 1 } @$group_by;
+ my @non_grp = grep { !$is_group{$_} } keys %{$meta->{cols}};
+
+ my %temp_table;
+ foreach my $row ( @rows ) {
+ my $group_key
+ = @$group_by
+ ? '{' . join('}{', map { defined $_ ? $_ : '' } @{$row}{@$group_by}) . '}'
+ : '';
+ $temp_table{$group_key} ||= [];
+ push @{$temp_table{$group_key}}, $row;
+ }
+
+ # Crush the rows together...
+ my @new_rows;
+ foreach my $key ( sort keys %temp_table ) {
+ my $group = $temp_table{$key};
+ my %new_row;
+ @new_row{@$group_by} = @{$group->[0]}{@$group_by};
+ foreach my $col ( @non_grp ) {
+ my $agg = $meta->{cols}->{$col}->{agg} || 'first';
+ $new_row{$col} = $agg_funcs{$agg}->( map { $_->{$col} } @$group );
+ }
+ push @new_rows, \%new_row;
+ }
+ return @new_rows;
+}
+
# set_to_tbl {{{3
# Unifies all the work of filtering, sorting etc. Alters the input.
+# TODO: pull all the little pieces out into subroutines and stick events in each of them.
sub set_to_tbl {
my ( $rows, $tbl ) = @_;
my $meta = $tbl_meta{$tbl} or die "No such table $tbl in tbl_meta";
- # Apply filters.
- foreach my $filter ( @{$meta->{filters}} ) {
- eval {
- @$rows = grep { $filters{$filter}->{func}->($_) } @$rows;
- };
- if ( $EVAL_ERROR && $config{debug}->{val} ) {
- die $EVAL_ERROR;
+ if ( !$meta->{pivot} ) {
+
+ # Hook in event listeners
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_filter}} ) {
+ $listener->set_to_tbl_pre_filter($rows, $tbl);
}
- }
- if ( !$meta->{pivot} ) {
- # Sort.
- if ( @$rows && $meta->{sort_func} ) {
+ # Apply filters. Note that if the table is pivoted, filtering and sorting
+ # are applied later.
+ foreach my $filter ( @{$meta->{filters}} ) {
+ eval {
+ @$rows = grep { $filters{$filter}->{func}->($_) } @$rows;
+ };
+ if ( $EVAL_ERROR && $config{debug}->{val} ) {
+ die $EVAL_ERROR;
+ }
+ }
+
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_sort}} ) {
+ $listener->set_to_tbl_pre_sort($rows, $tbl);
+ }
+
+ # Sort. Note that if the table is pivoted, sorting might have the wrong
+ # columns and it could crash. This will only be an issue if it's possible
+ # to toggle pivoting on and off, which it's not at the moment.
+ if ( @$rows && $meta->{sort_func} && !$meta->{aggregate} ) {
if ( $meta->{sort_dir} > 0 ) {
@$rows = $meta->{sort_func}->( @$rows );
}
@@ -4125,11 +4468,38 @@
@$rows = reverse $meta->{sort_func}->( @$rows );
}
}
+
}
# Stop altering arguments now.
my @rows = @$rows;
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_group}} ) {
+ $listener->set_to_tbl_pre_group(\@rows, $tbl);
+ }
+
+ # Apply group-by.
+ if ( $meta->{aggregate} ) {
+ @rows = apply_group_by($tbl, $meta->{group_by}, @rows);
+
+ # Sort. Note that if the table is pivoted, sorting might have the wrong
+ # columns and it could crash. This will only be an issue if it's possible
+ # to toggle pivoting on and off, which it's not at the moment.
+ if ( @rows && $meta->{sort_func} ) {
+ if ( $meta->{sort_dir} > 0 ) {
+ @rows = $meta->{sort_func}->( @rows );
+ }
+ else {
+ @rows = reverse $meta->{sort_func}->( @rows );
+ }
+ }
+
+ }
+
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_colorize}} ) {
+ $listener->set_to_tbl_pre_colorize(\@rows, $tbl);
+ }
+
if ( !$meta->{pivot} ) {
# Colorize. Adds a _color column to rows.
if ( @rows && $meta->{color_func} ) {
@@ -4144,6 +4514,10 @@
}
}
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_transform}} ) {
+ $listener->set_to_tbl_pre_transform(\@rows, $tbl);
+ }
+
# Apply_transformations.
if ( @rows ) {
my $cols = $meta->{cols};
@@ -4160,6 +4534,11 @@
# Pivot.
if ( $meta->{pivot} ) {
+
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_pivot}} ) {
+ $listener->set_to_tbl_pre_pivot(\@rows, $tbl);
+ }
+
my @vars = @{$meta->{visible}};
my @tmp = map { { name => $_ } } @vars;
my @cols = 'name';
@@ -4170,19 +4549,68 @@
$tmp[$j]->{$col} = $rows[$i]->{$vars[$j]};
}
}
- $fmt_meta = { map { $_ => { hdr => $_, just => '-'} } @cols };
+ $fmt_meta = { map { $_ => { hdr => $_, just => '-' } } @cols };
$fmt_cols = \@cols;
@rows = @tmp;
+
+ # Hook in event listeners
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_filter}} ) {
+ $listener->set_to_tbl_pre_filter($rows, $tbl);
+ }
+
+ # Apply filters.
+ foreach my $filter ( @{$meta->{filters}} ) {
+ eval {
+ @rows = grep { $filters{$filter}->{func}->($_) } @rows;
+ };
+ if ( $EVAL_ERROR && $config{debug}->{val} ) {
+ die $EVAL_ERROR;
+ }
+ }
+
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_sort}} ) {
+ $listener->set_to_tbl_pre_sort($rows, $tbl);
+ }
+
+ # Sort.
+ if ( @rows && $meta->{sort_func} ) {
+ if ( $meta->{sort_dir} > 0 ) {
+ @rows = $meta->{sort_func}->( @rows );
+ }
+ else {
+ @rows = reverse $meta->{sort_func}->( @rows );
+ }
+ }
+
}
else {
- $fmt_meta = $meta->{cols};
- $fmt_cols = $meta->{visible};
+ # If the table isn't pivoted, just show all columns that are supposed to
+ # be shown; but eliminate aggonly columns if the table isn't aggregated.
+ my $aggregated = $meta->{aggregate};
+ $fmt_cols = [ grep { $aggregated || !$meta->{cols}->{$_}->{aggonly} } @{$meta->{visible}} ];
+ $fmt_meta = { map { $_ => $meta->{cols}->{$_} } @$fmt_cols };
+
+ # If the table is aggregated, re-order the group_by columns to the left of
+ # the display.
+ if ( $aggregated ) {
+ my %is_group = map { $_ => 1 } @{$meta->{group_by}};
+ $fmt_cols = [ @{$meta->{group_by}}, grep { !$is_group{$_} } @$fmt_cols ];
+ }
}
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_create}} ) {
+ $listener->set_to_tbl_pre_create(\@rows, $tbl);
+ }
+
@rows = create_table( $fmt_cols, $fmt_meta, \@rows);
if ( !$meta->{hide_caption} && !$opts{n} && $config{display_table_captions}->{val} ) {
@rows = create_caption($meta->{capt}, @rows)
}
+
+ foreach my $listener ( @{$event_listener_for{set_to_tbl_post_create}} ) {
+ $listener->set_to_tbl_post_create(\@rows, $tbl);
+ }
+
return @rows;
}
@@ -4194,7 +4622,6 @@
return \%labels;
}
-
# commify {{{3
# From perlfaq5: add commas.
sub commify {
@@ -4274,23 +4701,48 @@
}
# make_sort_func {{{3
-# Accepts a list of sort columns, like "+cxn -time" and returns a subroutine that will
-# sort that way.
+# Gets a list of sort columns from the table, like "+cxn -time" and returns a
+# subroutine that will sort that way.
sub make_sort_func {
my ( $tbl ) = @_;
my @criteria;
- foreach my $col ( split(/\s+/, $tbl->{sort_cols} ) ) {
- next unless $col;
- my ( $dir, $name ) = $col =~ m/([+-])?(\w+)$/;
- next unless $name && $tbl->{cols}->{$name};
- $dir ||= '+';
- my $op = $tbl->{cols}->{$name}->{num} ? "<=>" : "cmp";
- my $df = $tbl->{cols}->{$name}->{num} ? "0" : "''";
- push @criteria,
- $dir eq '+'
- ? "(\$a->{$name} || $df) $op (\$b->{$name} || $df)"
- : "(\$b->{$name} || $df) $op (\$a->{$name} || $df)";
+
+ # Pivoted tables can be sorted by 'name' and set_x columns; others must be
+ # sorted by existing columns. TODO: this will crash if you toggle between
+ # pivoted and nonpivoted. I have several other 'crash' notes about this if
+ # this ever becomes possible.
+
+ if ( $tbl->{pivot} ) {
+ # Sort type is not really possible on pivoted columns, because a 'column'
+ # contains data from an entire non-pivoted row, so there could be a mix of
+ # numeric and non-numeric data. Thus everything has to be 'cmp' type.
+ foreach my $col ( split(/\s+/, $tbl->{sort_cols} ) ) {
+ next unless $col;
+ my ( $dir, $name ) = $col =~ m/([+-])?(\w+)$/;
+ next unless $name && $name =~ m/^(?:name|set_\d+)$/;
+ $dir ||= '+';
+ my $op = 'cmp';
+ my $df = "''";
+ push @criteria,
+ $dir eq '+'
+ ? "(\$a->{$name} || $df) $op (\$b->{$name} || $df)"
+ : "(\$b->{$name} || $df) $op (\$a->{$name} || $df)";
+ }
}
+ else {
+ foreach my $col ( split(/\s+/, $tbl->{sort_cols} ) ) {
+ next unless $col;
+ my ( $dir, $name ) = $col =~ m/([+-])?(\w+)$/;
+ next unless $name && $tbl->{cols}->{$name};
+ $dir ||= '+';
+ my $op = $tbl->{cols}->{$name}->{num} ? "<=>" : "cmp";
+ my $df = $tbl->{cols}->{$name}->{num} ? "0" : "''";
+ push @criteria,
+ $dir eq '+'
+ ? "(\$a->{$name} || $df) $op (\$b->{$name} || $df)"
+ : "(\$b->{$name} || $df) $op (\$a->{$name} || $df)";
+ }
+ }
return sub { return @_ } unless @criteria;
my $sub = eval 'sub { sort {' . join("||", @criteria) . '} @_; }';
die if $EVAL_ERROR;
@@ -4383,7 +4835,7 @@
my ( $text, $width) = @_;
$width ||= $this_term_size[0];
$text =~ s/(.{0,$width})(?:\s+|$)/$1\n/g;
- $text =~ s/\s+$//;
+ $text =~ s/ +$//mg;
return $text;
}
@@ -4397,7 +4849,13 @@
if ( !$opts{n} && $config{show_statusbar}->{val} ) {
unshift @$display_lines, create_statusbar();
}
- $clear_screen_sub->() unless $modes{$config{mode}->{val}}->{no_clear_screen};
+
+ foreach my $listener ( @{$event_listener_for{draw_screen}} ) {
+ $listener->draw_screen($display_lines);
+ }
+
+ $clear_screen_sub->()
+ if $prefs->{clear} || !$modes{$config{mode}->{val}}->{no_clear_screen};
if ( $opts{n} || $prefs->{raw} ) {
my $num_lines = 0;
print join("\n",
@@ -4540,7 +4998,7 @@
$cxn);
}
- return [ $result, 'bold reverse' ];
+ return $config{color}->{val} ? [ $result, 'bold reverse' ] : $result;
}
# Database connections {{{3
@@ -4671,6 +5129,9 @@
# Get a list of connection names used in this mode.
sub get_connections {
+ if ( $file ) {
+ return qw(file);
+ }
my $mode = shift || $config{mode}->{val};
my @connections = $modes{$mode}->{server_group}
? @{$server_groups{$modes{$mode}->{server_group}}}
@@ -4725,6 +5186,8 @@
sub do_stmt {
my ( $cxn, $stmt_name, @args ) = @_;
+ return undef if $file;
+
# Test if the cxn should not even be tried
return undef if $dbhs{$cxn}
&& $dbhs{$cxn}->{err_count}
@@ -4804,6 +5267,8 @@
sub do_query {
my ( $cxn, $query ) = @_;
+ return undef if $file;
+
# Test if the cxn should not even be tried
return undef if $dbhs{$cxn}
&& $dbhs{$cxn}->{err_count}
@@ -4839,6 +5304,13 @@
return $sth;
}
+sub get_uptime {
+ my ( $cxn ) = @_;
+ $dbhs{$cxn}->{start_time} ||= time();
+ # Avoid dividing by zero
+ return (time() - $dbhs{$cxn}->{start_time}) || .001;
+}
+
sub connect_to_db {
my ( $cxn ) = @_;
@@ -4888,7 +5360,7 @@
my $vars = $vars{$cxn}->{$clock};
my %res = map { $_ =~ s/ +/_/g; $_ } $dbhs{$cxn}->{dbh}->{mysql_stat} =~ m/(\w[^:]+): ([\d\.]+)/g;
map { $vars->{$_} ||= $res{$_} } keys %res;
- $vars->{Uptime_hires} ||= time() - $dbhs{$cxn}->{start_time};
+ $vars->{Uptime_hires} ||= get_uptime($cxn);
$vars->{cxn} = $cxn;
}
}
@@ -4896,6 +5368,10 @@
sub get_new_db_connection {
my ( $connection, $destroy ) = @_;
+ if ( $file ) {
+ die "You can't connect to a MySQL server while monitoring a file. This is probably a bug.";
+ }
+
my $dsn = $connections{$connection}
or die "No connection named '$connection' is defined in your configuration";
@@ -5050,9 +5526,36 @@
# load_config {{{3
sub load_config {
- my $filename = $opts{c} || "$homepath/.innotop";
+ my $filename = $opts{c} || "$homepath/.innotop/innotop.ini";
+ my $dirname = dirname($filename);
+ if ( -f $dirname && !$opts{c} ) {
+ # innotop got upgraded and this is the old config file.
+ my $answer = pause("Innotop's default config location has moved to $filename. Move old config file $dirname there now? y/n");
+ if ( lc $answer eq 'y' ) {
+ rename($dirname, "$homepath/innotop.ini")
+ or die "Can't rename '$dirname': $OS_ERROR";
+ mkdir($dirname) or die "Can't create directory '$dirname': $OS_ERROR";
+ mkdir("$dirname/plugins") or die "Can't create directory '$dirname/plugins': $OS_ERROR";
+ rename("$homepath/innotop.ini", $filename)
+ or die "Can't rename '$homepath/innotop.ini' to '$filename': $OS_ERROR";
+ }
+ else {
+ print "\nInnotop will now exit so you can fix the config file.\n";
+ exit(0);
+ }
+ }
+
+ if ( ! -d $dirname ) {
+ mkdir $dirname
+ or die "Can't create directory '$dirname': $OS_ERROR";
+ }
+ if ( ! -d "$dirname/plugins" ) {
+ mkdir "$dirname/plugins"
+ or die "Can't create directory '$dirname/plugins': $OS_ERROR";
+ }
+
if ( -f $filename ) {
- open my $file, "<", $filename or die("Can't open $filename: $OS_ERROR");
+ open my $file, "<", $filename or die("Can't open '$filename': $OS_ERROR");
# Check config file version. Just ignore if either innotop or the file has
# garbage in the version number.
@@ -5115,6 +5618,78 @@
}
}
+# load_config_plugins {{{3
+sub load_config_plugins {
+ my ( $file ) = @_;
+
+ # First, find a list of all plugins that exist on disk, and get information about them.
+ my $dir = $config{plugin_dir}->{val};
+ foreach my $p_file ( <$dir/*.pm> ) {
+ my ($package, $desc);
+ eval {
+ open my $p_in, "<", $p_file or die $OS_ERROR;
+ while ( my $line = <$p_in> ) {
+ chomp $line;
+ if ( $line =~ m/^package\s+(.*?);/ ) {
+ $package = $1;
+ }
+ elsif ( $line =~ m/^# description: (.*)/ ) {
+ $desc = $1;
+ }
+ last if $package && $desc;
+ }
+ close $p_in;
+ };
+ if ( $package ) {
+ $plugins{$package} = {
+ file => $p_file,
+ desc => $desc,
+ class => $package,
+ active => 0,
+ };
+ if ( $config{debug}->{val} && $EVAL_ERROR ) {
+ die $EVAL_ERROR;
+ }
+ }
+ }
+
+ # Now read which ones the user has activated. Each line simply represents an active plugin.
+ while ( my $line = <$file> ) {
+ chomp $line;
+ next if $line =~ m/^#/;
+ last if $line =~ m/^\[/;
+ next unless $line && $plugins{$line};
+
+ my $obj;
+ eval {
+ require $plugins{$line}->{file};
+ $obj = $line->new(%pluggable_vars);
+ foreach my $event ( $obj->register_for_events() ) {
+ my $queue = $event_listener_for{$event};
+ if ( $queue ) {
+ push @$queue, $obj;
+ }
+ }
+ };
+ if ( $config{debug}->{val} && $EVAL_ERROR ) {
+ die $EVAL_ERROR;
+ }
+ if ( $obj ) {
+ $plugins{$line}->{active} = 1;
+ $plugins{$line}->{object} = $obj;
+ }
+ }
+}
+
+# save_config_plugins {{{3
+sub save_config_plugins {
+ my $file = shift;
+ foreach my $class ( sort keys %plugins ) {
+ next unless $plugins{$class}->{active};
+ print $file "$class\n";
+ }
+}
+
# load_config_active_server_groups {{{3
sub load_config_active_server_groups {
my ( $file ) = @_;
@@ -5188,6 +5763,33 @@
}
}
+# load_config_group_by {{{3
+sub load_config_group_by {
+ my ( $file ) = @_;
+ while ( my $line = <$file> ) {
+ chomp $line;
+ next if $line =~ m/^#/;
+ last if $line =~ m/^\[/;
+
+ my ( $tbl , $rest ) = $line =~ m/^(.*?)=(.*)$/;
+ next unless $tbl && exists $tbl_meta{$tbl};
+ my @parts = unique(grep { exists($tbl_meta{$tbl}->{cols}->{$_}) } split(/\s+/, $rest));
+ $tbl_meta{$tbl}->{group_by} = [ @parts ];
+ $tbl_meta{$tbl}->{cust}->{group_by} = 1;
+ }
+}
+
+# save_config_group_by {{{3
+sub save_config_group_by {
+ my $file = shift;
+ foreach my $tbl ( sort keys %tbl_meta ) {
+ next if $tbl_meta{$tbl}->{temp};
+ next unless $tbl_meta{$tbl}->{cust}->{group_by};
+ my $aref = $tbl_meta{$tbl}->{group_by};
+ print $file "$tbl=", join(' ', @$aref), "\n";
+ }
+}
+
# load_config_filters {{{3
sub load_config_filters {
my ( $file ) = @_;
@@ -5480,7 +6082,7 @@
sub save_config {
return if $config{readonly}->{val};
# Save to a temp file first, so a crash doesn't destroy the main config file
- my $newname = $opts{c} || "$homepath/.innotop";
+ my $newname = $opts{c} || "$homepath/.innotop/innotop.ini";
my $filename = $newname . '_tmp';
open my $file, "+>", $filename
or die("Can't write to $filename: $OS_ERROR");
@@ -5774,7 +6376,16 @@
()
);
my ( $col, $text ) = split(/\s+/, $response, 2);
- return unless $col && $text && exists($tbl_meta{$tbl}->{cols}->{$col});
+
+ # You can't filter on a nonexistent column. But if you filter on a pivoted
+ # table, the columns are different, so on a pivoted table, allow filtering
+ # on the 'name' column.
+ # NOTE: if a table is pivoted and un-pivoted, this will likely cause crashes.
+ # Currently not an issue since there's no way to toggle pivot/nopivot.
+ return unless $col && $text &&
+ (exists($tbl_meta{$tbl}->{cols}->{$col})
+ || ($tbl_meta{$tbl}->{pivot} && $col eq 'name'));
+
my ( $sub, $err ) = compile_filter( "defined \$set->{$col} && \$set->{$col} =~ m/$text/" );
return if !$sub || $err;
my $name = "quick_$tbl.$col";
@@ -5807,6 +6418,62 @@
}
}
+sub edit_plugins {
+ $clear_screen_sub->();
+
+ my @cols = ('', qw(class desc active));
+ my $info = { map { $_ => { hdr => $_, just => '-', } } @cols };
+ my @rows = map { $plugins{$_} } sort keys %plugins;
+ my $key;
+ my $selected;
+
+ # This loop builds a tabular view of the plugins.
+ do {
+
+ # Show help
+ if ( $key && $key eq '?' ) {
+ my @display_lines = '';
+ push @display_lines, create_caption('Editor key mappings',
+ create_table2(
+ [ sort keys %plugin_editor_action ],
+ { map { $_ => $_ } keys %plugin_editor_action },
+ { map { $_ => $plugin_editor_action{$_}->{note} } keys %plugin_editor_action },
+ { sep => ' ' }));
+ draw_screen(\@display_lines);
+ pause();
+ $key = '';
+ }
+
+ # Do the action specified
+ else {
+ $selected ||= 0;
+ if ( $key && $plugin_editor_action{$key} ) {
+ $selected = $plugin_editor_action{$key}->{func}->(\@rows, $selected);
+ $selected ||= 0;
+ }
+
+ # Build the table of plugins.
+ foreach my $row ( 0.. $#rows ) {
+ $rows[$row]->{''} = $row eq $selected ? '>' : ' ';
+ }
+ my @display_lines = create_table(\@cols, $info, \@rows);
+
+ # Highlight selected entry
+ for my $i ( 0 .. $#display_lines ) {
+ if ( $display_lines[$i] =~ m/^>/ ) {
+ $display_lines[$i] = [ $display_lines[$i], 'reverse' ];
+ }
+ }
+
+ # Draw the screen and wait for a command.
+ unshift @display_lines, '',
+ "Plugin Management. Press ? for help, q to quit.", '';
+ draw_screen(\@display_lines);
+ $key = pause('');
+ }
+ } while ( $key ne 'q' );
+}
+
# edit_table {{{3
sub edit_table {
$clear_screen_sub->();
@@ -5869,7 +6536,7 @@
# Draw the screen and wait for a command.
unshift @display_lines, '',
"Editing table definition for $meta->{capt}. Press ? for help, q to quit.", '';
- draw_screen(\@display_lines);
+ draw_screen(\@display_lines, { clear => 1 });
$key = pause('');
}
} while ( $key ne 'q' );
@@ -5911,6 +6578,14 @@
return $tbl;
}
+sub toggle_aggregate {
+ my ( $tbl ) = @_;
+ $tbl ||= choose_visible_table();
+ return unless $tbl && exists $tbl_meta{$tbl};
+ my $meta = $tbl_meta{$tbl};
+ $meta->{aggregate} ^= 1;
+}
+
sub choose_filters {
my ( $tbl ) = @_;
$tbl ||= choose_visible_table();
@@ -5945,17 +6620,46 @@
$meta->{cust}->{filters} = 1;
}
+sub choose_group_cols {
+ my ( $tbl ) = @_;
+ $tbl ||= choose_visible_table();
+ return unless $tbl && exists $tbl_meta{$tbl};
+ $clear_screen_sub->();
+ my $meta = $tbl_meta{$tbl};
+ my $curr = join(', ', @{$meta->{group_by}});
+ my $val = prompt_list(
+ 'Group-by columns',
+ $curr,
+ sub { return keys %{$meta->{cols}} },
+ { map { $_ => $meta->{cols}->{$_}->{label} } keys %{$meta->{cols}} });
+ if ( $curr ne $val ) {
+ $meta->{group_by} = [ grep { exists $meta->{cols}->{$_} } $val =~ m/(\w+)/g ];
+ $meta->{cust}->{group_by} = 1;
+ }
+}
+
sub choose_sort_cols {
my ( $tbl ) = @_;
$tbl ||= choose_visible_table();
return unless $tbl && exists $tbl_meta{$tbl};
$clear_screen_sub->();
my $meta = $tbl_meta{$tbl};
+
+ my ( $cols, $hints );
+ if ( $meta->{pivot} ) {
+ $cols = sub { qw(name set_0) };
+ $hints = { name => 'name', set_0 => 'set_0' };
+ }
+ else {
+ $cols = sub { return keys %{$meta->{cols}} };
+ $hints = { map { $_ => $meta->{cols}->{$_}->{label} } keys %{$meta->{cols}} };
+ }
+
my $val = prompt_list(
'Sort columns (reverse sort with -col)',
$meta->{sort_cols},
- sub { return keys %{$meta->{cols}} },
- { map { $_ => $meta->{cols}->{$_}->{label} } keys %{$meta->{cols}} });
+ $cols,
+ $hints );
if ( $meta->{sort_cols} ne $val ) {
$meta->{sort_cols} = $val;
$meta->{cust}->{sort_cols} = 1;
@@ -6061,21 +6765,6 @@
$clear_screen_sub->();
}
-# get_file {{{3
-sub get_file {
- my $filename = shift;
- open my $file, "<", "$filename" or die "Can't open $filename: $!";
- my $file_contents = do { local $/; <$file>; };
- close $file;
- return $file_contents;
-}
-
-# filename {{{3
-sub filename {
- ( my $filename = shift ) =~ s#^.*[/\\]##;
- return $filename;
-}
-
# Online configuration and prompting functions {{{2
# edit_stmt_sleep_times {{{3
@@ -6209,7 +6898,7 @@
# Calculate hi-res uptime and add cxn to the hash. This duplicates get_driver_status,
# but it's most important to have consistency.
- $vars->{Uptime_hires} ||= time() - $dbhs{$cxn}->{start_time};
+ $vars->{Uptime_hires} ||= get_uptime($cxn);
$vars->{cxn} = $cxn;
# Add SHOW VARIABLES to the hash
@@ -6247,7 +6936,17 @@
# Find out which thread to do.
my $info;
if ( @candidates > 1 ) {
- my @threads = sort map { $_->{id} } @candidates;
+
+ # Sort longest-active first, then longest-idle.
+ my $sort_func = sub {
+ my ( $a, $b ) = @_;
+ return $a->{query} && !$b->{query} ? 1
+ : $b->{query} && !$a->{query} ? -1
+ : ($a->{time} || 0) <=> ($b->{time} || 0);
+ };
+ my @threads = map { $_->{id} } reverse sort { $sort_func->($a, $b) } @candidates;
+
+ print "\n";
my $thread = prompt_list($prompt,
$threads[0],
sub { return @threads });
@@ -6315,6 +7014,12 @@
# TODO: there are a few places that don't remember prev set so can't pass it.
sub extract_values {
my ( $set, $cur, $pre, $tbl ) = @_;
+
+ # Hook in event listeners
+ foreach my $listener ( @{$event_listener_for{extract_values}} ) {
+ $listener->extract_values($set, $cur, $pre, $tbl);
+ }
+
my $result = {};
my $meta = $tbl_meta{$tbl};
my $cols = $meta->{cols};
@@ -6377,8 +7082,39 @@
}
foreach my $cxn ( @$cxns ) {
- my $stmt = do_stmt($cxn, 'INNODB_STATUS') or next;
- my $innodb_status_text = $stmt->fetchrow_hashref()->{status};
+ my $innodb_status_text;
+
+ if ( $file ) { # Try to fetch status text from the file.
+ my @stat = stat($file);
+
+ # Initialize the file.
+ if ( !$file_mtime ) {
+ # Initialize to 130k from the end of the file (because the limit
+ # on the size of innodb status is 128k even with Google's patches)
+ # and try to grab the last status from the file.
+ sysseek($file, (-128 * 1_024), 2);
+ }
+
+ # Read from the file.
+ my $buffer;
+ if ( !$file_mtime || $file_mtime != $stat[9] ) {
+ $file_data = '';
+ while ( sysread($file, $buffer, 4096) ) {
+ $file_data .= $buffer;
+ }
+ $file_mtime = $stat[9];
+ }
+
+ # Delete everything but the last InnoDB status text from the file.
+ $file_data =~ s/\A.*(?=^=====================================\n...... ........ INNODB MONITOR OUTPUT)//ms;
+ $innodb_status_text = $file_data;
+ }
+
+ else {
+ my $stmt = do_stmt($cxn, 'INNODB_STATUS') or next;
+ $innodb_status_text = $stmt->fetchrow_hashref()->{status};
+ }
+
next unless $innodb_status_text
&& substr($innodb_status_text, 0, 100) =~ m/INNODB MONITOR OUTPUT/;
@@ -6400,7 +7136,7 @@
my $hash = $vars{$cxn}->{$clock};
@{$hash}{ keys %innodb_status } = values %innodb_status;
$hash->{cxn} = $cxn;
- $hash->{Uptime_hires} ||= time() - $dbhs{$cxn}->{start_time};
+ $hash->{Uptime_hires} ||= get_uptime($cxn);
}
}
}
@@ -6478,7 +7214,7 @@
$stmt = do_stmt($cxn, 'SHOW_SLAVE_STATUS') or next;
$res = $stmt->fetchall_arrayref({})->[0];
@{$vars}{ keys %$res } = values %$res;
- $vars->{Uptime_hires} ||= time() - $dbhs{$cxn}->{start_time};
+ $vars->{Uptime_hires} ||= get_uptime($cxn);
}
}
}
@@ -6500,6 +7236,20 @@
innotop - MySQL and InnoDB transaction/status monitor.
+=head1 SYNOPSIS
+
+To monitor servers normally:
+
+ innotop
+
+To monitor InnoDB status information from a file:
+
+ innotop /var/log/mysql/mysqld.err
+
+To run innotop non-interactively in a pipe-and-filter configuration:
+
+ innotop --count 5 -d 1 -n
+
=head1 DESCRIPTION
innotop monitors MySQL servers. Each of its modes shows you a different aspect
@@ -6507,7 +7257,7 @@
replication, one for queries, and one for transactions. innotop refreshes its
data periodically, so you see an updating view.
-innotop has many features for power users, but you can start and run it with
+innotop has lots of features for power users, but you can start and run it with
virtually no configuration. If you're just getting started, see
L<"QUICK-START">. Press '?' at any time while running innotop for
context-sensitive help.
@@ -6525,6 +7275,10 @@
will prompt you for a DSN (data source name). You should be able to just accept
the defaults by pressing Enter.
+When innotop asks you about a table to use when resetting InnoDB deadlock
+information, just accept the default for now. This is an advanced feature you
+can configure later (see L<"D: InnoDB Deadlocks"> for more).
+
If you have a .my.cnf file with your MySQL connection defaults, innotop can read
it, and you won't need to specify a username and password if it's in that file.
Otherwise, you should answer 'y' to the next couple of prompts.
@@ -6561,8 +7315,13 @@
=head1 OPTIONS
+innotop is mostly configured via its configuration file, but some of the
+configuration options can come from the command line. You can also specify a
+file to monitor for InnoDB status output; see L<"MONITORING A FILE"> for more
+details.
+
You can negate some options by prefixing the option name with --no. For
-example, --noinc negates L<"--inc">.
+example, --noinc (or --no-inc) negates L<"--inc">.
=over
@@ -6570,6 +7329,11 @@
Print a summary of command-line usage and exit.
+=item --color
+
+Enable or disable terminal coloring. Corresponds to the L<"color"> config file
+setting.
+
=item --config
Specifies a configuration file to read. This option is non-sticky, that is to
@@ -6648,6 +7412,37 @@
This mode contains the L<"buffer_pool">, L<"page_statistics">,
L<"insert_buffers">, and L<"adaptive_hash_index"> tables by default.
+=item C: Command Summary
+
+This mode is similar to mytop's Command Summary mode. It shows the
+L<"cmd_summary"> table, which looks something like the following:
+
+ Command Summary (? for help) localhost, 25+07:16:43, 2.45 QPS, 3 thd, 5.0.40
+ _____________________ Command Summary _____________________
+ Name Value Pct Last Incr Pct
+ Select_scan 3244858 69.89% 2 100.00%
+ Select_range 1354177 29.17% 0 0.00%
+ Select_full_join 39479 0.85% 0 0.00%
+ Select_full_range_join 4097 0.09% 0 0.00%
+ Select_range_check 0 0.00% 0 0.00%
+
+The command summary table is built by extracting variables from
+L<"STATUS_VARIABLES">. The variables must be numeric and must match the prefix
+given by the L<"cmd_filter"> configuration variable. The variables are then
+sorted by value descending and compared to the last variable, as shown above.
+The percentage columns are percentage of the total of all variables in the
+table, so you can see the relative weight of the variables.
+
+The example shows what you see if the prefix is "Select_". The default
+prefix is "Com_". You can choose a prefix with the 's' key.
+
+It's rather like running SHOW VARIABLES LIKE "prefix%" with memory and
+nice formatting.
+
+Values are aggregated across all servers. The Pct columns are not correctly
+aggregated across multiple servers. This is a known limitation of the grouping
+algorithm that may be fixed in the future.
+
=item D: InnoDB Deadlocks
This mode shows the transactions involved in the last InnoDB deadlock. A second
@@ -6694,6 +7489,50 @@
file I/O miscellaneous, and log statistics. It displays the L<"io_threads">,
L<"pending_io">, L<"file_io_misc">, and L<"log_statistics"> tables by default.
+=item L: Locks
+
+This mode shows information about current locks. At the moment only InnoDB
+locks are supported, and by default you'll only see locks for which transactions
+are waiting. This information comes from the TRANSACTIONS section of the InnoDB
+status text. If you have a very busy server, you may have frequent lock waits;
+it helps to be able to see which tables and indexes are the "hot spot" for
+locks. If your server is running pretty well, this mode should show nothing.
+
+You can configure MySQL and innotop to monitor not only locks for which a
+transaction is waiting, but those currently held, too. You can do this with the
+InnoDB Lock Monitor (L<http://dev.mysql.com/doc/en/innodb-monitor.html>). It's
+not documented in the MySQL manual, but creating the lock monitor with the
+following statement also affects the output of SHOW INNODB STATUS, which innotop
+uses:
+
+ CREATE TABLE innodb_lock_monitor(a int) ENGINE=INNODB;
+
+This causes InnoDB to print its output to the MySQL file every 16 seconds or so,
+as stated in the manual, but it also makes the normal SHOW INNODB STATUS output
+include lock information, which innotop can parse and display (that's the
+undocumented feature).
+
+This means you can do what may have seemed impossible: to a limited extent
+(InnoDB truncates some information in the output), you can see which transaction
+holds the locks something else is waiting for. You can also enable and disable
+the InnoDB Lock Monitor with the key mappings in this mode.
+
+This mode displays the L<"innodb_locks"> table by default. Here's a sample of
+the screen when one connection is waiting for locks another connection holds:
+
+ _________________________________ InnoDB Locks __________________________
+ CXN ID Type Waiting Wait Active Mode DB Table Index
+ localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY
+ localhost 12 TABLE 0 00:10 00:10 IX test t1
+ localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY
+ localhost 11 TABLE 0 00:00 00:25 IX test t1
+ localhost 11 RECORD 0 00:00 00:25 X test t1 PRIMARY
+
+You can see the first connection, ID 12, is waiting for a lock on the PRIMARY
+key on test.t1, and has been waiting for 10 seconds. The second connection
+isn't waiting, because the Waiting column is 0, but it holds locks on the same
+index. That tells you connection 11 is blocking connection 12.
+
=item M: Master/Slave Replication Status
This mode shows the output of SHOW SLAVE STATUS and SHOW MASTER STATUS in three
@@ -6768,7 +7607,8 @@
format. This mode is the reason I wrote innotop.
You can kill queries or processes with the 'k' and 'x' keys, and EXPLAIN a query
-with the 'e' or 'f' keys.
+with the 'e' or 'f' keys. InnoDB doesn't print the full query in transactions,
+so explaining may not work right if the query is truncated.
The informational header can be toggled on and off with the 'h' key. By
default, innotop hides inactive transactions and its own transaction. You can
@@ -6777,21 +7617,6 @@
This mode displays the L<"t_header"> and L<"innodb_transactions"> tables by
default.
-=item W: InnoDB Lock Waits
-
-This mode shows information about current InnoDB lock waits. This information
-comes from the TRANSACTIONS section of the InnoDB status text. If you have a
-very busy server, you may have frequent lock waits; it helps to be able to see
-which tables and indexes are the "hot spot" for locks. If your server is
-running pretty well, this mode should show nothing.
-
-A second table shows any waits in the OS wait array. This comes from a
-different section of the status text. If you see frequent waits, your server is
-probably running under a high concurrency workload. This is the same table
-displayed in R mode.
-
-This mode displays the L<"lock_waits"> and L<"wait_array"> tables by default.
-
=back
=head1 INNOTOP STATUS
@@ -6837,6 +7662,15 @@
See L<"ERROR HANDLING"> for more details about innotop's error handling.
+=head2 MONITORING A FILE
+
+If you give a filename on the command line, innotop will not connect to ANY
+servers at all. It will watch the specified file for InnoDB status output and
+use that as its data source. It will always show a single connection called
+'file'. And since it can't connect to a server, it can't determine how long the
+server it's monitoring has been up; so it calculates the server's uptime as time
+since innotop started running.
+
=head1 SERVER ADMINISTRATION
While innotop is primarily a monitor that lets you watch and analyze your
@@ -6848,6 +7682,7 @@
Press 'k' to issue a KILL command, or 'x' to issue a KILL QUERY command.
innotop will prompt you for the server and/or connection ID to kill (innotop
does not prompt you if there is only one possible choice for any input).
+innotop pre-selects the longest-running query, or the oldest connection.
Confirm the command with 'y'.
In L<"M: Master/Slave Replication Status"> mode, you can start and stop slaves
@@ -7106,6 +7941,10 @@
Starts the row-coloring rules editor on one of the displayed table(s). See
L<"COLORS"> for details.
+=item p: Manage Plugins
+
+Starts the plugin configuration editor. See L<"PLUGINS"> for details.
+
=item s: Server Groups
Lets you create and edit server groups. See L<"SERVER GROUPS">.
@@ -7187,6 +8026,14 @@
considers every character a control character, which can be useful for
collapsing ALL text fields in queries.
+=item cmd_filter
+
+This is the prefix that filters variables in L<"C: Command Summary"> mode.
+
+=item color
+
+Whether terminal coloring is permitted.
+
=item cxn_timeout
On MySQL versions 4.0.3 and newer, this variable is used to set the connection's
@@ -7265,6 +8112,11 @@
keeps in its memory, so the larger this variable is, the more memory innotop
uses.
+=item plugin_dir
+
+Specifies where plugins can be found. By default, innotop stores plugins in the
+'plugins' subdirectory of your innotop configuration directory.
+
=item readonly
Whether the configuration file is readonly. This cannot be set interactively,
@@ -7305,6 +8157,11 @@
=back
+=item plugins
+
+This section holds a list of package names of active plugins. If the plugin
+exists, innotop will activate it. See L<"PLUGINS"> for more information.
+
=item filters
This section holds user-defined filters (see L<"FILTERS">). Each line is in the
@@ -7385,6 +8242,11 @@
This section contains statement sleep times. Each line is in the format
statement_name=sleep_time. See L<"S: Statement Sleep Times">.
+=item group_by
+
+This section contains column lists for table group_by expressions. Each line is
+in the format tbl_name=column_list. See L<"GROUPING">.
+
=back
=head1 CUSTOMIZING
@@ -7475,20 +8337,24 @@
=item *
-innotop sorts the rows, unless they are to be pivoted. See L<"SORTING">.
+innotop sorts the rows. See L<"SORTING">.
=item *
-innotop colorizes the rows, again skipping this step if they are to be
-pivoted. See L<"COLORS">.
+innotop groups the rows together, if specified. See L<"GROUPING">.
=item *
+innotop colorizes the rows. See L<"COLORS">.
+
+=item *
+
innotop transforms the column values in each row. See L<"TRANSFORMATIONS">.
=item *
-innotop optionally pivots the rows (see L<"PIVOTING">).
+innotop optionally pivots the rows (see L<"PIVOTING">), then filters and sorts
+them.
=item *
@@ -7500,6 +8366,15 @@
=back
+The lifecycle is slightly different if the table is pivoted, as noted above. To
+clarify, if the table is pivoted, the process is extract, group, transform,
+pivot, filter, sort, create. If it's not pivoted, the process is extract,
+filter, sort, group, color, transform, create. This slightly convoluted process
+doesn't map all that well to SQL, but pivoting complicates things pretty
+thoroughly. Roughly speaking, filtering and sorting happen as late as needed to
+effect the final result as you might expect, but as early as possible for
+efficiency.
+
Each built-in table is described below:
=over
@@ -7513,6 +8388,10 @@
Displays data about InnoDB's buffer pool. Data source: L<"STATUS_VARIABLES">.
+=item cmd_summary
+
+Displays weighted status variables. Data source: L<"STATUS_VARIABLES">.
+
=item deadlock_locks
Shows which locks were held and waited for by the last detected deadlock. Data
@@ -7537,6 +8416,10 @@
Displays various data about InnoDB's last foreign key error. Data source:
L<"STATUS_VARIABLES">.
+=item innodb_locks
+
+Displays InnoDB locks. Data source: L<"INNODB_LOCKS">.
+
=item innodb_transactions
Displays data about InnoDB's current transactions. Data source:
@@ -7550,11 +8433,6 @@
Displays data about InnoDB's I/O threads. Data source: L<"IO_THREADS">.
-=item lock_waits
-
-Displays InnoDB lock waits, i.e. transactions which are waiting for a lock to be
-granted. Data source: L<"LOCK_WAITS">.
-
=item log_statistics
Displays data about InnoDB's logging system. Data source: L<"STATUS_VARIABLES">.
@@ -7671,6 +8549,20 @@
trans: a list of column transformations. See L<"TRANSFORMATIONS">.
+=item *
+
+agg: an aggregate function. See L<"GROUPING">. The default is L<"first">.
+
+=item *
+
+aggonly: controls whether the column only shows when grouping is enabled on the
+table (see L<"GROUPING">). By default, this is disabled. This means columns
+will always be shown by default, whether grouping is enabled or not. If a
+column's aggonly is set true, the column will appear when you toggle grouping on
+the table. Several columns are set this way, such as the count column on
+L<"processlist"> and L<"innodb_transactions">, so you don't see a count when the
+grouping isn't enabled, but you do when it is.
+
=back
=head2 FILTERS
@@ -7752,14 +8644,89 @@
Some modes have keys mapped to open this dialog directly, and to quickly reverse
sort direction. Press '?' as usual to see which keys are mapped in any mode.
+=head2 GROUPING
+
+innotop can group, or aggregate, rows together (I use the terms
+interchangeably). This is quite similar to an SQL GROUP BY clause. You can
+specify to group on certain columns, or if you don't specify any, the entire set
+of rows is treated as one group. This is quite like SQL so far, but unlike SQL,
+you can also select un-grouped columns. innotop actually aggregates every
+column. If you don't explicitly specify a grouping function, the default is
+'first'. This is basically a convenience so you don't have to specify an
+aggregate function for every column you want in the result.
+
+You can quickly toggle grouping on a table with the '=' key, which toggles its
+aggregate property. This property doesn't persist to the config file.
+
+The columns by which the table is grouped are specified in its group_by
+property. When you turn grouping on, innotop places the group_by columns at the
+far left of the table, even if they're not supposed to be visible. The rest of
+the visible columns appear in order after them.
+
+Two tables have default group_by lists and a count column built in:
+L<"processlist"> and L<"innodb_transactions">. The grouping is by connection
+and status, so you can quickly see how many queries or transactions are in a
+given status on each server you're monitoring. The time columns are aggregated
+as a sum; other columns are left at the default 'first' aggregation.
+
+By default, the table shown in L<"S: Variables & Status"> mode also uses
+grouping so you can monitor variables and status across many servers. The
+default aggregation function in this mode is 'avg'.
+
+Valid grouping functions are defined in the %agg_funcs hash. They include
+
+=over
+
+=item first
+
+Returns the first element in the group.
+
+=item count
+
+Returns the number of elements in the group, including undefined elements, much
+like SQL's COUNT(*).
+
+=item avg
+
+Returns the average of defined elements in the group.
+
+=item sum
+
+Returns the sum of elements in the group.
+
+=back
+
+Here's an example of grouping at work. Suppose you have a very busy server with
+hundreds of open connections, and you want to see how many connections are in
+what status. Using the built-in grouping rules, you can press 'Q' to enter
+L<"Q: Query List"> mode. Press '=' to toggle grouping (if necessary, select the
+L<"processlist"> table when prompted).
+
+Your display might now look like the following:
+
+ Query List (? for help) localhost, 32:33, 0.11 QPS, 1 thd, 5.0.38-log
+
+ CXN Cmd Cnt ID User Host Time Query
+ localhost Query 49 12933 webusr localhost 19:38 SELECT * FROM
+ localhost Sending Da 23 2383 webusr localhost 12:43 SELECT col1,
+ localhost Sleep 120 140 webusr localhost 5:18:12
+ localhost Statistics 12 19213 webusr localhost 01:19 SELECT * FROM
+
+That's actually quite a worrisome picture. You've got a lot of idle connections
+(Sleep), and some connections executing queries (Query and Sending Data).
+That's okay, but you also have a lot in Statistics status, collectively spending
+over a minute. That means the query optimizer is having a really hard time
+optimizing your statements. Something is wrong; it should normally take
+milliseconds to optimize queries. You might not have seen this pattern if you
+didn't look at your connections in aggregate. (This is a made-up example, but
+it can happen in real life).
+
=head2 PIVOTING
-innotop can pivot a table for more compact display, just like a Pivot Table in a
-spreadsheet (also known as a crosstab). This is used in L<"S: Variables &
-Status"> mode, for example.
+innotop can pivot a table for more compact display, similar to a Pivot Table in
+a spreadsheet (also known as a crosstab). Pivoting a table makes columns into
+rows. Assume you start with this table:
-Pivoting a table makes columns into rows. Assume you start with this table:
-
foo bar
=== ===
1 3
@@ -7772,10 +8739,8 @@
foo 1 2
bar 3 4
-This functionality is currently limited because it becomes tricky to pivot when
-innotop is displaying data from multiple connections, each with a 'foo' and
-'bar' value. In the future innotop will support some kind of aggregation,
-similar to SQL GROUP BY, to help solve this problem.
+To get reasonable results, you might need to group as well as pivoting.
+innotop currently does this for L<"S: Variables & Status"> mode.
=head2 COLORS
@@ -7961,6 +8926,10 @@
among the columns available but not currently displayed. Finally, you can
re-order the columns with the '+' and '-' keys.
+You can do more than just edit the columns with the table editor, you can also
+edit other properties, such as the table's sort expression and group-by
+expression. Press '?' to see the full list, of course.
+
If you want to really customize and create your own column, as opposed to just
activating a built-in one that's not currently displayed, press the (n)ew key,
and innotop will prompt you for the information it needs:
@@ -7992,6 +8961,21 @@
properties and behaviors. innotop will write the column's definition to the
configuration file, so it will persist across sessions.
+Here's an example: suppose you want to track how many times your slaves have
+retried transactions. According to the MySQL manual, the
+Slave_retried_transactions status variable gives you that data: "The total
+number of times since startup that the replication slave SQL thread has retried
+transactions. This variable was added in version 5.0.4." This is appropriate to
+add to the L<"slave_sql_status"> table.
+
+To add the column, switch to the replication-monitoring mode with the 'M' key,
+and press the '^' key to start the table editor. When prompted, choose
+slave_sql_status as the table, then press 'n' to create the column. Type
+'retries' as the column name, 'Retries' as the column header, and
+'Slave_retried_transactions' as the source. Now the column is created, and you
+see the table editor screen again. Press 'q' to exit the table editor, and
+you'll see your column at the end of the table.
+
=head1 VARIABLE SETS
Variable sets are used in L<"S: Variables & Status"> mode to define more easily
@@ -8036,6 +9020,234 @@
This example is simple, but it shows how easy it is to choose which variables
you want to monitor.
+=head1 PLUGINS
+
+innotop has a simple but powerful plugin mechanism by which you can extend
+or modify its existing functionality, and add new functionality. innotop's
+plugin functionality is event-based: plugins register themselves to be called
+when events happen. They then have a chance to influence the event.
+
+An innotop plugin is a Perl module placed in innotop's L<"plugin_dir">
+directory. On UNIX systems, you can place a symbolic link to the module instead
+of putting the actual file there. innotop automatically discovers the file. If
+there is a corresponding entry in the L<"plugins"> configuration file section,
+innotop loads and activates the plugin.
+
+The module must conform to innotop's plugin interface. Additionally, the source
+code of the module must be written in such a way that innotop can inspect the
+file and determine the package name and description.
+
+=head2 Package Source Convention
+
+innotop inspects the plugin module's source to determine the Perl package name.
+It looks for a line of the form "package Foo;" and if found, considers the
+plugin's package name to be Foo. Of course the package name can be a valid Perl
+package name, with double semicolons and so on.
+
+It also looks for a description in the source code, to make the plugin editor
+more human-friendly. The description is a comment line of the form "#
+description: Foo", where "Foo" is the text innotop will consider to be the
+plugin's description.
+
+=head2 Plugin Interface
+
+The innotop plugin interface is quite simple: innotop expects the plugin to be
+an object-oriented module it can call certain methods on. The methods are
+
+=over
+
+=item new(%variables)
+
+This is the plugin's constructor. It is passed a hash of innotop's variables,
+which it can manipulate (see L<"Plugin Variables">). It must return a reference
+to the newly created plugin object.
+
+At construction time, innotop has only loaded the general configuration and
+created the default built-in variables with their default contents (which is
+quite a lot). Therefore, the state of the program is exactly as in the innotop
+source code, plus the configuration variables from the L<"general"> section in
+the config file.
+
+If your plugin manipulates the variables, it is changing global data, which is
+shared by innotop and all plugins. Plugins are loaded in the order they're
+listed in the config file. Your plugin may load before or after another plugin,
+so there is a potential for conflict or interaction between plugins if they
+modify data other plugins use or modify.
+
+=item register_for_events()
+
+This method must return a list of events in which the plugin is interested, if
+any. See L<"Plugin Events"> for the defined events. If the plugin returns an
+event that's not defined, the event is ignored.
+
+=item event handlers
+
+The plugin must implement a method named the same as each event for which it has
+registered. In other words, if the plugin returns qw(foo bar) from
+register_for_events(), it must have foo() and bar() methods. These methods are
+callbacks for the events. See L<"Plugin Events"> for more details about each
+event.
+
+=back
+
+=head2 Plugin Variables
+
+The plugin's constructor is passed a hash of innotop's variables, which it can
+manipulate. It is probably a good idea if the plugin object saves a copy of it
+for later use. The variables are defined in the innotop variable
+%pluggable_vars, and are as follows:
+
+=over
+
+=item action_for
+
+A hashref of key mappings. These are innotop's global hot-keys.
+
+=item agg_funcs
+
+A hashref of functions that can be used for grouping. See L<"GROUPING">.
+
+=item config
+
+The global configuration hash.
+
+=item connections
+
+A hashref of connection specifications. These are just specifications of how to
+connect to a server.
+
+=item dbhs
+
+A hashref of innotop's database connections. These are actual DBI connection
+objects.
+
+=item filters
+
+A hashref of filters applied to table rows. See L<"FILTERS"> for more.
+
+=item modes
+
+A hashref of modes. See L<"MODES"> for more.
+
+=item server_groups
+
+A hashref of server groups. See L<"SERVER GROUPS">.
+
+=item tbl_meta
+
+A hashref of innotop's table meta-data, with one entry per table (see
+L<"TABLES"> for more information).
+
+=item trans_funcs
+
+A hashref of transformation functions. See L<"TRANSFORMATIONS">.
+
+=item var_sets
+
+A hashref of variable sets. See L<"VARIABLE SETS">.
+
+=back
+
+=head2 Plugin Events
+
+Each event is defined somewhere in the innotop source code. When innotop runs
+that code, it executes the callback function for each plugin that expressed its
+interest in the event. innotop passes some data for each event. The events are
+defined in the %event_listener_for variable, and are as follows:
+
+=over
+
+=item extract_values($set, $cur, $pre, $tbl)
+
+This event occurs inside the function that extracts values from a data source.
+The arguments are the set of values, the current values, the previous values,
+and the table name.
+
+=item set_to_tbl
+
+Events are defined at many places in this subroutine, which is responsible for
+turning an arrayref of hashrefs into an arrayref of lines that can be printed to
+the screen. The events all pass the same data: an arrayref of rows and the name
+of the table being created. The events are set_to_tbl_pre_filter,
+set_to_tbl_pre_sort,set_to_tbl_pre_group, set_to_tbl_pre_colorize,
+set_to_tbl_pre_transform, set_to_tbl_pre_pivot, set_to_tbl_pre_create,
+set_to_tbl_post_create.
+
+=item draw_screen($lines)
+
+This event occurs inside the subroutine that prints the lines to the screen.
+$lines is an arrayref of strings.
+
+=back
+
+=head2 Simple Plugin Example
+
+The easiest way to explain the plugin functionality is probably with a simple
+example. The following module adds a column to the beginning of every table and
+sets its value to 1.
+
+ use strict;
+ use warnings FATAL => 'all';
+
+ package Innotop::Plugin::Example;
+ # description: Adds an 'example' column to every table
+
+ sub new {
+ my ( $class, %vars ) = @_;
+ # Store reference to innotop's variables in $self
+ my $self = bless { %vars }, $class;
+
+ # Design the example column
+ my $col = {
+ hdr => 'Example',
+ just => '',
+ dec => 0,
+ num => 1,
+ label => 'Example',
+ src => 'example', # Get data from this column in the data source
+ tbl => '',
+ trans => [],
+ };
+
+ # Add the column to every table.
+ my $tbl_meta = $vars{tbl_meta};
+ foreach my $tbl ( values %$tbl_meta ) {
+ # Add the column to the list of defined columns
+ $tbl->{cols}->{example} = $col;
+ # Add the column to the list of visible columns
+ unshift @{$tbl->{visible}}, 'example';
+ }
+
+ # Be sure to return a reference to the object.
+ return $self;
+ }
+
+ # I'd like to be called when a data set is being rendered into a table, please.
+ sub register_for_events {
+ my ( $self ) = @_;
+ return qw(set_to_tbl_pre_filter);
+ }
+
+ # This method will be called when the event fires.
+ sub set_to_tbl_pre_filter {
+ my ( $self, $rows, $tbl ) = @_;
+ # Set the example column's data source to the value 1.
+ foreach my $row ( @$rows ) {
+ $row->{example} = 1;
+ }
+ }
+
+ 1;
+
+=head2 Plugin Editor
+
+The plugin editor lets you view the plugins innotop discovered and activate or
+deactivate them. Start the editor by pressing $ to start the configuration
+editor from any mode. Press the 'p' key to start the plugin editor. You'll see
+a list of plugins innotop discovered. You can use the 'j' and 'k' keys to move
+the highlight to the desired one, then press the * key to toggle it active or
+inactive. Exit the editor and restart innotop for the changes to take effect.
+
=head1 SQL STATEMENTS
innotop uses a limited set of SQL statements to retrieve data from MySQL for
@@ -8105,7 +9317,7 @@
This data is from the list of threads in the the FILE I/O section of SHOW INNODB
STATUS.
-=item LOCK_WAITS
+=item INNODB_LOCKS
This data is from the TRANSACTIONS section of SHOW INNODB STATUS and is nested
two levels deep.
@@ -8183,9 +9395,9 @@
=head1 FILES
-$HOMEDIR/.innotop is used to store configuration information.
-$HOMEDIR/.innotop_core_dump contains verbose error messages if L<"debug"> is
-enabled.
+$HOMEDIR/.innotop is used to store configuration information. Files include the
+configuration file innotop.ini, the core_dump file which contains verbose error
+messages if L<"debug"> is enabled, and the plugins/ subdirectory.
=head1 GLOSSARY OF TERMS
Modified: branches/sid-5.1/debian/additions/innotop/innotop.1
===================================================================
--- branches/sid-5.1/debian/additions/innotop/innotop.1 2007-11-09 19:08:33 UTC (rev 979)
+++ branches/sid-5.1/debian/additions/innotop/innotop.1 2007-11-09 19:12:55 UTC (rev 980)
@@ -129,91 +129,223 @@
.\" ========================================================================
.\"
.IX Title "INNOTOP 1p"
-.TH INNOTOP 1 "2007-03-03" "perl v5.8.8" "User Contributed Perl Documentation"
+.TH INNOTOP 1p "2007-11-09" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
-innotop \- A MySQL and InnoDB monitor program.
+innotop \- MySQL and InnoDB transaction/status monitor.
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+To monitor servers normally:
+.PP
+.Vb 1
+\& innotop
+.Ve
+.PP
+To monitor InnoDB status information from a file:
+.PP
+.Vb 1
+\& innotop /var/log/mysql/mysqld.err
+.Ve
+.PP
+To run innotop non-interactively in a pipe-and-filter configuration:
+.PP
+.Vb 1
+\& innotop \-\-count 5 \-d 1 \-n
+.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
-innotop connects to one or many MySQL database servers and retrieves data, then
-displays it. It can run interactively as a monitor, or serve as a source for
-\&\s-1UNIX\s0 pipe-and-filter style programming. innotop uses the data from \s-1SHOW\s0
-\&\s-1VARIABLES\s0, \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0, \s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0, and \s-1SHOW\s0 \s-1ENGINE\s0 \s-1INNODB\s0
-\&\s-1STATUS\s0, among other things. It refreshes the data at regular intervals, so you
-get a sense of what's happening inside your MySQL servers. You can control how
-fast it refreshes.
+innotop monitors MySQL servers. Each of its modes shows you a different aspect
+of what's happening in the server. For example, there's a mode for monitoring
+replication, one for queries, and one for transactions. innotop refreshes its
+data periodically, so you see an updating view.
.PP
-I originally wrote innotop to parse \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 and show a list of
-current transactions in `top' style, hence the name. It now has much more
-functionality.
+innotop has lots of features for power users, but you can start and run it with
+virtually no configuration. If you're just getting started, see
+\&\*(L"\s-1QUICK\-START\s0\*(R". Press '?' at any time while running innotop for
+context-sensitive help.
+.SH "QUICK-START"
+.IX Header "QUICK-START"
+To start innotop, open a terminal or command prompt. If you have installed
+innotop on your system, you should be able to just type \*(L"innotop\*(R" and press
+Enter; otherwise, you will need to change to innotop's directory and type \*(L"perl
+innotop\*(R".
.PP
-When innotop is running interactively, you control it with key presses. You can
-find a complete list of all available keys at any time by pressing '?' for help.
-Keys change innotop from one mode to another, let you change configuration, and
-send commands to MySQL servers.
-.SH "OVERVIEW"
-.IX Header "OVERVIEW"
-Within each of innotop's modes, innotop displays 'tables' of the current data.
-For example, in T (InnoDB Transactions) mode, it shows the transactions in a
-table. In some modes there are many tables on screen at once.
+The first thing innotop needs to know is how to connect to a MySQL server. You
+can just enter the hostname of the server, for example \*(L"localhost\*(R" or
+\&\*(L"127.0.0.1\*(R" if the server is on the same machine as innotop. After this innotop
+will prompt you for a \s-1DSN\s0 (data source name). You should be able to just accept
+the defaults by pressing Enter.
.PP
-You can choose which tables to display, in what order, which columns and in what
-order, how to sort the rows, colorize and filter the rows, and more. Think of
-the tables as spreadsheets; you have quite a bit of control over what goes into
-the cells. You can even define your own formulas and apply formatting. For
-example, you can choose whether a cell should be right or left justified,
-specify minimum and maximum widths, shorten large numbers to familiar units like
-\&\s-1MB\s0 and \s-1GB\s0, and turn an integer number of seconds into hours:minutes:seconds
-display.
+When innotop asks you about a table to use when resetting InnoDB deadlock
+information, just accept the default for now. This is an advanced feature you
+can configure later (see \*(L"D: InnoDB Deadlocks\*(R" for more).
.PP
-Some modes allow you to see the incremental changes since last refresh. This
-can be useful to see how many new queries have been issued during that time, for
-example. You can toggle this on and off.
+If you have a .my.cnf file with your MySQL connection defaults, innotop can read
+it, and you won't need to specify a username and password if it's in that file.
+Otherwise, you should answer 'y' to the next couple of prompts.
.PP
-You can define many connections to servers, group the servers together, and
-switch between them easily to manage many MySQL instances conveniently. See
-\&\s-1SERVER\s0 \s-1GROUPS\s0 for more.
+After this, you should be connected, and innotop should show you something like
+the following:
.PP
-Remember, press '?' to see what commands are available to you at any time.
-.SH "CONFIGURATION"
-.IX Header "CONFIGURATION"
-innotop is completely configurable. The default configuration is built into the
-program, but everything is written out to a configuration file when you exit
-innotop. You can edit this file by hand as you wish, or just use the built-in
-configuration commands while innotop is running.
+.Vb 1
+\& InnoDB Txns (? for help) localhost, 01:11:19, InnoDB 10s :\-), 50 QPS,
+.Ve
.PP
-You can specify certain options on the command\-line. Run `innotop \-\-help' for
+.Vb 2
+\& CXN History Versions Undo Dirty Buf Used Bufs Txns MaxTxn
+\& localhost 7 2035 0 0 0.00% 92.19% 1 07:34
+.Ve
+.PP
+.Vb 5
+\& CXN ID User Host Txn Status Time Undo Query Tex
+\& localhost 98379 user1 webserver ACTIVE 07:34 0 SELECT `c
+\& localhost 98450 user1 webserver ACTIVE 01:06 0 INSERT IN
+\& localhost 97750 user1 webserver not starte 00:00 0
+\& localhost 98375 user1 appserver not starte 00:00 0
+.Ve
+.PP
+(This sample is truncated at the right so it will fit on a terminal when running
+\&'man innotop')
+.PP
+This sample comes from a quiet server with few transactions active. If your
+server is busy, you'll see more output. Notice the first line on the screen,
+which tells you what mode you're in and what server you're connected to. You
+can change to other modes with keystrokes; press 'Q' to switch to a list of
+currently running queries.
+.PP
+Press the '?' key to see what keys are active in the current mode. You can
+press any of these keys and innotop will either take the requested action or
+prompt you for more input. If your system has Term::ReadLine support, you can
+use \s-1TAB\s0 and other keys to auto-complete and edit input.
+.PP
+To quit innotop, press the 'q' key.
+.SH "OPTIONS"
+.IX Header "OPTIONS"
+innotop is mostly configured via its configuration file, but some of the
+configuration options can come from the command line. You can also specify a
+file to monitor for InnoDB status output; see \*(L"\s-1MONITORING\s0 A \s-1FILE\s0\*(R" for more
details.
+.PP
+You can negate some options by prefixing the option name with \-\-no. For
+example, \-\-noinc (or \-\-no\-inc) negates \*(L"\-\-inc\*(R".
+.IP "\-\-help" 4
+.IX Item "--help"
+Print a summary of command-line usage and exit.
+.IP "\-\-color" 4
+.IX Item "--color"
+Enable or disable terminal coloring. Corresponds to the \*(L"color\*(R" config file
+setting.
+.IP "\-\-config" 4
+.IX Item "--config"
+Specifies a configuration file to read. This option is non\-sticky, that is to
+say it does not persist to the configuration file itself.
+.IP "\-\-nonint" 4
+.IX Item "--nonint"
+Enable non-interactive operation. See \*(L"\s-1NON\-INTERACTIVE\s0 \s-1OPERATION\s0\*(R" for more.
+.IP "\-\-count" 4
+.IX Item "--count"
+Refresh only the specified number of times (ticks) before exiting. Each refresh
+is a pause for \*(L"interval\*(R" seconds, followed by requesting data from MySQL
+connections and printing it to the terminal.
+.IP "\-\-delay" 4
+.IX Item "--delay"
+Specifies the amount of time to pause between ticks (refreshes). Corresponds to
+the configuration option \*(L"interval\*(R".
+.IP "\-\-mode" 4
+.IX Item "--mode"
+Specifies the mode in which innotop should start. Corresponds to the
+configuration option \*(L"mode\*(R".
+.IP "\-\-inc" 4
+.IX Item "--inc"
+Specifies whether innotop should display absolute numbers or relative numbers
+(offsets from their previous values). Corresponds to the configuration option
+\&\*(L"status_inc\*(R".
+.IP "\-\-version" 4
+.IX Item "--version"
+Output version information and exit.
+.SH "HOTKEYS"
+.IX Header "HOTKEYS"
+innotop is interactive, and you control it with key\-presses.
+.IP "\(bu" 4
+Uppercase keys switch between modes.
+.IP "\(bu" 4
+Lowercase keys initiate some action within the current mode.
+.IP "\(bu" 4
+Other keys do something special like change configuration or show the
+innotop license.
+.PP
+Press '?' at any time to see the currently active keys and what they do.
.SH "MODES"
.IX Header "MODES"
-innotop has many modes. The following is a brief description of each in
-alphabetical order. Remember, you can always get the authoritative help by
-pressing '?'.
-.IP "B: InnoDB Buffers" 8
+Each of innotop's modes retrieves and displays a particular type of data from
+the servers you're monitoring. You switch between modes with uppercase keys.
+The following is a brief description of each mode, in alphabetical order. To
+switch to the mode, press the key listed in front of its heading in the
+following list:
+.IP "B: InnoDB Buffers" 4
.IX Item "B: InnoDB Buffers"
-This mode displays the InnoDB buffer pool, page statistics, insert buffer, and
-adaptive hash index.
-.IP "D: InnoDB Deadlocks" 8
+This mode displays information about the InnoDB buffer pool, page statistics,
+insert buffer, and adaptive hash index. The data comes from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+.Sp
+This mode contains the \*(L"buffer_pool\*(R", \*(L"page_statistics\*(R",
+\&\*(L"insert_buffers\*(R", and \*(L"adaptive_hash_index\*(R" tables by default.
+.IP "C: Command Summary" 4
+.IX Item "C: Command Summary"
+This mode is similar to mytop's Command Summary mode. It shows the
+\&\*(L"cmd_summary\*(R" table, which looks something like the following:
+.Sp
+.Vb 8
+\& Command Summary (? for help) localhost, 25+07:16:43, 2.45 QPS, 3 thd, 5.0.40
+\& _____________________ Command Summary _____________________
+\& Name Value Pct Last Incr Pct
+\& Select_scan 3244858 69.89% 2 100.00%
+\& Select_range 1354177 29.17% 0 0.00%
+\& Select_full_join 39479 0.85% 0 0.00%
+\& Select_full_range_join 4097 0.09% 0 0.00%
+\& Select_range_check 0 0.00% 0 0.00%
+.Ve
+.Sp
+The command summary table is built by extracting variables from
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". The variables must be numeric and must match the prefix
+given by the \*(L"cmd_filter\*(R" configuration variable. The variables are then
+sorted by value descending and compared to the last variable, as shown above.
+The percentage columns are percentage of the total of all variables in the
+table, so you can see the relative weight of the variables.
+.Sp
+The example shows what you see if the prefix is \*(L"Select_\*(R". The default
+prefix is \*(L"Com_\*(R". You can choose a prefix with the 's' key.
+.Sp
+It's rather like running \s-1SHOW\s0 \s-1VARIABLES\s0 \s-1LIKE\s0 \*(L"prefix%\*(R" with memory and
+nice formatting.
+.Sp
+Values are aggregated across all servers. The Pct columns are not correctly
+aggregated across multiple servers. This is a known limitation of the grouping
+algorithm that may be fixed in the future.
+.IP "D: InnoDB Deadlocks" 4
.IX Item "D: InnoDB Deadlocks"
This mode shows the transactions involved in the last InnoDB deadlock. A second
-table shows the locks each transaction held and waited for (recall that a
-deadlock is caused by a cycle in the waits-for graph).
+table shows the locks each transaction held and waited for. A deadlock is
+caused by a cycle in the waits-for graph, so there should be two locks held and
+one waited for unless the deadlock information is truncated.
.Sp
InnoDB puts deadlock information before some other information in the \s-1SHOW\s0
\&\s-1INNODB\s0 \s-1STATUS\s0 output. If there are a lot of locks, the deadlock information can
-grow very large indeed, and there is a limit on the size of the \s-1SHOW\s0 \s-1INNODB\s0
+grow very large, and there is a limit on the size of the \s-1SHOW\s0 \s-1INNODB\s0
\&\s-1STATUS\s0 output. A large deadlock can fill the entire output, or even be
truncated, and prevent you from seeing other information at all. If you are
running innotop in another mode, for example T mode, and suddenly you don't see
anything, you might want to check and see if a deadlock has wiped out the data
you need.
.Sp
-If it has, you can create a small deadlock to replace it. Use the 'w' key to
-\&'wipe' the large deadlock with a small one. This will not work unless you have
-defined a deadlock table for the connection \*(-- look in your configuration file.
+If it has, you can create a small deadlock to replace the large one. Use the
+\&'w' key to 'wipe' the large deadlock with a small one. This will not work
+unless you have defined a deadlock table for the connection (see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R").
.Sp
-You can also set innotop to automatically detect when a large deadlock needs to
-be replaced with a small one. This feature is turned off by default.
-.IP "F: InnoDB Foreign Key Errors" 8
+You can also configure innotop to automatically detect when a large deadlock
+needs to be replaced with a small one (see \*(L"auto_wipe_dl\*(R").
+.Sp
+This mode displays the \*(L"deadlock_transactions\*(R" and \*(L"deadlock_locks\*(R" tables
+by default.
+.IP "F: InnoDB Foreign Key Errors" 4
.IX Item "F: InnoDB Foreign Key Errors"
This mode shows the last InnoDB foreign key error information, such as the
table where it happened, when and who and what query caused it, and so on.
@@ -223,128 +355,1646 @@
so much code devoted to parsing this messy, unparseable output that innotop is
likely never to be perfect in this regard. If innotop doesn't show you what
you need to see, just look at the status text directly.
-.IP "G: Load Graph" 8
-.IX Item "G: Load Graph"
-This mode calculates per-second statistics, such as queries per second, scales
-them against a maximum, and prints them out as a \*(L"bar graph.\*(R" It's similar to
-the Load Statistics mode, except it's a graph instead of numbers.
.Sp
-Headers are abbreviated to fit on the screen if necessary. This only happens in
-interactive operation, not while running unattended.
-.IP "I: InnoDB I/O Info" 8
+This mode displays the \*(L"fk_error\*(R" table by default.
+.IP "I: InnoDB I/O Info" 4
.IX Item "I: InnoDB I/O Info"
-This mode shows InnoDB's I/O statistics, including the I/O threads, pending
-I/O, file I/O miscellaneous, and log statistics.
-.IP "M: Master/Slave Replication Status" 8
+This mode shows InnoDB's I/O statistics, including the I/O threads, pending I/O,
+file I/O miscellaneous, and log statistics. It displays the \*(L"io_threads\*(R",
+\&\*(L"pending_io\*(R", \*(L"file_io_misc\*(R", and \*(L"log_statistics\*(R" tables by default.
+.IP "L: Locks" 4
+.IX Item "L: Locks"
+This mode shows information about current locks. At the moment only InnoDB
+locks are supported, and by default you'll only see locks for which transactions
+are waiting. This information comes from the \s-1TRANSACTIONS\s0 section of the InnoDB
+status text. If you have a very busy server, you may have frequent lock waits;
+it helps to be able to see which tables and indexes are the \*(L"hot spot\*(R" for
+locks. If your server is running pretty well, this mode should show nothing.
+.Sp
+You can configure MySQL and innotop to monitor not only locks for which a
+transaction is waiting, but those currently held, too. You can do this with the
+InnoDB Lock Monitor (<http://dev.mysql.com/doc/en/innodb\-monitor.html>). It's
+not documented in the MySQL manual, but creating the lock monitor with the
+following statement also affects the output of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, which innotop
+uses:
+.Sp
+.Vb 1
+\& CREATE TABLE innodb_lock_monitor(a int) ENGINE=INNODB;
+.Ve
+.Sp
+This causes InnoDB to print its output to the MySQL file every 16 seconds or so,
+as stated in the manual, but it also makes the normal \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 output
+include lock information, which innotop can parse and display (that's the
+undocumented feature).
+.Sp
+This means you can do what may have seemed impossible: to a limited extent
+(InnoDB truncates some information in the output), you can see which transaction
+holds the locks something else is waiting for. You can also enable and disable
+the InnoDB Lock Monitor with the key mappings in this mode.
+.Sp
+This mode displays the \*(L"innodb_locks\*(R" table by default. Here's a sample of
+the screen when one connection is waiting for locks another connection holds:
+.Sp
+.Vb 7
+\& _________________________________ InnoDB Locks __________________________
+\& CXN ID Type Waiting Wait Active Mode DB Table Index
+\& localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY
+\& localhost 12 TABLE 0 00:10 00:10 IX test t1
+\& localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY
+\& localhost 11 TABLE 0 00:00 00:25 IX test t1
+\& localhost 11 RECORD 0 00:00 00:25 X test t1 PRIMARY
+.Ve
+.Sp
+You can see the first connection, \s-1ID\s0 12, is waiting for a lock on the \s-1PRIMARY\s0
+key on test.t1, and has been waiting for 10 seconds. The second connection
+isn't waiting, because the Waiting column is 0, but it holds locks on the same
+index. That tells you connection 11 is blocking connection 12.
+.IP "M: Master/Slave Replication Status" 4
.IX Item "M: Master/Slave Replication Status"
This mode shows the output of \s-1SHOW\s0 \s-1SLAVE\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1MASTER\s0 \s-1STATUS\s0 in three
tables. The first two divide the slave's status into \s-1SQL\s0 and I/O thread status,
and the last shows master status. Filters are applied to eliminate non-slave
-servers from the slave tables and vice versa.
-.IP "O: Open Tables" 8
+servers from the slave tables, and non-master servers from the master table.
+.Sp
+This mode displays the \*(L"slave_sql_status\*(R", \*(L"slave_io_status\*(R", and
+\&\*(L"master_status\*(R" tables by default.
+.IP "O: Open Tables" 4
.IX Item "O: Open Tables"
This section comes from MySQL's \s-1SHOW\s0 \s-1OPEN\s0 \s-1TABLES\s0 command. By default it is
filtered to show tables which are in use by one or more queries, so you can
get a quick look at which tables are 'hot'. You can use this to guess which
tables might be locked implicitly.
-.IP "Q: Query List" 8
+.Sp
+This mode displays the \*(L"open_tables\*(R" mode by default.
+.IP "Q: Query List" 4
.IX Item "Q: Query List"
This mode displays the output from \s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0, much like \fBmytop\fR's
query list mode. This mode does \fBnot\fR show InnoDB-related information. This
is probably one of the most useful modes for general usage.
.Sp
-You can toggle an informative header that shows general status information about
-your server. There are default sorting, filtering, and colorization rules.
+There is an informative header that shows general status information about
+your server. You can toggle it on and off with the 'h' key. By default,
+innotop hides inactive processes and its own process. You can toggle these on
+and off with the 'i' and 'a' keys.
.Sp
-You can \s-1EXPLAIN\s0 a query from this mode. This will allow you to see the query's
-full text, the results of \s-1EXPLAIN\s0, and in newer MySQL versions, even see the
-optimized query resulting from \s-1EXPLAIN\s0 \s-1EXTENDED\s0.
-.IP "R: InnoDB Row Operations and Semaphores" 8
+You can \s-1EXPLAIN\s0 a query from this mode with the 'e' key. This displays the
+query's full text, the results of \s-1EXPLAIN\s0, and in newer MySQL versions, even
+the optimized query resulting from \s-1EXPLAIN\s0 \s-1EXTENDED\s0. innotop also tries to
+rewrite certain queries to make them EXPLAIN\-able. For example, \s-1INSERT/SELECT\s0
+statements are rewritable.
+.Sp
+This mode displays the \*(L"q_header\*(R" and \*(L"processlist\*(R" tables by default.
+.IP "R: InnoDB Row Operations and Semaphores" 4
.IX Item "R: InnoDB Row Operations and Semaphores"
This mode shows InnoDB row operations, row operation miscellaneous, semaphores,
-and information from the wait array.
-.IP "S: Load Statistics" 8
-.IX Item "S: Load Statistics"
+and information from the wait array. It displays the \*(L"row_operations\*(R",
+\&\*(L"row_operation_misc\*(R", \*(L"semaphores\*(R", and \*(L"wait_array\*(R" tables by default.
+.IP "S: Variables & Status" 4
+.IX Item "S: Variables & Status"
This mode calculates statistics, such as queries per second, and prints them out
-in the style of <vmstat>. It's similar to the Load Graph mode, except it's a
-numbers instead of a graph. You can show absolute values or incremental values
-since the last refresh. Like G mode, headers may be abbreviated to fit on the
-screen in interactive operation. You choose which variables to display with the
-\&'c' key, which selects from predefined sets. You can choose your own sets.
-.IP "T: InnoDB Transactions" 8
+in several different styles. You can show absolute values, or incremental values
+between ticks.
+.Sp
+You can switch between the views by pressing a key. The 's' key prints a
+single line each time the screen updates, in the style of \fBvmstat\fR. The 'g'
+key changes the view to a graph of the same numbers, sort of like \fBtload\fR.
+The 'v' key changes the view to a pivoted table of variable names on the left,
+with successive updates scrolling across the screen from left to right. You can
+choose how many updates to put on the screen with the \*(L"num_status_sets\*(R"
+configuration variable.
+.Sp
+Headers may be abbreviated to fit on the screen in interactive operation. You
+choose which variables to display with the 'c' key, which selects from
+predefined sets, or lets you create your own sets. You can edit the current set
+with the 'e' key.
+.Sp
+This mode doesn't really display any tables like other modes. Instead, it uses
+a table definition to extract and format the data, but it then transforms the
+result in special ways before outputting it. It uses the \*(L"var_status\*(R" table
+definition for this.
+.IP "T: InnoDB Transactions" 4
.IX Item "T: InnoDB Transactions"
-This mode shows every transaction in the InnoDB monitor's output, in `top'
+This mode shows transactions from the InnoDB monitor's output, in \fBtop\fR\-like
format. This mode is the reason I wrote innotop.
.Sp
-By default, two filters are applied to the table to hide inactive transactions
-and hide innotop's own transaction. You can toggle this on and off. There are
-also default sort and colorization rules in this view. You can customize these.
+You can kill queries or processes with the 'k' and 'x' keys, and \s-1EXPLAIN\s0 a query
+with the 'e' or 'f' keys. InnoDB doesn't print the full query in transactions,
+so explaining may not work right if the query is truncated.
.Sp
-If you are only viewing one server's transactions, innotop can display an
-informational header. This will show you things like how many entries there are
-in the InnoDB history list, how much of the buffer pool is used, and so forth.
-.IP "V: Variables & Status" 8
-.IX Item "V: Variables & Status"
-This mode displays any variables you please from \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0 and \s-1SHOW\s0
-\&\s-1VARIABLES\s0, as well as the values parsed from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. It displays
-not only the current values, but previous values too; you choose how many sets
-to keep on screen.
-.IP "W: InnoDB Lock Waits" 8
-.IX Item "W: InnoDB Lock Waits"
-This mode shows information about current InnoDB lock waits. This information
-comes from the \s-1TRANSACTIONS\s0 section of the InnoDB status text. If you have a
-very busy server, you may have frequent lock waits; it helps to be able to see
-which tables and indexes are the \*(L"hot spot\*(R" for locks. If your server is
-running pretty well, this mode should show nothing.
+The informational header can be toggled on and off with the 'h' key. By
+default, innotop hides inactive transactions and its own transaction. You can
+toggle this on and off with the 'i' and 'a' keys.
.Sp
-A second table shows any waits in the \s-1OS\s0 wait array. This comes from a separate
-section of the status text. If you see frequent waits, your server is probably
-running under a high concurrency workload. This is the same table displayed in
-R mode.
+This mode displays the \*(L"t_header\*(R" and \*(L"innodb_transactions\*(R" tables by
+default.
+.SH "INNOTOP STATUS"
+.IX Header "INNOTOP STATUS"
+The first line innotop displays is a \*(L"status bar\*(R" of sorts. What it contains
+depends on the mode you're in, and what servers you're monitoring. The first
+few words are always the innotop mode, such as \*(L"InnoDB Txns\*(R" for T mode,
+followed by a reminder to press '?' for help at any time.
+.Sh "\s-1ONE\s0 \s-1SERVER\s0"
+.IX Subsection "ONE SERVER"
+The simplest case is when you're monitoring a single server. In this case, the
+name of the connection is next on the status line. This is the name you gave
+when you created the connection \*(-- most likely the MySQL server's hostname.
+This is followed by the server's uptime.
+.PP
+If you're in an InnoDB mode, such as T or B, the next word is \*(L"InnoDB\*(R" followed
+by some information about the \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 output used to render the
+screen. The first word is the number of seconds since the last \s-1SHOW\s0 \s-1INNODB\s0
+\&\s-1STATUS\s0, which InnoDB uses to calculate some per-second statistics. The next is
+a smiley face indicating whether the InnoDB output is truncated. If the smiley
+face is a :\-), all is well; there is no truncation. A :^| means the transaction
+list is so long, InnoDB has only printed out some of the transactions. Finally,
+a frown :\-( means the output is incomplete, which is probably due to a deadlock
+printing too much lock information (see \*(L"D: InnoDB Deadlocks\*(R").
+.PP
+The next two words indicate the server's queries per second (\s-1QPS\s0) and how many
+threads (connections) exist. Finally, the server's version number is the last
+thing on the line.
+.Sh "\s-1MULTIPLE\s0 \s-1SERVERS\s0"
+.IX Subsection "MULTIPLE SERVERS"
+If you are monitoring multiple servers (see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R"), the status
+line does not show any details about individual servers. Instead, it shows the
+names of the connections that are active. Again, these are connection names you
+specified, which are likely to be the server's hostname. A connection that has
+an error is prefixed with an exclamation point.
+.PP
+If you are monitoring a group of servers (see \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R"), the status
+line shows the name of the group. If any connection in the group has an
+error, the group's name is followed by the fraction of the connections that
+don't have errors.
+.PP
+See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R" for more details about innotop's error handling.
+.Sh "\s-1MONITORING\s0 A \s-1FILE\s0"
+.IX Subsection "MONITORING A FILE"
+If you give a filename on the command line, innotop will not connect to \s-1ANY\s0
+servers at all. It will watch the specified file for InnoDB status output and
+use that as its data source. It will always show a single connection called
+\&'file'. And since it can't connect to a server, it can't determine how long the
+server it's monitoring has been up; so it calculates the server's uptime as time
+since innotop started running.
+.SH "SERVER ADMINISTRATION"
+.IX Header "SERVER ADMINISTRATION"
+While innotop is primarily a monitor that lets you watch and analyze your
+servers, it can also send commands to servers. The most frequently useful
+commands are killing queries and stopping or starting slaves.
+.PP
+You can kill a connection, or in newer versions of MySQL kill a query but not a
+connection, from \*(L"Q: Query List\*(R" and \*(L"T: InnoDB Transactions\*(R" modes.
+Press 'k' to issue a \s-1KILL\s0 command, or 'x' to issue a \s-1KILL\s0 \s-1QUERY\s0 command.
+innotop will prompt you for the server and/or connection \s-1ID\s0 to kill (innotop
+does not prompt you if there is only one possible choice for any input).
+innotop pre-selects the longest-running query, or the oldest connection.
+Confirm the command with 'y'.
+.PP
+In \*(L"M: Master/Slave Replication Status\*(R" mode, you can start and stop slaves
+with the 'a' and 'o' keys, respectively. You can send these commands to many
+slaves at once. innotop fills in a default command of \s-1START\s0 \s-1SLAVE\s0 or \s-1STOP\s0 \s-1SLAVE\s0
+for you, but you can actually edit the command and send anything you wish, such
+as \s-1SET\s0 \s-1GLOBAL\s0 SQL_SLAVE_SKIP_COUNTER=1 to make the slave skip one binlog event
+when it starts.
+.PP
+You can also ask innotop to calculate the earliest binlog in use by any slave
+and issue a \s-1PURGE\s0 \s-1MASTER\s0 \s-1LOGS\s0 on the master. Use the 'b' key for this. innotop
+will prompt you for a master to run the command on, then prompt you for the
+connection names of that master's slaves (there is no way for innotop to
+determine this reliably itself). innotop will find the minimum binlog in use by
+these slave connections and suggest it as the argument to \s-1PURGE\s0 \s-1MASTER\s0 \s-1LOGS\s0.
+.SH "SERVER CONNECTIONS"
+.IX Header "SERVER CONNECTIONS"
+When you create a server connection, innotop asks you for a series of inputs, as
+follows:
+.IP "\s-1DSN\s0" 4
+.IX Item "DSN"
+A \s-1DSN\s0 is a Data Source Name, which is the initial argument passed to the \s-1DBI\s0
+module for connecting to a server. It is usually of the form
+.Sp
+.Vb 1
+\& DBI:mysql:;mysql_read_default_group=mysql;host=HOSTNAME
+.Ve
+.Sp
+Since this \s-1DSN\s0 is passed to the DBD::mysql driver, you should read the driver's
+documentation at \*(L"http://search.cpan.org/dist/DBD\-mysql/lib/DBD/mysql.pm\*(R" for
+the exact details on all the options you can pass the driver in the \s-1DSN\s0. You
+can read more about \s-1DBI\s0 at <http://dbi.perl.org/docs/>, and especially at
+<http://search.cpan.org/~timb/DBI/DBI.pm>.
+.Sp
+The mysql_read_default_group=mysql option lets the \s-1DBD\s0 driver read your MySQL
+options files, such as ~/.my.cnf on UNIX-ish systems. You can use this to avoid
+specifying a username or password for the connection.
+.IP "InnoDB Deadlock Table" 4
+.IX Item "InnoDB Deadlock Table"
+This optional item tells innotop a table name it can use to deliberately create
+a small deadlock (see \*(L"D: InnoDB Deadlocks\*(R"). If you specify this option,
+you just need to be sure the table doesn't exist, and that innotop can create
+and drop the table with the InnoDB storage engine. You can safely omit or just
+accept the default if you don't intend to use this.
+.IP "Username" 4
+.IX Item "Username"
+innotop will ask you if you want to specify a username. If you say 'y', it will
+then prompt you for a user name. If you have a MySQL option file that specifies
+your username, you don't have to specify a username.
+.Sp
+The username defaults to your login name on the system you're running innotop on.
+.IP "Password" 4
+.IX Item "Password"
+innotop will ask you if you want to specify a password. Like the username, the
+password is optional, but there's an additional prompt that asks if you want to
+save the password in the innotop configuration file. If you don't save it in
+the configuration file, innotop will prompt you for a password each time it
+starts. Passwords in the innotop configuration file are saved in plain text,
+not encrypted in any way.
+.PP
+Once you finish answering these questions, you should be connected to a server.
+But innotop isn't limited to monitoring a single server; you can define many
+server connections and switch between them by pressing the '@' key. See
+\&\*(L"\s-1SWITCHING\s0 \s-1BETWEEN\s0 \s-1CONNECTIONS\s0\*(R".
+.PP
+To create a new connection, press the '@' key and type the name of the new
+connection, then follow the steps given above.
.SH "SERVER GROUPS"
.IX Header "SERVER GROUPS"
-If you have a lot of MySQL instances, or even if you only have a few, you will
-probably find this functionality helpful.
+If you have multiple MySQL instances, you can put them into named groups, such
+as 'all', 'masters', and 'slaves', which innotop can monitor all together.
.PP
-To begin with, when you start innotop it will prompt you to define a connection
-to a server. After that is done, you can tell it to monitor another server with
-the @ key. This key actually brings up a list of connections you've defined.
-If you name one that doesn't exist, innotop will guide you through the process
-of defining it as a new connection, and it will be available from then on.
+You can choose which group to monitor with the '#' key, and you can press the
+\&\s-1TAB\s0 key to switch to the next group. If you're not currently monitoring a
+group, pressing \s-1TAB\s0 selects the first group.
.PP
-You can name multiple connections in any mode. For example, suppose you are in
-T mode, monitoring transactions on server1; if you press @, you can type
-\&'server1 server2' and see data from both.
+To create a group, press the '#' key and type the name of your new group, then
+type the names of the connections you want the group to contain.
+.SH "SWITCHING BETWEEN CONNECTIONS"
+.IX Header "SWITCHING BETWEEN CONNECTIONS"
+innotop lets you quickly switch which servers you're monitoring. The most basic
+way is by pressing the '@' key and typing the name(s) of the connection(s) you
+want to use. This setting is per\-mode, so you can monitor different connections
+in each mode, and innotop remembers which connections you choose.
.PP
-This becomes unwieldy after a bit though. To address this, you can press the
-\&'#' key to create and select server groups. Groups work just the same as
-connections: if you name one that doesn't exist, you can create it.
+You can quickly switch to the 'next' connection in alphabetical order with the
+\&'n' key. If you're monitoring a server group (see \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R") this will
+switch to the first connection.
.PP
-As an example, you might have groups named 'all', 'masters', 'slaves', 'oltp'
-and 'olap'. Many of the servers could belong to several of these groups. It's
-just a quick way to toggle between various servers.
+You can also type many connection names, and innotop will fetch and display data
+from them all. Just separate the connection names with spaces, for example
+\&\*(L"server1 server2.\*(R" Again, if you type the name of a connection that doesn't
+exist, innotop will prompt you for connection information and create the
+connection.
.PP
-Once you have defined groups, you can press the \s-1TAB\s0 key to cycle between them.
+Another way to monitor multiple connections at once is with server groups. You
+can use the \s-1TAB\s0 key to switch to the 'next' group in alphabetical order, or if
+you're not monitoring any groups, \s-1TAB\s0 will switch to the first group.
.PP
-As of this writing innotop does \s-1NOT\s0 fetch data in parallel from different
-servers, so if your groups get large you may notice increased delay time when
-innotop refreshes. You can address this by creating more small groups. At some
-point I plan to make the data-fetching multi-threaded and this problem will not
-be so severe.
+innotop does not fetch data in parallel from connections, so if you are
+monitoring a large group or many connections, you may notice increased delay
+between ticks.
+.PP
+When you monitor more than one connection, innotop's status bar changes. See
+\&\*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R".
+.SH "ERROR HANDLING"
+.IX Header "ERROR HANDLING"
+Error handling is not that important when monitoring a single connection, but is
+crucial when you have many active connections. A crashed server or lost
+connection should not crash innotop. As a result, innotop will continue to run
+even when there is an error; it just won't display any information from the
+connection that had an error. Because of this, innotop's behavior might confuse
+you. It's a feature, not a bug!
+.PP
+innotop does not continue to query connections that have errors, because they
+may slow innotop and make it hard to use, especially if the error is a problem
+connecting and causes a long time\-out. Instead, innotop retries the connection
+occasionally to see if the error still exists. If so, it will wait until some
+point in the future. The wait time increases in ticks as the Fibonacci series,
+so it tries less frequently as time passes.
+.PP
+Since errors might only happen in certain modes because of the \s-1SQL\s0 commands
+issued in those modes, innotop keeps track of which mode caused the error. If
+you switch to a different mode, innotop will retry the connection instead of
+waiting.
+.PP
+By default innotop will display the problem in red text at the bottom of the
+first table on the screen. You can disable this behavior with the
+\&\*(L"show_cxn_errors_in_tbl\*(R" configuration option, which is enabled by default.
+If the \*(L"debug\*(R" option is enabled, innotop will display the error at the
+bottom of every table, not just the first. And if \*(L"show_cxn_errors\*(R" is
+enabled, innotop will print the error text to \s-1STDOUT\s0 as well. Error messages
+might only display in the mode that caused the error, depending on the mode and
+whether innotop is avoiding querying that connection.
+.SH "NON-INTERACTIVE OPERATION"
+.IX Header "NON-INTERACTIVE OPERATION"
+You can run innotop in non-interactive mode, in which case it is entirely
+controlled from the configuration file and command-line options. To start
+innotop in non-interactive mode, give the L\*(L"<\-\-nonint\*(R"> command-line option.
+This changes innotop's behavior in the following ways:
+.IP "\(bu" 4
+Certain Perl modules are not loaded. Term::Readline is not loaded, since
+innotop doesn't prompt interactively. Term::ANSIColor and Win32::Console::ANSI
+modules are not loaded. Term::ReadKey is still used, since innotop may have to
+prompt for connection passwords when starting up.
+.IP "\(bu" 4
+innotop does not clear the screen after each tick.
+.IP "\(bu" 4
+innotop does not persist any changes to the configuration file.
+.IP "\(bu" 4
+If \*(L"\-\-count\*(R" is given and innotop is in incremental mode (see \*(L"status_inc\*(R"
+and \*(L"\-\-inc\*(R"), innotop actually refreshes one more time than specified so it
+can print incremental statistics. This suppresses output during the first
+tick, so innotop may appear to hang.
+.IP "\(bu" 4
+innotop only displays the first table in each mode. This is so the output can
+be easily processed with other command-line utilities such as awk and sed. To
+change which tables display in each mode, see \*(L"\s-1TABLES\s0\*(R". Since \*(L"Q: Query List\*(R" mode is so important, innotop automatically disables the \*(L"q_header\*(R"
+table. This ensures you'll see the \*(L"processlist\*(R" table, even if you have
+innotop configured to show the q_header table during interactive operation.
+Similarly, in \*(L"T: InnoDB Transactions\*(R" mode, the \*(L"t_header\*(R" table is
+suppressed so you see only the \*(L"innodb_transactions\*(R" table.
+.IP "\(bu" 4
+All output is tab-separated instead of being column-aligned with whitespace, and
+innotop prints the full contents of each table instead of only printing one
+screenful at a time.
+.IP "\(bu" 4
+innotop only prints column headers once instead of every tick (see
+\&\*(L"hide_hdr\*(R"). innotop does not print table captions (see
+\&\*(L"display_table_captions\*(R"). innotop ensures there are no empty lines in the
+output.
+.IP "\(bu" 4
+innotop does not honor the \*(L"shorten\*(R" transformation, which normally shortens
+some numbers to human-readable formats.
+.IP "\(bu" 4
+innotop does not print a status line (see \*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R").
+.SH "CONFIGURING"
+.IX Header "CONFIGURING"
+Nearly everything about innotop is configurable. Most things are possible to
+change with built-in commands, but you can also edit the configuration file.
+.PP
+While running innotop, press the '$' key to bring up the configuration editing
+dialog. Press another key to select the type of data you want to edit:
+.IP "S: Statement Sleep Times" 4
+.IX Item "S: Statement Sleep Times"
+Edits \s-1SQL\s0 statement sleep delays, which make innotop pause for the specified
+amount of time after executing a statement. See \*(L"\s-1SQL\s0 \s-1STATEMENTS\s0\*(R" for a
+definition of each statement and what it does. By default innotop does not
+delay after any statements.
+.Sp
+This feature is included so you can customize the side-effects caused by
+monitoring your server. You may not see any effects, but some innotop users
+have noticed that certain MySQL versions under very high load with InnoDB
+enabled take longer than usual to execute \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0. If innotop calls
+\&\s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0 immediately afterward, the processlist contains more
+queries than the machine actually averages at any given moment. Configuring
+innotop to pause briefly after calling \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0 alleviates this
+effect.
+.Sp
+Sleep times are stored in the \*(L"stmt_sleep_times\*(R" section of the configuration
+file. Fractional-second sleeps are supported, subject to your hardware's
+limitations.
+.IP "c: Edit Columns" 4
+.IX Item "c: Edit Columns"
+Starts the table editor on one of the displayed tables. See \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R".
+An alternative way to start the table editor without entering the configuration
+dialog is with the '^' key.
+.IP "g: General Configuration" 4
+.IX Item "g: General Configuration"
+Starts the configuration editor to edit global and mode-specific configuration
+variables (see \*(L"\s-1MODES\s0\*(R"). innotop prompts you to choose a variable from among
+the global and mode-specific ones depending on the current mode.
+.IP "k: Row-Coloring Rules" 4
+.IX Item "k: Row-Coloring Rules"
+Starts the row-coloring rules editor on one of the displayed table(s). See
+\&\*(L"\s-1COLORS\s0\*(R" for details.
+.IP "p: Manage Plugins" 4
+.IX Item "p: Manage Plugins"
+Starts the plugin configuration editor. See \*(L"\s-1PLUGINS\s0\*(R" for details.
+.IP "s: Server Groups" 4
+.IX Item "s: Server Groups"
+Lets you create and edit server groups. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R".
+.IP "t: Choose Displayed Tables" 4
+.IX Item "t: Choose Displayed Tables"
+Lets you choose which tables to display in this mode. See \*(L"\s-1MODES\s0\*(R" and
+\&\*(L"\s-1TABLES\s0\*(R".
+.SH "CONFIGURATION FILE"
+.IX Header "CONFIGURATION FILE"
+innotop's default configuration file location is in \f(CW$HOME\fR/.innotop, but can be
+overridden with the \*(L"\-\-config\*(R" command-line option. You can edit it by hand
+safely. innotop reads the configuration file when it starts, and writes it out
+again when it exits, so any changes you make while innotop is running will be
+lost.
+.PP
+innotop doesn't store its entire configuration in the configuration file. It
+has a huge set of default configuration that it holds only in memory, and the
+configuration file only overrides these defaults. When you customize a default
+setting, innotop notices, and then stores the customizations into the file.
+This keeps the file size down, makes it easier to edit, and makes upgrades
+easier.
+.PP
+A configuration file can be made read\-only. See \*(L"readonly\*(R".
+.PP
+The configuration file is arranged into sections like an \s-1INI\s0 file. Each
+section begins with [section\-name] and ends with [/section\-name]. Each
+section's entries have a different syntax depending on the data they need to
+store. You can put comments in the file; any line that begins with a #
+character is a comment. innotop will not read the comments, so it won't write
+them back out to the file when it exits. Comments in read-only configuration
+files are still useful, though.
+.PP
+The first line in the file is innotop's version number. This lets innotop
+notice when the file format is not backwards\-compatible, and upgrade smoothly
+without destroying your customized configuration.
+.PP
+The following list describes each section of the configuration file and the data
+it contains:
+.IP "general" 4
+.IX Item "general"
+The 'general' section contains global configuration variables and variables that
+may be mode\-specific, but don't belong in any other section. The syntax is a
+simple key=value list. innotop writes a comment above each value to help you
+edit the file by hand.
+.RS 4
+.IP "S_func" 4
+.IX Item "S_func"
+Controls S mode presentation (see \*(L"S: Variables & Status\*(R"). If g, values are
+graphed; if s, values are like vmstat; if p, values are in a pivoted table.
+.IP "S_set" 4
+.IX Item "S_set"
+Specifies which set of variables to display in \*(L"S: Variables & Status\*(R" mode.
+See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R".
+.IP "auto_wipe_dl" 4
+.IX Item "auto_wipe_dl"
+Instructs innotop to automatically wipe large deadlocks when it notices them.
+When this happens you may notice a slight delay. At the next tick, you will
+usually see the information that was being truncated by the large deadlock.
+.IP "charset" 4
+.IX Item "charset"
+Specifies what kind of characters to allow through the \*(L"no_ctrl_char\*(R"
+transformation. This keeps non-printable characters from confusing a
+terminal when you monitor queries that contain binary data, such as images.
+.Sp
+The default is 'ascii', which considers anything outside normal \s-1ASCII\s0 to be a
+control character. The other allowable values are 'unicode' and 'none'. 'none'
+considers every character a control character, which can be useful for
+collapsing \s-1ALL\s0 text fields in queries.
+.IP "cmd_filter" 4
+.IX Item "cmd_filter"
+This is the prefix that filters variables in \*(L"C: Command Summary\*(R" mode.
+.IP "color" 4
+.IX Item "color"
+Whether terminal coloring is permitted.
+.IP "cxn_timeout" 4
+.IX Item "cxn_timeout"
+On MySQL versions 4.0.3 and newer, this variable is used to set the connection's
+timeout, so MySQL doesn't close the connection if it is not used for a while.
+This might happen because a connection isn't monitored in a particular mode, for
+example.
+.IP "debug" 4
+.IX Item "debug"
+This option enables more verbose errors and makes innotop more strict in some
+places. It can help in debugging filters and other user-defined code. It also
+makes innotop write a lot of information to \*(L"debugfile\*(R" when there is a
+crash.
+.IP "debugfile" 4
+.IX Item "debugfile"
+A file to which innotop will write information when there is a crash. See
+\&\*(L"\s-1FILES\s0\*(R".
+.IP "display_table_captions" 4
+.IX Item "display_table_captions"
+innotop displays a table caption above most tables. This variable suppresses or
+shows captions on all tables globally. Some tables are configured with the
+hide_caption property, which overrides this.
+.IP "global" 4
+.IX Item "global"
+Whether to show \s-1GLOBAL\s0 variables and status. innotop only tries to do this on
+servers which support the \s-1GLOBAL\s0 option to \s-1SHOW\s0 \s-1VARIABLES\s0 and \s-1SHOW\s0 \s-1STATUS\s0. In
+some MySQL versions, you need certain privileges to do this; if you don't have
+them, innotop will not be able to fetch any variable and status data. This
+configuration variable lets you run innotop and fetch what data you can even
+without the elevated privileges.
+.Sp
+I can no longer find or reproduce the situation where \s-1GLOBAL\s0 wasn't allowed, but
+I know there was one.
+.IP "graph_char" 4
+.IX Item "graph_char"
+Defines the character to use when drawing graphs in \*(L"S: Variables & Status\*(R"
+mode.
+.IP "header_highlight" 4
+.IX Item "header_highlight"
+Defines how to highlight column headers. This only works if Term::ANSIColor is
+available. Valid values are 'bold' and 'underline'.
+.IP "hide_hdr" 4
+.IX Item "hide_hdr"
+Hides column headers globally.
+.IP "interval" 4
+.IX Item "interval"
+The interval at which innotop will refresh its data (ticks). The interval is
+implemented as a sleep time between ticks, so the true interval will vary
+depending on how long it takes innotop to fetch and render data.
+.Sp
+This variable accepts fractions of a second.
+.IP "mode" 4
+.IX Item "mode"
+The mode in which innotop should start. Allowable arguments are the same as the
+key presses that select a mode interactively. See \*(L"\s-1MODES\s0\*(R".
+.IP "num_digits" 4
+.IX Item "num_digits"
+How many digits to show in fractional numbers and percents. This variable's
+range is between 0 and 9 and can be set directly from \*(L"S: Variables & Status\*(R"
+mode with the '+' and '\-' keys. It is used in the \*(L"set_precision\*(R",
+\&\*(L"shorten\*(R", and \*(L"percent\*(R" transformations.
+.IP "num_status_sets" 4
+.IX Item "num_status_sets"
+Controls how many sets of status variables to display in pivoted \*(L"S: Variables & Status\*(R" mode. It also controls the number of old sets of variables innotop
+keeps in its memory, so the larger this variable is, the more memory innotop
+uses.
+.IP "plugin_dir" 4
+.IX Item "plugin_dir"
+Specifies where plugins can be found. By default, innotop stores plugins in the
+\&'plugins' subdirectory of your innotop configuration directory.
+.IP "readonly" 4
+.IX Item "readonly"
+Whether the configuration file is readonly. This cannot be set interactively,
+because it would prevent itself from being written to the configuration file.
+.IP "show_cxn_errors" 4
+.IX Item "show_cxn_errors"
+Makes innotop print connection errors to \s-1STDOUT\s0. See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R".
+.IP "show_cxn_errors_in_tbl" 4
+.IX Item "show_cxn_errors_in_tbl"
+Makes innotop display connection errors as rows in the first table on screen.
+See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R".
+.IP "show_percent" 4
+.IX Item "show_percent"
+Adds a '%' character after the value returned by the \*(L"percent\*(R"
+transformation.
+.IP "show_statusbar" 4
+.IX Item "show_statusbar"
+Controls whether to show the status bar in the display. See \*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R".
+.IP "skip_innodb" 4
+.IX Item "skip_innodb"
+Disables fetching \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, in case your server(s) do not have InnoDB
+enabled and you don't want innotop to try to fetch it. This can also be useful
+when you don't have the \s-1SUPER\s0 privilege, required to run \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+.IP "status_inc" 4
+.IX Item "status_inc"
+Whether to show absolute or incremental values for status variables.
+Incremental values are calculated as an offset from the last value innotop saw
+for that variable. This is a global setting, but will probably become
+mode-specific at some point. Right now it is honored a bit inconsistently; some
+modes don't pay attention to it.
+.RE
+.RS 4
+.RE
+.IP "plugins" 4
+.IX Item "plugins"
+This section holds a list of package names of active plugins. If the plugin
+exists, innotop will activate it. See \*(L"\s-1PLUGINS\s0\*(R" for more information.
+.IP "filters" 4
+.IX Item "filters"
+This section holds user-defined filters (see \*(L"\s-1FILTERS\s0\*(R"). Each line is in the
+format filter_name=text='filter text' tbls='table list'.
+.Sp
+The filter text is the text of the subroutine's code. The table list is a list
+of tables to which the filter can apply. By default, user-defined filters apply
+to the table for which they were created, but you can manually override that by
+editing the definition in the configuration file.
+.IP "active_filters" 4
+.IX Item "active_filters"
+This section stores which filters are active on each table. Each line is in the
+format table_name=filter_list.
+.IP "tbl_meta" 4
+.IX Item "tbl_meta"
+This section stores user-defined or user-customized columns (see \*(L"\s-1COLUMNS\s0\*(R").
+Each line is in the format col_name=properties, where the properties are a
+name=quoted\-value list.
+.IP "connections" 4
+.IX Item "connections"
+This section holds the server connections you have defined. Each line is in the
+format name=properties, where the properties are a name=value list. The
+properties are self\-explanatory, and the only one that is treated specially is
+\&'pass' which is only present if 'savepass' is set. See \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R".
+.IP "active_connections" 4
+.IX Item "active_connections"
+This section holds a list of which connections are active in each mode. Each
+line is in the format mode_name=connection_list.
+.IP "server_groups" 4
+.IX Item "server_groups"
+This section holds server groups. Each line is in the format
+name=connection_list. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R".
+.IP "active_server_groups" 4
+.IX Item "active_server_groups"
+This section holds a list of which server group is active in each mode. Each
+line is in the format mode_name=server_group.
+.IP "max_values_seen" 4
+.IX Item "max_values_seen"
+This section holds the maximum values seen for variables. This is used to scale
+the graphs in \*(L"S: Variables & Status\*(R" mode. Each line is in the format
+name=value.
+.IP "active_columns" 4
+.IX Item "active_columns"
+This section holds table column lists. Each line is in the format
+tbl_name=column_list. See \*(L"\s-1COLUMNS\s0\*(R".
+.IP "sort_cols" 4
+.IX Item "sort_cols"
+This section holds the sort definition. Each line is in the format
+tbl_name=column_list. If a column is prefixed with '\-', that column sorts
+descending. See \*(L"\s-1SORTING\s0\*(R".
+.IP "visible_tables" 4
+.IX Item "visible_tables"
+This section defines which tables are visible in each mode. Each line is in the
+format mode_name=table_list. See \*(L"\s-1TABLES\s0\*(R".
+.IP "varsets" 4
+.IX Item "varsets"
+This section defines variable sets for use in \*(L"S: Status & Variables\*(R" mode.
+Each line is in the format name=variable_list. See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R".
+.IP "colors" 4
+.IX Item "colors"
+This section defines colorization rules. Each line is in the format
+tbl_name=property_list. See \*(L"\s-1COLORS\s0\*(R".
+.IP "stmt_sleep_times" 4
+.IX Item "stmt_sleep_times"
+This section contains statement sleep times. Each line is in the format
+statement_name=sleep_time. See \*(L"S: Statement Sleep Times\*(R".
+.IP "group_by" 4
+.IX Item "group_by"
+This section contains column lists for table group_by expressions. Each line is
+in the format tbl_name=column_list. See \*(L"\s-1GROUPING\s0\*(R".
+.SH "CUSTOMIZING"
+.IX Header "CUSTOMIZING"
+You can customize innotop a great deal. For example, you can:
+.IP "\(bu" 4
+Choose which tables to display, and in what order.
+.IP "\(bu" 4
+Choose which columns are in those tables, and create new columns.
+.IP "\(bu" 4
+Filter which rows display with built-in filters, user-defined filters, and
+quick\-filters.
+.IP "\(bu" 4
+Sort the rows to put important data first or group together related rows.
+.IP "\(bu" 4
+Highlight rows with color.
+.IP "\(bu" 4
+Customize the alignment, width, and formatting of columns, and apply
+transformations to columns to extract parts of their values or format the values
+as you wish (for example, shortening large numbers to familiar units).
+.IP "\(bu" 4
+Design your own expressions to extract and combine data as you need. This gives
+you unlimited flexibility.
+.PP
+All these and more are explained in the following sections.
+.Sh "\s-1TABLES\s0"
+.IX Subsection "TABLES"
+A table is what you'd expect: a collection of columns. It also has some other
+properties, such as a caption. Filters, sorting rules, and colorization rules
+belong to tables and are covered in later sections.
+.PP
+Internally, table meta-data is defined in a data structure called \f(CW%tbl_meta\fR.
+This hash holds all built-in table definitions, which contain a lot of default
+instructions to innotop. The meta-data includes the caption, a list of columns
+the user has customized, a list of columns, a list of visible columns, a list of
+filters, color rules, a sort-column list, sort direction, and some information
+about the table's data sources. Most of this is customizable via the table
+editor (see \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R").
+.PP
+You can choose which tables to show by pressing the '$' key. See \*(L"\s-1MODES\s0\*(R" and
+\&\*(L"\s-1TABLES\s0\*(R".
+.PP
+The table life-cycle is as follows:
+.IP "\(bu" 4
+Each table begins with a data source, which is an array of hashes. See below
+for details on data sources.
+.IP "\(bu" 4
+Each element of the data source becomes a row in the final table.
+.IP "\(bu" 4
+For each element in the data source, innotop extracts values from the source and
+creates a row. This row is another hash, which later steps will refer to as
+\&\f(CW$set\fR. The values innotop extracts are determined by the table's columns. Each
+column has an extraction subroutine, compiled from an expression (see
+\&\*(L"\s-1EXPRESSIONS\s0\*(R"). The resulting row is a hash whose keys are named the same as
+the column name.
+.IP "\(bu" 4
+innotop filters the rows, removing those that don't need to be displayed. See
+\&\*(L"\s-1FILTERS\s0\*(R".
+.IP "\(bu" 4
+innotop sorts the rows. See \*(L"\s-1SORTING\s0\*(R".
+.IP "\(bu" 4
+innotop groups the rows together, if specified. See \*(L"\s-1GROUPING\s0\*(R".
+.IP "\(bu" 4
+innotop colorizes the rows. See \*(L"\s-1COLORS\s0\*(R".
+.IP "\(bu" 4
+innotop transforms the column values in each row. See \*(L"\s-1TRANSFORMATIONS\s0\*(R".
+.IP "\(bu" 4
+innotop optionally pivots the rows (see \*(L"\s-1PIVOTING\s0\*(R"), then filters and sorts
+them.
+.IP "\(bu" 4
+innotop formats and justifies the rows as a table. During this step, innotop
+applies further formatting to the column values, including alignment, maximum
+and minimum widths. innotop also does final error checking to ensure there are
+no crashes due to undefined values. innotop then adds a caption if specified,
+and the table is ready to print.
+.PP
+The lifecycle is slightly different if the table is pivoted, as noted above. To
+clarify, if the table is pivoted, the process is extract, group, transform,
+pivot, filter, sort, create. If it's not pivoted, the process is extract,
+filter, sort, group, color, transform, create. This slightly convoluted process
+doesn't map all that well to \s-1SQL\s0, but pivoting complicates things pretty
+thoroughly. Roughly speaking, filtering and sorting happen as late as needed to
+effect the final result as you might expect, but as early as possible for
+efficiency.
+.PP
+Each built-in table is described below:
+.IP "adaptive_hash_index" 4
+.IX Item "adaptive_hash_index"
+Displays data about InnoDB's adaptive hash index. Data source:
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "buffer_pool" 4
+.IX Item "buffer_pool"
+Displays data about InnoDB's buffer pool. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "cmd_summary" 4
+.IX Item "cmd_summary"
+Displays weighted status variables. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "deadlock_locks" 4
+.IX Item "deadlock_locks"
+Shows which locks were held and waited for by the last detected deadlock. Data
+source: \*(L"\s-1DEADLOCK_LOCKS\s0\*(R".
+.IP "deadlock_transactions" 4
+.IX Item "deadlock_transactions"
+Shows transactions involved in the last detected deadlock. Data source:
+\&\*(L"\s-1DEADLOCK_TRANSACTIONS\s0\*(R".
+.IP "explain" 4
+.IX Item "explain"
+Shows the output of \s-1EXPLAIN\s0. Data source: \*(L"\s-1EXPLAIN\s0\*(R".
+.IP "file_io_misc" 4
+.IX Item "file_io_misc"
+Displays data about InnoDB's file and I/O operations. Data source:
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "fk_error" 4
+.IX Item "fk_error"
+Displays various data about InnoDB's last foreign key error. Data source:
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "innodb_locks" 4
+.IX Item "innodb_locks"
+Displays InnoDB locks. Data source: \*(L"\s-1INNODB_LOCKS\s0\*(R".
+.IP "innodb_transactions" 4
+.IX Item "innodb_transactions"
+Displays data about InnoDB's current transactions. Data source:
+\&\*(L"\s-1INNODB_TRANSACTIONS\s0\*(R".
+.IP "insert_buffers" 4
+.IX Item "insert_buffers"
+Displays data about InnoDB's insert buffer. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "io_threads" 4
+.IX Item "io_threads"
+Displays data about InnoDB's I/O threads. Data source: \*(L"\s-1IO_THREADS\s0\*(R".
+.IP "log_statistics" 4
+.IX Item "log_statistics"
+Displays data about InnoDB's logging system. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "master_status" 4
+.IX Item "master_status"
+Displays replication master status. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "open_tables" 4
+.IX Item "open_tables"
+Displays open tables. Data source: \*(L"\s-1OPEN_TABLES\s0\*(R".
+.IP "page_statistics" 4
+.IX Item "page_statistics"
+Displays InnoDB page statistics. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "pending_io" 4
+.IX Item "pending_io"
+Displays InnoDB pending I/O operations. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "processlist" 4
+.IX Item "processlist"
+Displays current MySQL processes (threads/connections). Data source:
+\&\*(L"\s-1PROCESSLIST\s0\*(R".
+.IP "q_header" 4
+.IX Item "q_header"
+Displays various status values. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "row_operation_misc" 4
+.IX Item "row_operation_misc"
+Displays data about InnoDB's row operations. Data source:
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "row_operations" 4
+.IX Item "row_operations"
+Displays data about InnoDB's row operations. Data source:
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "semaphores" 4
+.IX Item "semaphores"
+Displays data about InnoDB's semaphores and mutexes. Data source:
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "slave_io_status" 4
+.IX Item "slave_io_status"
+Displays data about the slave I/O thread. Data source:
+\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "slave_sql_status" 4
+.IX Item "slave_sql_status"
+Displays data about the slave \s-1SQL\s0 thread. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "t_header" 4
+.IX Item "t_header"
+Displays various InnoDB status values. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "var_status" 4
+.IX Item "var_status"
+Displays user-configurable data. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+.IP "wait_array" 4
+.IX Item "wait_array"
+Displays data about InnoDB's \s-1OS\s0 wait array. Data source: \*(L"\s-1OS_WAIT_ARRAY\s0\*(R".
+.Sh "\s-1COLUMNS\s0"
+.IX Subsection "COLUMNS"
+Columns belong to tables. You can choose a table's columns by pressing the '^'
+key, which starts the \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R" and lets you choose and edit columns.
+Pressing 'e' from within the table editor lets you edit the column's properties:
+.IP "\(bu" 4
+hdr: a column header. This appears in the first row of the table.
+.IP "\(bu" 4
+just: justification. '\-' means left-justified and '' means right\-justified,
+just as with printf formatting codes (not a coincidence).
+.IP "\(bu" 4
+dec: whether to further align the column on the decimal point.
+.IP "\(bu" 4
+num: whether the column is numeric. This affects how values are sorted
+(lexically or numerically).
+.IP "\(bu" 4
+label: a small note about the column, which appears in dialogs that help the
+user choose columns.
+.IP "\(bu" 4
+src: an expression that innotop uses to extract the column's data from its
+source (see \*(L"\s-1DATA\s0 \s-1SOURCES\s0\*(R"). See \*(L"\s-1EXPRESSIONS\s0\*(R" for more on expressions.
+.IP "\(bu" 4
+minw: specifies a minimum display width. This helps stabilize the display,
+which makes it easier to read if the data is changing frequently.
+.IP "\(bu" 4
+maxw: similar to minw.
+.IP "\(bu" 4
+trans: a list of column transformations. See \*(L"\s-1TRANSFORMATIONS\s0\*(R".
+.IP "\(bu" 4
+agg: an aggregate function. See \*(L"\s-1GROUPING\s0\*(R". The default is \*(L"first\*(R".
+.IP "\(bu" 4
+aggonly: controls whether the column only shows when grouping is enabled on the
+table (see \*(L"\s-1GROUPING\s0\*(R"). By default, this is disabled. This means columns
+will always be shown by default, whether grouping is enabled or not. If a
+column's aggonly is set true, the column will appear when you toggle grouping on
+the table. Several columns are set this way, such as the count column on
+\&\*(L"processlist\*(R" and \*(L"innodb_transactions\*(R", so you don't see a count when the
+grouping isn't enabled, but you do when it is.
+.Sh "\s-1FILTERS\s0"
+.IX Subsection "FILTERS"
+Filters remove rows from the display. They behave much like a \s-1WHERE\s0 clause in
+\&\s-1SQL\s0. innotop has several built-in filters, which remove irrelevant information
+like inactive queries, but you can define your own as well. innotop also lets
+you create quick\-filters, which do not get saved to the configuration file, and
+are just an easy way to quickly view only some rows.
+.PP
+You can enable or disable a filter on any table. Press the '%' key (mnemonic: %
+looks kind of like a line being filtered between two circles) and choose which
+table you want to filter, if asked. You'll then see a list of possible filters
+and a list of filters currently enabled for that table. Type the names of
+filters you want to apply and press Enter.
+.PP
+\fIUSER-DEFINED \s-1FILTERS\s0\fR
+.IX Subsection "USER-DEFINED FILTERS"
+.PP
+If you type a name that doesn't exist, innotop will prompt you to create the
+filter. Filters are easy to create if you know Perl, and not hard if you don't.
+What you're doing is creating a subroutine that returns true if the row should
+be displayed. The row is a hash reference passed to your subroutine as \f(CW$set\fR.
+.PP
+For example, imagine you want to filter the processlist table so you only see
+queries that have been running more than five minutes. Type a new name for your
+filter, and when prompted for the subroutine body, press \s-1TAB\s0 to initiate your
+terminal's auto\-completion. You'll see the names of the columns in the
+\&\*(L"processlist\*(R" table (innotop generally tries to help you with auto-completion
+lists). You want to filter on the 'time' column. Type the text \*(L"$set\->{time} >
+300\*(R" to return true when the query is more than five minutes old. That's all
+you need to do.
+.PP
+In other words, the code you're typing is surrounded by an implicit context,
+which looks like this:
+.PP
+.Vb 4
+\& sub filter {
+\& my ( $set ) = @_;
+\& # YOUR CODE HERE
+\& }
+.Ve
+.PP
+If your filter doesn't work, or if something else suddenly behaves differently,
+you might have made an error in your filter, and innotop is silently catching
+the error. Try enabling \*(L"debug\*(R" to make innotop throw an error instead.
+.PP
+\fIQUICK-FILTERS\fR
+.IX Subsection "QUICK-FILTERS"
+.PP
+innotop's quick-filters are a shortcut to create a temporary filter that doesn't
+persist when you restart innotop. To create a quick\-filter, press the '/' key.
+innotop will prompt you for the column name and filter text. Again, you can use
+auto-completion on column names. The filter text can be just the text you want
+to \*(L"search for.\*(R" For example, to filter the \*(L"processlist\*(R" table on queries
+that refer to the products table, type '/' and then 'info product'.
+.PP
+The filter text can actually be any Perl regular expression, but of course a
+literal string like 'product' works fine as a regular expression.
+.PP
+Behind the scenes innotop compiles the quick-filter into a specially tagged
+filter that is otherwise like any other filter. It just isn't saved to the
+configuration file.
+.PP
+To clear quick\-filters, press the '\e' key and innotop will clear them all at
+once.
+.Sh "\s-1SORTING\s0"
+.IX Subsection "SORTING"
+innotop has sensible built-in defaults to sort the most important rows to the
+top of the table. Like anything else in innotop, you can customize how any
+table is sorted.
+.PP
+To start the sort dialog, start the \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R" with the '^' key, choose a
+table if necessary, and press the 's' key. You'll see a list of columns you can
+use in the sort expression and the current sort expression, if any. Enter a
+list of columns by which you want to sort and press Enter. If you want to
+reverse sort, prefix the column name with a minus sign. For example, if you
+want to sort by column a ascending, then column b descending, type 'a \-b'. You
+can also explicitly add a + in front of columns you want to sort ascending, but
+it's not required.
+.PP
+Some modes have keys mapped to open this dialog directly, and to quickly reverse
+sort direction. Press '?' as usual to see which keys are mapped in any mode.
+.Sh "\s-1GROUPING\s0"
+.IX Subsection "GROUPING"
+innotop can group, or aggregate, rows together (I use the terms
+interchangeably). This is quite similar to an \s-1SQL\s0 \s-1GROUP\s0 \s-1BY\s0 clause. You can
+specify to group on certain columns, or if you don't specify any, the entire set
+of rows is treated as one group. This is quite like \s-1SQL\s0 so far, but unlike \s-1SQL\s0,
+you can also select un-grouped columns. innotop actually aggregates every
+column. If you don't explicitly specify a grouping function, the default is
+\&'first'. This is basically a convenience so you don't have to specify an
+aggregate function for every column you want in the result.
+.PP
+You can quickly toggle grouping on a table with the '=' key, which toggles its
+aggregate property. This property doesn't persist to the config file.
+.PP
+The columns by which the table is grouped are specified in its group_by
+property. When you turn grouping on, innotop places the group_by columns at the
+far left of the table, even if they're not supposed to be visible. The rest of
+the visible columns appear in order after them.
+.PP
+Two tables have default group_by lists and a count column built in:
+\&\*(L"processlist\*(R" and \*(L"innodb_transactions\*(R". The grouping is by connection
+and status, so you can quickly see how many queries or transactions are in a
+given status on each server you're monitoring. The time columns are aggregated
+as a sum; other columns are left at the default 'first' aggregation.
+.PP
+By default, the table shown in \*(L"S: Variables & Status\*(R" mode also uses
+grouping so you can monitor variables and status across many servers. The
+default aggregation function in this mode is 'avg'.
+.PP
+Valid grouping functions are defined in the \f(CW%agg_funcs\fR hash. They include
+.IP "first" 4
+.IX Item "first"
+Returns the first element in the group.
+.IP "count" 4
+.IX Item "count"
+Returns the number of elements in the group, including undefined elements, much
+like \s-1SQL\s0's \s-1COUNT\s0(*).
+.IP "avg" 4
+.IX Item "avg"
+Returns the average of defined elements in the group.
+.IP "sum" 4
+.IX Item "sum"
+Returns the sum of elements in the group.
+.PP
+Here's an example of grouping at work. Suppose you have a very busy server with
+hundreds of open connections, and you want to see how many connections are in
+what status. Using the built-in grouping rules, you can press 'Q' to enter
+\&\*(L"Q: Query List\*(R" mode. Press '=' to toggle grouping (if necessary, select the
+\&\*(L"processlist\*(R" table when prompted).
+.PP
+Your display might now look like the following:
+.PP
+.Vb 1
+\& Query List (? for help) localhost, 32:33, 0.11 QPS, 1 thd, 5.0.38\-log
+.Ve
+.PP
+.Vb 5
+\& CXN Cmd Cnt ID User Host Time Query
+\& localhost Query 49 12933 webusr localhost 19:38 SELECT * FROM
+\& localhost Sending Da 23 2383 webusr localhost 12:43 SELECT col1,
+\& localhost Sleep 120 140 webusr localhost 5:18:12
+\& localhost Statistics 12 19213 webusr localhost 01:19 SELECT * FROM
+.Ve
+.PP
+That's actually quite a worrisome picture. You've got a lot of idle connections
+(Sleep), and some connections executing queries (Query and Sending Data).
+That's okay, but you also have a lot in Statistics status, collectively spending
+over a minute. That means the query optimizer is having a really hard time
+optimizing your statements. Something is wrong; it should normally take
+milliseconds to optimize queries. You might not have seen this pattern if you
+didn't look at your connections in aggregate. (This is a made-up example, but
+it can happen in real life).
+.Sh "\s-1PIVOTING\s0"
+.IX Subsection "PIVOTING"
+innotop can pivot a table for more compact display, similar to a Pivot Table in
+a spreadsheet (also known as a crosstab). Pivoting a table makes columns into
+rows. Assume you start with this table:
+.PP
+.Vb 4
+\& foo bar
+\& === ===
+\& 1 3
+\& 2 4
+.Ve
+.PP
+After pivoting, the table will look like this:
+.PP
+.Vb 4
+\& name set0 set1
+\& ==== ==== ====
+\& foo 1 2
+\& bar 3 4
+.Ve
+.PP
+To get reasonable results, you might need to group as well as pivoting.
+innotop currently does this for \*(L"S: Variables & Status\*(R" mode.
+.Sh "\s-1COLORS\s0"
+.IX Subsection "COLORS"
+By default, innotop highlights rows with color so you can see at a glance which
+rows are more important. You can customize the colorization rules and add your
+own to any table. Open the table editor with the '^' key, choose a table if
+needed, and press 'o' to open the color editor dialog.
+.PP
+The color editor dialog displays the rules applied to the table, in the order
+they are evaluated. Each row is evaluated against each rule to see if the rule
+matches the row; if it does, the row gets the specified color, and no further
+rules are evaluated. The rules look like the following:
+.PP
+.Vb 9
+\& state eq Locked black on_red
+\& cmd eq Sleep white
+\& user eq system user white
+\& cmd eq Connect white
+\& cmd eq Binlog Dump white
+\& time > 600 red
+\& time > 120 yellow
+\& time > 60 green
+\& time > 30 cyan
+.Ve
+.PP
+This is the default rule set for the \*(L"processlist\*(R" table. In order of
+priority, these rules make locked queries black on a red background, \*(L"gray out\*(R"
+connections from replication and sleeping queries, and make queries turn from
+cyan to red as they run longer.
+.PP
+(For some reason, the \s-1ANSI\s0 color code \*(L"white\*(R" is actually a light gray. Your
+terminal's display may vary; experiment to find colors you like).
+.PP
+You can use keystrokes to move the rules up and down, which re-orders their
+priority. You can also delete rules and add new ones. If you add a new rule,
+innotop prompts you for the column, an operator for the comparison, a value
+against which to compare the column, and a color to assign if the rule matches.
+There is auto-completion and prompting at each step.
+.PP
+The value in the third step needs to be correctly quoted. innotop does not try
+to quote the value because it doesn't know whether it should treat the value as
+a string or a number. If you want to compare the column against a string, as
+for example in the first rule above, you should enter 'Locked' surrounded by
+quotes. If you get an error message about a bareword, you probably should have
+quoted something.
+.Sh "\s-1EXPRESSIONS\s0"
+.IX Subsection "EXPRESSIONS"
+Expressions are at the core of how innotop works, and are what enables you to
+extend innotop as you wish. Recall the table lifecycle explained in
+\&\*(L"\s-1TABLES\s0\*(R". Expressions are used in the earliest step, where it extracts
+values from a data source to form rows.
+.PP
+It does this by calling a subroutine for each column, passing it the source data
+set, a set of current values, and a set of previous values. These are all
+needed so the subroutine can calculate things like the difference between this
+tick and the previous tick.
+.PP
+The subroutines that extract the data from the set are compiled from
+expressions. This gives significantly more power than just naming the values to
+fill the columns, because it allows the column's value to be calculated from
+whatever data is necessary, but avoids the need to write complicated and lengthy
+Perl code.
+.PP
+innotop begins with a string of text that can look as simple as a value's name
+or as complicated as a full-fledged Perl expression. It looks at each
+\&'bareword' token in the string and decides whether it's supposed to be a key
+into the \f(CW$set\fR hash. A bareword is an unquoted value that isn't already
+surrounded by code-ish things like dollar signs or curly brackets. If innotop
+decides that the bareword isn't a function or other valid Perl code, it converts
+it into a hash access. After the whole string is processed, innotop compiles a
+subroutine, like this:
+.PP
+.Vb 5
+\& sub compute_column_value {
+\& my ( $set, $cur, $pre ) = @_;
+\& my $val = # EXPANDED STRING GOES HERE
+\& return $val;
+\& }
+.Ve
+.PP
+Here's a concrete example, taken from the header table \*(L"q_header\*(R" in \*(L"Q: Query List\*(R" mode. This expression calculates the qps, or Queries Per Second,
+column's values, from the values returned by \s-1SHOW\s0 \s-1STATUS:\s0
+.PP
+.Vb 1
+\& Questions/Uptime_hires
+.Ve
+.PP
+innotop decides both words are barewords, and transforms this expression into
+the following Perl code:
+.PP
+.Vb 1
+\& $set\->{Questions}/$set\->{Uptime_hires}
+.Ve
+.PP
+When surrounded by the rest of the subroutine's code, this is executable Perl
+that calculates a high-resolution queries-per-second value.
+.PP
+The arguments to the subroutine are named \f(CW$set\fR, \f(CW$cur\fR, and \f(CW$pre\fR. In most cases,
+\&\f(CW$set\fR and \f(CW$cur\fR will be the same values. However, if \*(L"status_inc\*(R" is set, \f(CW$cur\fR
+will not be the same as \f(CW$set\fR, because \f(CW$set\fR will already contain values that are
+the incremental difference between \f(CW$cur\fR and \f(CW$pre\fR.
+.PP
+Every column in innotop is computed by subroutines compiled in the same fashion.
+There is no difference between innotop's built-in columns and user-defined
+columns. This keeps things consistent and predictable.
+.Sh "\s-1TRANSFORMATIONS\s0"
+.IX Subsection "TRANSFORMATIONS"
+Transformations change how a value is rendered. For example, they can take a
+number of seconds and display it in H:M:S format. The following transformations
+are defined:
+.IP "commify" 4
+.IX Item "commify"
+Adds commas to large numbers every three decimal places.
+.IP "dulint_to_int" 4
+.IX Item "dulint_to_int"
+Accepts two unsigned integers and converts them into a single longlong. This is
+useful for certain operations with InnoDB, which uses two integers as
+transaction identifiers, for example.
+.IP "no_ctrl_char" 4
+.IX Item "no_ctrl_char"
+Removes quoted control characters from the value. This is affected by the
+\&\*(L"charset\*(R" configuration variable.
+.Sp
+This transformation only operates within quoted strings, for example, values to
+a \s-1SET\s0 clause in an \s-1UPDATE\s0 statement. It will not alter the \s-1UPDATE\s0 statement,
+but will collapse the quoted string to [\s-1BINARY\s0] or [\s-1TEXT\s0], depending on the
+charset.
+.IP "percent" 4
+.IX Item "percent"
+Converts a number to a percentage by multiplying it by two, formatting it with
+\&\*(L"num_digits\*(R" digits after the decimal point, and optionally adding a percent
+sign (see \*(L"show_percent\*(R").
+.IP "secs_to_time" 4
+.IX Item "secs_to_time"
+Formats a number of seconds as time in days+hours:minutes:seconds format.
+.IP "set_precision" 4
+.IX Item "set_precision"
+Formats numbers with \*(L"num_digits\*(R" number of digits after the decimal point.
+.IP "shorten" 4
+.IX Item "shorten"
+Formats a number as a unit of 1024 (k/M/G/T) and with \*(L"num_digits\*(R" number of
+digits after the decimal point.
+.Sh "\s-1TABLE\s0 \s-1EDITOR\s0"
+.IX Subsection "TABLE EDITOR"
+The innotop table editor lets you customize tables with keystrokes. You start
+the table editor with the '^' key. If there's more than one table on the
+screen, it will prompt you to choose one of them. Once you do, innotop will
+show you something like this:
+.PP
+.Vb 1
+\& Editing table definition for Buffer Pool. Press ? for help, q to quit.
+.Ve
+.PP
+.Vb 9
+\& name hdr label src
+\& cxn CXN Connection from which cxn
+\& buf_pool_size Size Buffer pool size IB_bp_buf_poo
+\& buf_free Free Bufs Buffers free in the b IB_bp_buf_fre
+\& pages_total Pages Pages total IB_bp_pages_t
+\& pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m
+\& buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo
+\& total_mem_alloc Memory Total memory allocate IB_bp_total_m
+\& add_pool_alloc Add\(aql Pool Additonal pool alloca IB_bp_add_poo
+.Ve
+.PP
+The first line shows which table you're editing, and reminds you again to press
+\&'?' for a list of key mappings. The rest is a tabular representation of the
+table's columns, because that's likely what you're trying to edit. However, you
+can edit more than just the table's columns; this screen can start the filter
+editor, color rule editor, and more.
+.PP
+Each row in the display shows a single column in the table you're editing, along
+with a couple of its properties such as its header and source expression (see
+\&\*(L"\s-1EXPRESSIONS\s0\*(R").
+.PP
+The key mappings are Vim\-style, as in many other places. Pressing 'j' and 'k'
+moves the highlight up or down. You can then (d)elete or (e)dit the highlighted
+column. You can also (a)dd a column to the table. This actually just activates
+one of the columns already defined for the table; it prompts you to choose from
+among the columns available but not currently displayed. Finally, you can
+re-order the columns with the '+' and '\-' keys.
+.PP
+You can do more than just edit the columns with the table editor, you can also
+edit other properties, such as the table's sort expression and group-by
+expression. Press '?' to see the full list, of course.
+.PP
+If you want to really customize and create your own column, as opposed to just
+activating a built-in one that's not currently displayed, press the (n)ew key,
+and innotop will prompt you for the information it needs:
+.IP "\(bu" 4
+The column name: this needs to be a word without any funny characters, e.g. just
+letters, numbers and underscores.
+.IP "\(bu" 4
+The column header: this is the label that appears at the top of the column, in
+the table header. This can have spaces and funny characters, but be careful not
+to make it too wide and waste space on\-screen.
+.IP "\(bu" 4
+The column's data source: this is an expression that determines what data from
+the source (see \*(L"\s-1TABLES\s0\*(R") innotop will put into the column. This can just be
+the name of an item in the source, or it can be a more complex expression, as
+described in \*(L"\s-1EXPRESSIONS\s0\*(R".
+.PP
+Once you've entered the required data, your table has a new column. There is no
+difference between this column and the built-in ones; it can have all the same
+properties and behaviors. innotop will write the column's definition to the
+configuration file, so it will persist across sessions.
+.PP
+Here's an example: suppose you want to track how many times your slaves have
+retried transactions. According to the MySQL manual, the
+Slave_retried_transactions status variable gives you that data: \*(L"The total
+number of times since startup that the replication slave \s-1SQL\s0 thread has retried
+transactions. This variable was added in version 5.0.4.\*(R" This is appropriate to
+add to the \*(L"slave_sql_status\*(R" table.
+.PP
+To add the column, switch to the replication-monitoring mode with the 'M' key,
+and press the '^' key to start the table editor. When prompted, choose
+slave_sql_status as the table, then press 'n' to create the column. Type
+\&'retries' as the column name, 'Retries' as the column header, and
+\&'Slave_retried_transactions' as the source. Now the column is created, and you
+see the table editor screen again. Press 'q' to exit the table editor, and
+you'll see your column at the end of the table.
+.SH "VARIABLE SETS"
+.IX Header "VARIABLE SETS"
+Variable sets are used in \*(L"S: Variables & Status\*(R" mode to define more easily
+what variables you want to monitor. Behind the scenes they are compiled to a
+list of expressions, and then into a column list so they can be treated just
+like columns in any other table, in terms of data extraction and
+transformations. However, you're protected from the tedious details by a syntax
+that ought to feel very natural to you: a \s-1SQL\s0 \s-1SELECT\s0 list.
+.PP
+The data source for variable sets, and indeed the entire S mode, is the
+combination of \s-1SHOW\s0 \s-1STATUS\s0, \s-1SHOW\s0 \s-1VARIABLES\s0, and \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. Imagine
+that you had a huge table with one column per variable returned from those
+statements. That's the data source for variable sets. You can now query this
+data source just like you'd expect. For example:
+.PP
+.Vb 1
+\& Questions, Uptime, Questions/Uptime as QPS
+.Ve
+.PP
+Behind the scenes innotop will split that variable set into three expressions,
+compile them and turn them into a table definition, then extract as usual. This
+becomes a \*(L"variable set,\*(R" or a \*(L"list of variables you want to monitor.\*(R"
+.PP
+innotop lets you name and save your variable sets, and writes them to the
+configuration file. You can choose which variable set you want to see with the
+\&'c' key, or activate the next and previous sets with the '>' and '<' keys.
+There are many built-in variable sets as well, which should give you a good
+start for creating your own. Press 'e' to edit the current variable set, or
+just to see how it's defined. To create a new one, just press 'c' and type its
+name.
+.PP
+You may want to use some of the functions listed in \*(L"\s-1TRANSFORMATIONS\s0\*(R" to help
+format the results. In particular, \*(L"set_precision\*(R" is often useful to limit
+the number of digits you see. Extending the above example, here's how:
+.PP
+.Vb 1
+\& Questions, Uptime, set_precision(Questions/Uptime) as QPS
+.Ve
+.PP
+Actually, this still needs a little more work. If your \*(L"interval\*(R" is less
+than one second, you might be dividing by zero because Uptime is incremental in
+this mode by default. Instead, use Uptime_hires:
+.PP
+.Vb 1
+\& Questions, Uptime, set_precision(Questions/Uptime_hires) as QPS
+.Ve
+.PP
+This example is simple, but it shows how easy it is to choose which variables
+you want to monitor.
+.SH "PLUGINS"
+.IX Header "PLUGINS"
+innotop has a simple but powerful plugin mechanism by which you can extend
+or modify its existing functionality, and add new functionality. innotop's
+plugin functionality is event\-based: plugins register themselves to be called
+when events happen. They then have a chance to influence the event.
+.PP
+An innotop plugin is a Perl module placed in innotop's \*(L"plugin_dir\*(R"
+directory. On \s-1UNIX\s0 systems, you can place a symbolic link to the module instead
+of putting the actual file there. innotop automatically discovers the file. If
+there is a corresponding entry in the \*(L"plugins\*(R" configuration file section,
+innotop loads and activates the plugin.
+.PP
+The module must conform to innotop's plugin interface. Additionally, the source
+code of the module must be written in such a way that innotop can inspect the
+file and determine the package name and description.
+.Sh "Package Source Convention"
+.IX Subsection "Package Source Convention"
+innotop inspects the plugin module's source to determine the Perl package name.
+It looks for a line of the form \*(L"package Foo;\*(R" and if found, considers the
+plugin's package name to be Foo. Of course the package name can be a valid Perl
+package name, with double semicolons and so on.
+.PP
+It also looks for a description in the source code, to make the plugin editor
+more human\-friendly. The description is a comment line of the form \*(L"#
+description: Foo\*(R", where \*(L"Foo\*(R" is the text innotop will consider to be the
+plugin's description.
+.Sh "Plugin Interface"
+.IX Subsection "Plugin Interface"
+The innotop plugin interface is quite simple: innotop expects the plugin to be
+an object-oriented module it can call certain methods on. The methods are
+.IP "new(%variables)" 4
+.IX Item "new(%variables)"
+This is the plugin's constructor. It is passed a hash of innotop's variables,
+which it can manipulate (see \*(L"Plugin Variables\*(R"). It must return a reference
+to the newly created plugin object.
+.Sp
+At construction time, innotop has only loaded the general configuration and
+created the default built-in variables with their default contents (which is
+quite a lot). Therefore, the state of the program is exactly as in the innotop
+source code, plus the configuration variables from the \*(L"general\*(R" section in
+the config file.
+.Sp
+If your plugin manipulates the variables, it is changing global data, which is
+shared by innotop and all plugins. Plugins are loaded in the order they're
+listed in the config file. Your plugin may load before or after another plugin,
+so there is a potential for conflict or interaction between plugins if they
+modify data other plugins use or modify.
+.IP "\fIregister_for_events()\fR" 4
+.IX Item "register_for_events()"
+This method must return a list of events in which the plugin is interested, if
+any. See \*(L"Plugin Events\*(R" for the defined events. If the plugin returns an
+event that's not defined, the event is ignored.
+.IP "event handlers" 4
+.IX Item "event handlers"
+The plugin must implement a method named the same as each event for which it has
+registered. In other words, if the plugin returns qw(foo bar) from
+\&\fIregister_for_events()\fR, it must have \fIfoo()\fR and \fIbar()\fR methods. These methods are
+callbacks for the events. See \*(L"Plugin Events\*(R" for more details about each
+event.
+.Sh "Plugin Variables"
+.IX Subsection "Plugin Variables"
+The plugin's constructor is passed a hash of innotop's variables, which it can
+manipulate. It is probably a good idea if the plugin object saves a copy of it
+for later use. The variables are defined in the innotop variable
+\&\f(CW%pluggable_vars\fR, and are as follows:
+.IP "action_for" 4
+.IX Item "action_for"
+A hashref of key mappings. These are innotop's global hot\-keys.
+.IP "agg_funcs" 4
+.IX Item "agg_funcs"
+A hashref of functions that can be used for grouping. See \*(L"\s-1GROUPING\s0\*(R".
+.IP "config" 4
+.IX Item "config"
+The global configuration hash.
+.IP "connections" 4
+.IX Item "connections"
+A hashref of connection specifications. These are just specifications of how to
+connect to a server.
+.IP "dbhs" 4
+.IX Item "dbhs"
+A hashref of innotop's database connections. These are actual \s-1DBI\s0 connection
+objects.
+.IP "filters" 4
+.IX Item "filters"
+A hashref of filters applied to table rows. See \*(L"\s-1FILTERS\s0\*(R" for more.
+.IP "modes" 4
+.IX Item "modes"
+A hashref of modes. See \*(L"\s-1MODES\s0\*(R" for more.
+.IP "server_groups" 4
+.IX Item "server_groups"
+A hashref of server groups. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R".
+.IP "tbl_meta" 4
+.IX Item "tbl_meta"
+A hashref of innotop's table meta\-data, with one entry per table (see
+\&\*(L"\s-1TABLES\s0\*(R" for more information).
+.IP "trans_funcs" 4
+.IX Item "trans_funcs"
+A hashref of transformation functions. See \*(L"\s-1TRANSFORMATIONS\s0\*(R".
+.IP "var_sets" 4
+.IX Item "var_sets"
+A hashref of variable sets. See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R".
+.Sh "Plugin Events"
+.IX Subsection "Plugin Events"
+Each event is defined somewhere in the innotop source code. When innotop runs
+that code, it executes the callback function for each plugin that expressed its
+interest in the event. innotop passes some data for each event. The events are
+defined in the \f(CW%event_listener_for\fR variable, and are as follows:
+.ie n .IP "extract_values($set, $cur\fR, \f(CW$pre\fR, \f(CW$tbl)" 4
+.el .IP "extract_values($set, \f(CW$cur\fR, \f(CW$pre\fR, \f(CW$tbl\fR)" 4
+.IX Item "extract_values($set, $cur, $pre, $tbl)"
+This event occurs inside the function that extracts values from a data source.
+The arguments are the set of values, the current values, the previous values,
+and the table name.
+.IP "set_to_tbl" 4
+.IX Item "set_to_tbl"
+Events are defined at many places in this subroutine, which is responsible for
+turning an arrayref of hashrefs into an arrayref of lines that can be printed to
+the screen. The events all pass the same data: an arrayref of rows and the name
+of the table being created. The events are set_to_tbl_pre_filter,
+set_to_tbl_pre_sort,set_to_tbl_pre_group, set_to_tbl_pre_colorize,
+set_to_tbl_pre_transform, set_to_tbl_pre_pivot, set_to_tbl_pre_create,
+set_to_tbl_post_create.
+.IP "draw_screen($lines)" 4
+.IX Item "draw_screen($lines)"
+This event occurs inside the subroutine that prints the lines to the screen.
+\&\f(CW$lines\fR is an arrayref of strings.
+.Sh "Simple Plugin Example"
+.IX Subsection "Simple Plugin Example"
+The easiest way to explain the plugin functionality is probably with a simple
+example. The following module adds a column to the beginning of every table and
+sets its value to 1.
+.PP
+.Vb 2
+\& use strict;
+\& use warnings FATAL => \(aqall\(aq;
+.Ve
+.PP
+.Vb 2
+\& package Innotop::Plugin::Example;
+\& # description: Adds an \(aqexample\(aq column to every table
+.Ve
+.PP
+.Vb 4
+\& sub new {
+\& my ( $class, %vars ) = @_;
+\& # Store reference to innotop\(aqs variables in $self
+\& my $self = bless { %vars }, $class;
+.Ve
+.PP
+.Vb 11
+\& # Design the example column
+\& my $col = {
+\& hdr => \(aqExample\(aq,
+\& just => \(aq\(aq,
+\& dec => 0,
+\& num => 1,
+\& label => \(aqExample\(aq,
+\& src => \(aqexample\(aq, # Get data from this column in the data source
+\& tbl => \(aq\(aq,
+\& trans => [],
+\& };
+.Ve
+.PP
+.Vb 8
+\& # Add the column to every table.
+\& my $tbl_meta = $vars{tbl_meta};
+\& foreach my $tbl ( values %$tbl_meta ) {
+\& # Add the column to the list of defined columns
+\& $tbl\->{cols}\->{example} = $col;
+\& # Add the column to the list of visible columns
+\& unshift @{$tbl\->{visible}}, \(aqexample\(aq;
+\& }
+.Ve
+.PP
+.Vb 3
+\& # Be sure to return a reference to the object.
+\& return $self;
+\& }
+.Ve
+.PP
+.Vb 5
+\& # I\(aqd like to be called when a data set is being rendered into a table, please.
+\& sub register_for_events {
+\& my ( $self ) = @_;
+\& return qw(set_to_tbl_pre_filter);
+\& }
+.Ve
+.PP
+.Vb 8
+\& # This method will be called when the event fires.
+\& sub set_to_tbl_pre_filter {
+\& my ( $self, $rows, $tbl ) = @_;
+\& # Set the example column\(aqs data source to the value 1.
+\& foreach my $row ( @$rows ) {
+\& $row\->{example} = 1;
+\& }
+\& }
+.Ve
+.PP
+.Vb 1
+\& 1;
+.Ve
+.Sh "Plugin Editor"
+.IX Subsection "Plugin Editor"
+The plugin editor lets you view the plugins innotop discovered and activate or
+deactivate them. Start the editor by pressing $ to start the configuration
+editor from any mode. Press the 'p' key to start the plugin editor. You'll see
+a list of plugins innotop discovered. You can use the 'j' and 'k' keys to move
+the highlight to the desired one, then press the * key to toggle it active or
+inactive. Exit the editor and restart innotop for the changes to take effect.
+.SH "SQL STATEMENTS"
+.IX Header "SQL STATEMENTS"
+innotop uses a limited set of \s-1SQL\s0 statements to retrieve data from MySQL for
+display. The statements are customized depending on the server version against
+which they are executed; for example, on MySQL 5 and newer, \s-1INNODB_STATUS\s0
+executes \*(L"\s-1SHOW\s0 \s-1ENGINE\s0 \s-1INNODB\s0 \s-1STATUS\s0\*(R", while on earlier versions it executes
+\&\*(L"\s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0\*(R". The statements are as follows:
+.PP
+.Vb 12
+\& Statement SQL executed
+\& =================== ===============================
+\& INNODB_STATUS SHOW [ENGINE] INNODB STATUS
+\& KILL_CONNECTION KILL
+\& KILL_QUERY KILL QUERY
+\& OPEN_TABLES SHOW OPEN TABLES
+\& PROCESSLIST SHOW FULL PROCESSLIST
+\& SHOW_MASTER_LOGS SHOW MASTER LOGS
+\& SHOW_MASTER_STATUS SHOW MASTER STATUS
+\& SHOW_SLAVE_STATUS SHOW SLAVE STATUS
+\& SHOW_STATUS SHOW [GLOBAL] STATUS
+\& SHOW_VARIABLES SHOW [GLOBAL] VARIABLES
+.Ve
+.SH "DATA SOURCES"
+.IX Header "DATA SOURCES"
+Each time innotop extracts values to create a table (see \*(L"\s-1EXPRESSIONS\s0\*(R" and
+\&\*(L"\s-1TABLES\s0\*(R"), it does so from a particular data source. Largely because of the
+complex data extracted from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, this is slightly messy. \s-1SHOW\s0
+\&\s-1INNODB\s0 \s-1STATUS\s0 contains a mixture of single values and repeated values that form
+nested data sets.
+.PP
+Whenever innotop fetches data from MySQL, it adds two extra bits to each set:
+cxn and Uptime_hires. cxn is the name of the connection from which the data
+came. Uptime_hires is a high-resolution version of the server's Uptime status
+variable, which is important if your \*(L"interval\*(R" setting is sub\-second.
+.PP
+Here are the kinds of data sources from which data is extracted:
+.IP "\s-1STATUS_VARIABLES\s0" 4
+.IX Item "STATUS_VARIABLES"
+This is the broadest category, into which the most kinds of data fall. It
+begins with the combination of \s-1SHOW\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1VARIABLES\s0, but other sources
+may be included as needed, for example, \s-1SHOW\s0 \s-1MASTER\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1SLAVE\s0
+\&\s-1STATUS\s0, as well as many of the non-repeated values from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+.IP "\s-1DEADLOCK_LOCKS\s0" 4
+.IX Item "DEADLOCK_LOCKS"
+This data is extracted from the transaction list in the \s-1LATEST\s0 \s-1DETECTED\s0 \s-1DEADLOCK\s0
+section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. It is nested two levels deep: transactions, then
+locks.
+.IP "\s-1DEADLOCK_TRANSACTIONS\s0" 4
+.IX Item "DEADLOCK_TRANSACTIONS"
+This data is from the transaction list in the \s-1LATEST\s0 \s-1DETECTED\s0 \s-1DEADLOCK\s0
+section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. It is nested one level deep.
+.IP "\s-1EXPLAIN\s0" 4
+.IX Item "EXPLAIN"
+This data is from the result set returned by \s-1EXPLAIN\s0.
+.IP "\s-1INNODB_TRANSACTIONS\s0" 4
+.IX Item "INNODB_TRANSACTIONS"
+This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+.IP "\s-1IO_THREADS\s0" 4
+.IX Item "IO_THREADS"
+This data is from the list of threads in the the \s-1FILE\s0 I/O section of \s-1SHOW\s0 \s-1INNODB\s0
+\&\s-1STATUS\s0.
+.IP "\s-1INNODB_LOCKS\s0" 4
+.IX Item "INNODB_LOCKS"
+This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 and is nested
+two levels deep.
+.IP "\s-1OPEN_TABLES\s0" 4
+.IX Item "OPEN_TABLES"
+This data is from \s-1SHOW\s0 \s-1OPEN\s0 \s-1TABLES\s0.
+.IP "\s-1PROCESSLIST\s0" 4
+.IX Item "PROCESSLIST"
+This data is from \s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0.
+.IP "\s-1OS_WAIT_ARRAY\s0" 4
+.IX Item "OS_WAIT_ARRAY"
+This data is from the \s-1SEMAPHORES\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 and is nested one
+level deep. It comes from the lines that look like this:
+.Sp
+.Vb 1
+\& \-\-Thread 1568861104 has waited at btr0cur.c line 424 ....
+.Ve
+.SH "MYSQL PRIVILEGES"
+.IX Header "MYSQL PRIVILEGES"
+.IP "\(bu" 4
+You must connect to MySQL as a user who has the \s-1SUPER\s0 privilege for many of the
+functions.
+.IP "\(bu" 4
+If you don't have the \s-1SUPER\s0 privilege, you can still run some functions, but you
+won't necessarily see all the same data.
+.IP "\(bu" 4
+You need the \s-1PROCESS\s0 privilege to see the list of currently running queries in Q
+mode.
+.IP "\(bu" 4
+You need special privileges to start and stop slave servers.
+.IP "\(bu" 4
+You need appropriate privileges to create and drop the deadlock tables if needed
+(see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R").
.SH "SYSTEM REQUIREMENTS"
.IX Header "SYSTEM REQUIREMENTS"
-You must connect to the \s-1DB\s0 server as a user who has the \s-1SUPER\s0 privilege for
-many of the functions. If you don't have the \s-1SUPER\s0 privilege, you may still
-be able to run some functions.
+You need Perl to run innotop, of course. You also need a few Perl modules: \s-1DBI\s0,
+DBD::mysql, Term::ReadKey, and Time::HiRes. These should be included with most
+Perl distributions, but in case they are not, I recommend using versions
+distributed with your operating system or Perl distribution, not from \s-1CPAN\s0.
+Term::ReadKey in particular has been known to cause problems if installed from
+\&\s-1CPAN\s0.
.PP
-I think everything you need to run innotop is distributed either with Perl, or
-with innotop itself. You need \s-1DBI\s0 and DBD::mysql. You also need the
-InnoDBParser module, and Term::ReadKey. If you have Time::HiRes, innotop will
-use it. If you have Term::ANSIColor, innotop will use it to format headers more
-readably and compactly. (Under Microsoft Windows, you also need
-Win32::Console::ANSI for terminal formatting codes to be honored). If you
-install Term::ReadLine, preferably Term::ReadLine::Gnu, you'll get nice
-auto-completion support.
+If you have Term::ANSIColor, innotop will use it to format headers more readably
+and compactly. (Under Microsoft Windows, you also need Win32::Console::ANSI for
+terminal formatting codes to be honored). If you install Term::ReadLine,
+preferably Term::ReadLine::Gnu, you'll get nice auto-completion support.
.PP
I run innotop on Gentoo GNU/Linux, Debian and Ubuntu, and I've had feedback from
people successfully running it on Red Hat, CentOS, Solaris, and Mac \s-1OSX\s0. I
@@ -352,17 +2002,61 @@
I don't know for sure. It also runs on Windows under ActivePerl without
problem.
.PP
-I have perl v5.8.8 installed, and I've had reports of it working on 5.8.5 but
-I don't know about other versions.
-.PP
-I use innotop on MySQL version 4.1 and 5.0, and have heard of others using it
-on these same versions and 5.1.
+I use innotop on MySQL versions 3.23.58, 4.0.27, 4.1.0, 4.1.22, 5.0.26, 5.1.15,
+and 5.2.3. If it doesn't run correctly for you, that is a bug and I hope you
+report it.
.SH "FILES"
.IX Header "FILES"
-$HOMEDIR/.innotop is used to store configuration information.
+$HOMEDIR/.innotop is used to store configuration information. Files include the
+configuration file innotop.ini, the core_dump file which contains verbose error
+messages if \*(L"debug\*(R" is enabled, and the plugins/ subdirectory.
+.SH "GLOSSARY OF TERMS"
+.IX Header "GLOSSARY OF TERMS"
+.IP "tick" 4
+.IX Item "tick"
+A tick is a refresh event, when innotop re-fetches data from connections and
+displays it.
+.SH "ACKNOWLEDGEMENTS"
+.IX Header "ACKNOWLEDGEMENTS"
+I'm grateful to the following people for various reasons, and hope I haven't
+forgotten to include anyone:
+.PP
+Allen K. Smith,
+Aurimas Mikalauskas,
+Bartosz Fenski,
+Brian Miezejewski,
+Christian Hammers,
+Cyril Scetbon,
+Dane Miller,
+David Multer,
+Dr. Frank Ullrich,
+Giuseppe Maxia,
+Google.com Site Reliability Engineers,
+Jan Pieter Kunst,
+Jari Aalto,
+Jay Pipes,
+Jeremy Zawodny,
+Johan Idren,
+Kristian Kohntopp,
+Lenz Grimmer,
+Maciej Dobrzanski,
+Michiel Betel,
+MySQL \s-1AB\s0,
+Paul McCullagh,
+Sebastien Estienne,
+Sourceforge.net,
+Steven Kreuzer,
+The Gentoo MySQL Team,
+Trevor Price,
+Yaar Schnitman,
+and probably more people I've neglected to include.
+.PP
+(If I misspelled your name, it's probably because I'm afraid of putting
+international characters into this documentation; earlier versions of Perl might
+not be able to compile it then).
.SH "COPYRIGHT, LICENSE AND WARRANTY"
.IX Header "COPYRIGHT, LICENSE AND WARRANTY"
-This program is copyright (c) 2006 Baron Schwartz, baron at xaprb dot com.
+This program is copyright (c) 2006 Baron Schwartz.
Feedback and improvements are welcome.
.PP
\&\s-1THIS\s0 \s-1PROGRAM\s0 \s-1IS\s0 \s-1PROVIDED\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1AND\s0 \s-1WITHOUT\s0 \s-1ANY\s0 \s-1EXPRESS\s0 \s-1OR\s0 \s-1IMPLIED\s0
@@ -382,10 +2076,11 @@
Execute innotop and press '!' to see this information at any time.
.SH "AUTHOR"
.IX Header "AUTHOR"
-Baron Schwartz, baron at xaprb dot com.
+Baron Schwartz.
.SH "BUGS"
.IX Header "BUGS"
-If you find any problems with innotop, please contact me. Specifically, if
-you find any problems with parsing the InnoDB monitor output, I would greatly
-appreciate you sending me the full text of the monitor output that caused the
-problem.
+You can report bugs, ask for improvements, and get other help and support at
+<http://sourceforge.net/projects/innotop>. There are mailing lists, forums,
+a bug tracker, etc. Please use these instead of contacting me directly, as it
+makes my job easier and benefits others if the discussions are permanent and
+public. Of course, if you need to contact me in private, please do.
Modified: branches/sid-5.1/debian/changelog
===================================================================
--- branches/sid-5.1/debian/changelog 2007-11-09 19:08:33 UTC (rev 979)
+++ branches/sid-5.1/debian/changelog 2007-11-09 19:12:55 UTC (rev 980)
@@ -192,6 +192,7 @@
mysql-dfsg-5.0 (5.0.45-2) UNRELEASED; urgency=low
* NOT RELEASED YET
+ * Package is now team-maintained. (closes: #421026)
[ Sean Finney ]
* New/updated debconf translations:
@@ -206,9 +207,10 @@
* Suggest usage of an update statement on the user table to change the mysql
root user password instead using mysqladmin, to catch all root users from
all hosts. (closes: #435744)
- * Updated innotop to 1.4.3 release.
+ * Update innotop to 1.6.0 release.
+ * Add myself to uploaders.
- -- Norbert Tretkowski <nobse at debian.org> Thu, 08 Nov 2007 20:03:58 +0100
+ -- Norbert Tretkowski <nobse at debian.org> Fri, 09 Nov 2007 20:07:39 +0100
mysql-dfsg-5.0 (5.0.45-1) unstable; urgency=low
Modified: branches/sid-5.1/debian/control
===================================================================
--- branches/sid-5.1/debian/control 2007-11-09 19:08:33 UTC (rev 979)
+++ branches/sid-5.1/debian/control 2007-11-09 19:12:55 UTC (rev 980)
@@ -2,7 +2,7 @@
Section: misc
Priority: optional
Maintainer: Debian MySQL Maintainers <pkg-mysql-maint at lists.alioth.debian.org>
-Uploaders: Christian Hammers <ch at debian.org>, Sean Finney <seanius at debian.org>, Adam Conrad <adconrad at 0c3.net>, Monty Taylor <mtaylor at mysql.com>
+Uploaders: Christian Hammers <ch at debian.org>, Sean Finney <seanius at debian.org>, Adam Conrad <adconrad at 0c3.net>, Monty Taylor <mtaylor at mysql.com>, Norbert Tretkowski <nobse at debian.org>
Build-Depends: libtool (>= 1.4.2-7), procps | hurd, debhelper (>= 4.1.16), file (>= 3.28-1), libncurses5-dev (>= 5.0-6), perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), zlib1g-dev (>= 1:1.1.3-5), libreadline5-dev | libreadline-dev, psmisc, po-debconf, chrpath, automake1.9, doxygen, texlive-latex-base, gs, dpatch, gawk, bison, linux-libc-dev [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64]
Standards-Version: 3.7.2
More information about the Pkg-mysql-commits
mailing list