~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to debian/additions/mysqlreport

  • Committer: Bazaar Package Importer
  • Author(s): Christian Hammers
  • Date: 2007-03-18 20:52:33 UTC
  • Revision ID: james.westby@ubuntu.com-20070318205233-s4s2or1xz2dl564z
Tags: 5.0.32-10
Really fixed FTBFS on Sparc introduced with the "make -j" trick in 
5.0.32-8 (thanks to Frank Lichtenheld). Closes: #415026

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl -w
2
2
 
3
 
# mysqlreport v2.5 Sep 1 2006
 
3
# mysqlreport v3.0a Dec 12 2006
4
4
# http://hackmysql.com/mysqlreport
5
5
 
6
 
# mysqlreport makes a friendly report of important MySQL status values.
 
6
# mysqlreport makes an easy-to-read report of important MySQL status values.
7
7
# Copyright (C) 2006  Daniel Nichter
8
8
#
9
9
# This program is free software; you can redistribute it and/or
31
31
my $WIN = ($^O eq 'MSWin32' ? 1 : 0);
32
32
my %op;
33
33
my %mycnf; # ~/.my.cnf
34
 
   $mycnf{'user'} = $ENV{USER};
35
 
   $mycnf{'pass'} = '';
36
34
my ($tmpfile_fh, $tmpfile);
37
35
my ($stat_name, $stat_val, $stat_label);
38
36
my ($major, $minor, $patch, $x); # MySQL version
39
37
my (%stats, %vars); # SHOW STATUS, SHOW VARIABLES
40
 
my (%DMS_vals, %Com_vals);
 
38
my (%DMS_vals, %Com_vals, %ib_vals);
41
39
my ($dbh, $query);
42
40
my ($questions, $key_read_ratio, $key_write_ratio, $dms);
43
41
my ($key_cache_block_size, $key_buffer_used, $key_buffer_usage);
44
42
my ($qc_mem_used, $qc_hi_r, $qc_ip_r); # Query Cache
 
43
my ($need_myisam_vals, $need_innodb_vals);
 
44
my ($ib_bp_used, $ib_bp_total, $ib_bp_read_ratio);
45
45
 
46
46
GetOptions (
47
47
   \%op,
57
57
   "sas",
58
58
   "tab",
59
59
   "qcache",
 
60
   "id-only|ido|innodb-only",
 
61
   "id|innodb",
 
62
   "dpr|drp",
60
63
   "all",
61
 
   "infile=s",
 
64
   "infile|in=s",
62
65
   "outfile=s",
63
66
   "flush-status",
64
67
   "email=s",
67
70
 
68
71
show_help_and_exit() if $op{'help'};
69
72
 
70
 
$op{'host'} = 'localhost' if !have_op 'host';
71
 
$op{'port'} ||= 3306;
72
 
$op{'socket'} ||= '/var/run/mysqld/mysqld.sock';
73
 
 
74
73
get_user_mycnf() unless $op{'no-mycnf'};
75
74
 
76
 
$mycnf{'user'} = $op{'user'} if have_op 'user';
 
75
# Command line options override ~/.my.cnf
 
76
$mycnf{'host'}   = $op{'host'}   if have_op 'host';
 
77
$mycnf{'port'}   = $op{'port'}   if have_op 'port';
 
78
$mycnf{'socket'} = $op{'socket'} if have_op 'socket'; 
 
79
$mycnf{'user'}   = $op{'user'}   if have_op 'user';
 
80
 
 
81
# Default values if nothing else
 
82
$mycnf{'host'}   ||= 'localhost';
 
83
$mycnf{'port'}   ||= 3306;
 
84
$mycnf{'socket'} ||= '/var/run/mysqld/mysqld.sock'; # Debian default
 
85
$mycnf{'user'}   ||= $ENV{'USER'};
77
86
 
78
87
if(exists $op{'password'})
79
88
{
87
96
   else { $mycnf{'pass'} = $op{'password'}; } # Use password given on command line
88
97
}
89
98
 
90
 
if($op{'all'} and not defined $op{'com'}) { $op{'com'} = 3; };
 
99
if($op{'all'} and not defined $op{'com'})  { $op{'com'} = 3; }
91
100
if(defined $op{'com'} and $op{'com'} == 0) { $op{'com'} = 3; }
92
101
 
93
102
# Connect to MySQL
94
 
if(!have_op 'infile') {
95
 
   $dbh = DBI->connect("dbi:mysql::$op{host};port=$op{port};mysql_socket=$op{socket}", $mycnf{'user'}, $mycnf{'pass'}) or die;
 
103
if(!have_op 'infile')
 
104
{
 
105
   my $dsn;
 
106
 
 
107
   if(-S $mycnf{'socket'} && !have_op 'host') { $dsn = "DBI:mysql:mysql_socket=$mycnf{socket}";         }
 
108
   else                                       { $dsn = "DBI:mysql:host=$mycnf{host};port=$mycnf{port}"; }
 
109
 
 
110
   $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die;
96
111
}
97
112
 
98
113
# The report is written to a tmp file first.
99
114
# Later it will be moved to $op{'outfile'} or emailed $op{'email'} if needed.
100
115
($tmpfile_fh, $tmpfile) = tempfile() or die("Can't open temporary file for writing: $!\n");
101
116
 
102
 
# Get status values and server system variables from MySQL or -infile
 
117
# Determine if we need MyISAM, InnoDB, or both vals, then
 
118
# get vals and system vars from MySQL or infile, then
 
119
# set vals for our own vars
 
120
which_vals();
103
121
get_vals_vars();
104
 
 
105
 
$questions = $stats{'Questions'};
106
 
$key_read_ratio  = sprintf "%.2f", ($stats{'Key_read_requests'} ? $stats{'Key_reads'} / $stats{'Key_read_requests'} : 0);
107
 
$key_write_ratio = sprintf "%.2f", ($stats{'Key_write_requests'} ? $stats{'Key_writes'} / $stats{'Key_write_requests'} : 0);
108
 
 
109
 
$key_cache_block_size = (defined $vars{'key_cache_block_size'} ? $vars{'key_cache_block_size'} : 1024);
110
 
$key_buffer_used = $stats{'Key_blocks_used'} * $key_cache_block_size;
111
 
 
112
 
if(defined $stats{'Key_blocks_unused'}) { # MySQL 4.1.2+
113
 
   $key_buffer_usage =  $vars{'key_buffer_size'} - ($stats{'Key_blocks_unused'} * $key_cache_block_size);
114
 
}
115
 
else { $key_buffer_usage = -1; }
116
 
 
117
 
# Data Manipulation Statements: http://dev.mysql.com/doc/mysql/en/Data_Manipulation.html
118
 
%DMS_vals = (
119
 
   SELECT  => $stats{'Com_select'},
120
 
   INSERT  => $stats{'Com_insert'}  + $stats{'Com_insert_select'},
121
 
   REPLACE => $stats{'Com_replace'} + $stats{'Com_replace_select'},
122
 
   UPDATE  => $stats{'Com_update'}  + (exists $stats{'Com_update_multi'} ? $stats{'Com_update_multi'} : 0),
123
 
   DELETE  => $stats{'Com_delete'}  + (exists $stats{'Com_delete_multi'} ? $stats{'Com_delete_multi'} : 0)
124
 
);
125
 
 
126
 
$dms = $DMS_vals{SELECT} + $DMS_vals{INSERT} + $DMS_vals{REPLACE} + $DMS_vals{UPDATE} + $DMS_vals{DELETE};
127
 
 
128
 
# Write the report
 
122
set_myisam_vals() if $need_myisam_vals;
 
123
set_ib_vals()     if $need_innodb_vals;
 
124
 
 
125
 
 
126
# Write the reports
129
127
select $tmpfile_fh;
130
 
$~ = 'KEY_BUFF_MAX', write;
131
 
if($key_buffer_usage != -1)     { $~ = 'KEY_BUFF_USAGE', write }
132
 
$~ = 'KEY_RATIOS', write;
133
 
if($op{'dtq'}    or $op{'all'}) { write_DTQ(); }
134
 
$~ = 'SLOW_DMS', write;
135
 
if($op{'dms'}    or $op{'all'}) { write_DMS(); }
136
 
if($op{'com'}    or $op{'all'}) { write_Com(); }
137
 
if($op{'sas'}    or $op{'all'}) { $~ = 'SAS', write; }
138
 
if($op{'qcache'} or $op{'all'}) { write_qcache(); }
139
 
$~ = 'REPORT_END', write;
140
 
$~ = 'TAB', write if $op{'tab'};
141
 
 
 
128
$~ = 'MYSQL_TIME', write;
 
129
if($need_myisam_vals)
 
130
{
 
131
   $~ = 'KEY_BUFF_MAX', write;
 
132
   if($key_buffer_usage != -1)     { $~ = 'KEY_BUFF_USAGE', write }
 
133
   $~ = 'KEY_RATIOS', write;
 
134
   if($op{'dtq'}    or $op{'all'}) { write_DTQ(); }
 
135
   $~ = 'SLOW_DMS', write;
 
136
   if($op{'dms'}    or $op{'all'}) { write_DMS(); }
 
137
   if($op{'com'}    or $op{'all'}) { write_Com(); }
 
138
   if($op{'sas'}    or $op{'all'}) { $~ = 'SAS', write; }
 
139
   if($op{'qcache'} or $op{'all'}) { write_qcache(); }
 
140
   $~ = 'REPORT_END', write;
 
141
   if($op{'tab'}    or $op{'all'}) { $~ = 'TAB', write; }
 
142
}
 
143
write_InnoDB() if $need_innodb_vals;
142
144
close $tmpfile_fh and select STDOUT;
143
145
 
144
146
email_report($tmpfile) if have_op 'email';
176
178
sub show_help_and_exit
177
179
{
178
180
   print <<"HELP";
179
 
mysqlreport v2.5 Sep 1 2006
180
 
mysqlreport makes a friendly report of important MySQL status values.
 
181
mysqlreport v3.0a Dec 12 2006
 
182
mysqlreport makes an easy-to-read report of important MySQL status values.
181
183
 
182
184
Command line options (abbreviations work):
183
185
   --user USER     Connect to MySQL as USER
192
194
   --sas           Show SELECT and Sort report
193
195
   --tab           Show Thread, Aborts, and Bytes reports
194
196
   --qcache        Show Query Cache report
195
 
   --all           Show --dms --com 3 --sas --qcache
 
197
   --innodb        Show InnoDB report
 
198
   --innodb-only   Show only InnoDB report (hide all other reports)
 
199
   --dpr           Show Data, Pages, Rows report in InnoDB report
 
200
   --all           Show --dtq --dms --com 3 --sas --tab --qcache --innodb --dpr
196
201
   --infile FILE   Read status values from FILE instead of MySQL
197
202
   --outfile FILE  Write report to FILE
198
203
   --email ADDRESS Email report to ADDRESS (doesn't work on Windows)
210
215
   return if $WIN;
211
216
   open MYCNF, "$ENV{HOME}/.my.cnf" or return;
212
217
   while(<MYCNF>) { $mycnf{$1} = $2 if /^(.+?)\s*=\s*"?(.+?)"?\s*$/; }
 
218
   $mycnf{'pass'} ||= $mycnf{'password'} if exists $mycnf{'password'};
213
219
   close MYCNF;
214
220
}
215
221
 
 
222
sub which_vals
 
223
{
 
224
   $need_myisam_vals = 1;
 
225
   $need_innodb_vals = 1; # This could be set to 0 later in get_vals_vars()
 
226
 
 
227
   $need_myisam_vals = 0, return if have_op 'id-only';
 
228
   $need_innodb_vals = 0, return if (!$op{'id'} && !$op{'id-only'} && !$op{'all'});
 
229
}
 
230
 
216
231
sub get_vals_vars
217
232
{
218
 
   if(not defined $op{'infile'})
 
233
   if(!have_op 'infile')
219
234
   {
220
235
      my @row;
221
236
 
222
 
      # Determine MySQL version
223
 
      $query = $dbh->prepare("SHOW VARIABLES LIKE 'version';");
224
 
      $query->execute();
225
 
      @row = $query->fetchrow_array();
226
 
 
227
 
      ($major, $minor, $patch) = ($row[1] =~ /(\d{1,2})\.(\d{1,2})\.(\d{1,2})/);
228
 
 
229
 
      if($major == 5 && (($minor == 0 && $patch >= 2) || $minor > 0))
230
 
      {
231
 
             $query = $dbh->prepare("SHOW GLOBAL STATUS;");
232
 
      }
233
 
      else { $query = $dbh->prepare("SHOW STATUS;"); }
234
 
      
 
237
      get_MySQL_version();
 
238
 
235
239
      # Get status values
 
240
      if($major >= 5 && (($minor == 0 && $patch >= 2) || $minor > 0)) {
 
241
         $query = $dbh->prepare("SHOW GLOBAL STATUS;");
 
242
      }
 
243
      else {
 
244
         $query = $dbh->prepare("SHOW STATUS;");
 
245
         $need_innodb_vals = 0;
 
246
      }
236
247
      $query->execute();
237
248
      while(@row = $query->fetchrow_array()) { $stats{$row[0]} = $row[1]; }
238
249
 
250
261
      # key_cache_block_size
251
262
      $vars{'key_buffer_size'} = 8388600; # 8M
252
263
      # query_cache_size
 
264
      $vars{'thread_cache_size'} = 0;
253
265
 
254
266
      open INFILE, "< $op{infile}" or die;
255
267
      while(<INFILE>)
268
280
         # Explicit var = val (e.g. key_buffer_size = 128M)
269
281
         $vars{$1} = ($3 ? $2 * 1024 * 1024 : $2) and next if(/^\s*(\w+)\s*=\s*([0-9.]+)(M*)\s*$/);
270
282
         
271
 
#         print "Unrecognized line in infile: $_\n";
 
283
         # print "Unrecognized line in infile: $_\n";
272
284
      }
273
285
      close INFILE;
274
 
   }
 
286
 
 
287
      get_MySQL_version();
 
288
   }
 
289
}
 
290
 
 
291
sub get_MySQL_version
 
292
{
 
293
   if(have_op 'infile')
 
294
   {
 
295
      ($major, $minor, $patch) = ($vars{'version'} =~ /(\d{1,2})\.(\d{1,2})\.(\d{1,2})/);
 
296
   }
 
297
   else
 
298
   {
 
299
      my @row;
 
300
 
 
301
      $query = $dbh->prepare("SHOW VARIABLES LIKE 'version';");
 
302
      $query->execute();
 
303
      @row = $query->fetchrow_array();
 
304
      ($major, $minor, $patch) = ($row[1] =~ /(\d{1,2})\.(\d{1,2})\.(\d{1,2})/);
 
305
   }
 
306
}
 
307
 
 
308
sub set_myisam_vals
 
309
{
 
310
   $questions = $stats{'Questions'};
 
311
 
 
312
   $key_read_ratio = sprintf "%.3f",
 
313
                     ($stats{'Key_read_requests'} ?
 
314
                      $stats{'Key_reads'} / $stats{'Key_read_requests'} :
 
315
                      0);
 
316
 
 
317
   $key_write_ratio = sprintf "%.3f",
 
318
                      ($stats{'Key_write_requests'} ?
 
319
                       $stats{'Key_writes'} / $stats{'Key_write_requests'} :
 
320
                       0);
 
321
 
 
322
   $key_cache_block_size = (defined $vars{'key_cache_block_size'} ?
 
323
                            $vars{'key_cache_block_size'} :
 
324
                            1024);
 
325
 
 
326
   $key_buffer_used = $stats{'Key_blocks_used'} * $key_cache_block_size;
 
327
 
 
328
   if(defined $stats{'Key_blocks_unused'}) { # MySQL 4.1.2+
 
329
      $key_buffer_usage =  $vars{'key_buffer_size'} -
 
330
                           ($stats{'Key_blocks_unused'} * $key_cache_block_size);
 
331
   }
 
332
   else { $key_buffer_usage = -1; }
 
333
 
 
334
   # Data Manipulation Statements: http://dev.mysql.com/doc/refman/5.0/en/data-manipulation.html
 
335
   %DMS_vals = (
 
336
      SELECT  => $stats{'Com_select'},
 
337
      INSERT  => $stats{'Com_insert'}  + $stats{'Com_insert_select'},
 
338
      REPLACE => $stats{'Com_replace'} + $stats{'Com_replace_select'},
 
339
      UPDATE  => $stats{'Com_update'}  +
 
340
                 (exists $stats{'Com_update_multi'} ? $stats{'Com_update_multi'} : 0),
 
341
      DELETE  => $stats{'Com_delete'}  +
 
342
                 (exists $stats{'Com_delete_multi'} ? $stats{'Com_delete_multi'} : 0)
 
343
   );
 
344
 
 
345
   $dms = $DMS_vals{SELECT} + $DMS_vals{INSERT} + $DMS_vals{REPLACE} + $DMS_vals{UPDATE} + $DMS_vals{DELETE};
 
346
}
 
347
 
 
348
sub set_ib_vals
 
349
{
 
350
   $ib_bp_used  = ($stats{'Innodb_buffer_pool_pages_total'} -
 
351
                   $stats{'Innodb_buffer_pool_pages_free'}) *
 
352
                   $stats{'Innodb_page_size'};
 
353
 
 
354
   $ib_bp_total = $stats{'Innodb_buffer_pool_pages_total'} * $stats{'Innodb_page_size'};
 
355
 
 
356
   $ib_bp_read_ratio = sprintf "%.3f",
 
357
                       ($stats{'Innodb_buffer_pool_read_requests'} ?
 
358
                        $stats{'Innodb_buffer_pool_reads'} / $stats{'Innodb_buffer_pool_read_requests'} :
 
359
                        0);
275
360
}
276
361
 
277
362
sub sec_to_dhms # Seconds to days hours:minutes:seconds
299
384
   return "$d $h:$m:$s";
300
385
}
301
386
 
302
 
# Copied from mytop (http://jeremy.zawodny.com/mysql/mytop/) and modified a little
303
387
sub make_short
304
388
{
305
 
   my ($number, $kb) = @_;
 
389
   my ($number, $kb, $d) = @_;
306
390
   my $n = 0;
307
391
   my $short;
308
392
 
309
 
   if(defined $kb) { while ($number > 1023) { $number /= 1024; $n++; }; }
 
393
   $d ||= 2;
 
394
 
 
395
   if($kb) { while ($number > 1023) { $number /= 1024; $n++; }; }
310
396
   else { while ($number > 999) { $number /= 1000; $n++; }; }
311
397
 
312
 
   $short = sprintf "%.2f%s", $number, ('','k','M','G','T')[$n];
 
398
   $short = sprintf "%.${d}f%s", $number, ('','k','M','G','T')[$n];
313
399
   if($short =~ /^(.+)\.(00)$/) { return $1; } # 12.00 -> 12 but not 12.00k -> 12k
 
400
 
314
401
   return $short;
315
402
}
316
403
 
323
410
sub t # Time average per second
324
411
{
325
412
   my $val = shift;
326
 
   return sprintf "%.2f", $val / $stats{'Uptime'};
 
413
   return 0 if !$val;
 
414
   return(make_short($val / $stats{'Uptime'}, 0, 1));
327
415
}
328
416
 
329
417
sub email_report # Email given report to $op{'email'}
335
423
   open SENDMAIL, "|/usr/sbin/sendmail -t";
336
424
   print SENDMAIL "From: mysqlreport\n";
337
425
   print SENDMAIL "To: $op{email}\n";
338
 
   print SENDMAIL "Subject: MySQL status report\n\n";
 
426
   print SENDMAIL "Subject: MySQL status report on $mycnf{'host'}\n\n";
339
427
   print SENDMAIL `cat $report`;
340
428
   close SENDMAIL;
341
429
}
452
540
   # Query cache was added in 4.0.1, but have_query_cache was added in 4.0.2,
453
541
   # ergo this method is slightly more reliable
454
542
   return if not exists $vars{'query_cache_size'};
455
 
   return if $vars{'query_cache_size'} == 0;
456
543
 
457
544
   $qc_mem_used = $vars{'query_cache_size'} - $stats{'Qcache_free_memory'};
458
545
   $qc_hi_r = sprintf "%.2f", $stats{'Qcache_hits'} / ($stats{'Qcache_inserts'} ||= 1);
462
549
   write;
463
550
}
464
551
 
 
552
sub write_InnoDB
 
553
{
 
554
   # Innodb_ status values were added in MySQL 5.0.2
 
555
   if(! ($major >= 5 && (($minor == 0 && $patch >= 2) || $minor > 0)) )
 
556
   {
 
557
      # In case infile has Innodb_ values but didn't specify the MySQL version
 
558
      if(not defined $stats{'Innodb_page_size'}) { return; }
 
559
   }
 
560
 
 
561
   $~ = 'IB';
 
562
   write;
 
563
 
 
564
   # Innodb_row_lock_ values were added in MySQL 5.0.3
 
565
   if((($minor == 0 && $patch >= 3) || $minor > 0))
 
566
   {
 
567
      $~ = 'IB_LOCK';
 
568
      write;
 
569
   }
 
570
 
 
571
   if($op{'dpr'} || $op{'all'}) # Data, Pages, Rows
 
572
   {
 
573
      $~ = 'IB_DPR';
 
574
      write;
 
575
   }
 
576
}
 
577
 
465
578
sub have_op
466
579
{
467
580
   my $key = shift;
474
587
# Formats
475
588
#
476
589
 
477
 
# First part of main report
478
 
format KEY_BUFF_MAX =
 
590
format MYSQL_TIME =
479
591
MySQL @<<<<<<<<<<<<<<<<  uptime @<<<<<<<<<<<   @>>>>>>>>>>>>>>>>>>>>>>>>
480
592
$vars{'version'}, sec_to_dhms($stats{'Uptime'}), scalar localtime
 
593
.
 
594
 
 
595
format KEY_BUFF_MAX =
481
596
 
482
597
__ Key _________________________________________________________________
483
598
Buffer used   @>>>>>> of @>>>>>>  %Used: @>>>>>
490
605
.
491
606
 
492
607
format KEY_RATIOS =
493
 
Write ratio @>>>>>>>>
 
608
Write ratio   @>>>>>>
494
609
$key_write_ratio
495
 
Read ratio  @>>>>>>>>
 
610
Read ratio    @>>>>>>
496
611
$key_read_ratio
497
612
 
498
613
__ Questions ___________________________________________________________
500
615
make_short($questions), t($questions)
501
616
.
502
617
 
503
 
# Distribution of Total Questions invoked by -dtq or -all
504
618
format DTQ =
505
619
  @<<<<<<<  @>>>>>>>>  @>>>>>/s  @>>>>>> @>>>>>
506
620
$stat_name, make_short($stat_val), t($stat_val), $stat_label, perc($stat_val, $questions)
507
621
.
508
622
 
509
 
# Second part of main report
510
623
format SLOW_DMS =
511
624
Slow        @>>>>>>>>  @>>>>>/s  @>>>>>> @>>>>>  %DMS: @>>>>>
512
625
make_short($stats{'Slow_queries'}), t($stats{'Slow_queries'}), ($op{'dtq'} || $op{'all'} ? '' : '%Total:'), perc($stats{'Slow_queries'}, $questions), perc($stats{'Slow_queries'}, $dms)
514
627
make_short($dms), t($dms), perc($dms, $questions)
515
628
.
516
629
 
517
 
# Data Manipulation Statements format invoked by -dms or -all
518
630
format DMS =
519
631
  @<<<<<<<  @>>>>>>>>  @>>>>>/s          @>>>>>        @>>>>>
520
632
$stat_name, make_short($stat_val), t($stat_val), perc($stat_val, $questions), perc($stat_val, $dms)
521
633
.
522
634
 
523
 
# Top Com_ format invoked by -com or -all
524
635
format COM_1 =
525
636
Com_        @>>>>>>>>  @>>>>>/s          @>>>>>
526
637
make_short($stat_val), t($stat_val), perc($stat_val, $questions)
531
642
$stat_name, make_short($stat_val), t($stat_val), perc($stat_val, $questions)
532
643
.
533
644
 
534
 
# SELECT and Sort format invoked by -sas or -all
535
645
format SAS =
536
646
 
537
647
__ SELECT and Sort _____________________________________________________
553
663
make_short($stats{'Sort_merge_passes'}), t($stats{'Sort_merge_passes'})
554
664
.
555
665
 
556
 
# Query Cache format invoked by -qcache or -all
557
666
format QCACHE =
558
667
 
559
668
__ Query Cache _________________________________________________________
565
674
make_short($stats{'Qcache_hits'}), t($stats{'Qcache_hits'})
566
675
Inserts       @>>>>>>   @>>>>/s
567
676
make_short($stats{'Qcache_inserts'}), t($stats{'Qcache_inserts'})
568
 
Prunes        @>>>>>>   @>>>>/s
569
 
make_short($stats{'Qcache_lowmem_prunes'}), t($stats{'Qcache_lowmem_prunes'})
570
677
Insrt:Prune @>>>>>>:1   @>>>>/s
571
678
make_short($qc_ip_r), t($stats{'Qcache_inserts'} - $stats{'Qcache_lowmem_prunes'})
572
679
Hit:Insert  @>>>>>>:1
573
680
$qc_hi_r, t($qc_hi_r)
574
681
.
575
682
 
576
 
# Third part of main report
 
683
# Not really the end...
577
684
format REPORT_END =
578
685
 
579
686
__ Table Locks _________________________________________________________
603
710
make_short($stats{'Created_tmp_files'}), t($stats{'Created_tmp_files'})
604
711
.
605
712
 
606
 
# Threads, Aborts, and Bytes format invoked by -tab
607
713
format TAB =
608
714
 
609
715
__ Threads _____________________________________________________________
610
716
Running     @>>>>>>>> of @>>>
611
717
$stats{'Threads_running'}, $stats{'Threads_connected'}
612
 
Cache       @>>>>>>>>              %Hit: @>>>>>
613
 
$stats{'Threads_cached'}, (100 - perc($stats{'Threads_created'}, $stats{'Connections'}))
 
718
Cached      @>>>>>>>> of @>>>      %Hit: @>>>>>
 
719
$stats{'Threads_cached'}, $vars{'thread_cache_size'}, make_short(100 - perc($stats{'Threads_created'}, $stats{'Connections'}))
614
720
Created     @>>>>>>>>  @>>>>>/s
615
721
make_short($stats{'Threads_created'}), t($stats{'Threads_created'})
616
722
Slow        @>>>>>>>>  @>>>>>/s
624
730
 
625
731
__ Bytes _______________________________________________________________
626
732
Sent        @>>>>>>>>  @>>>>>/s
627
 
make_short($stats{'Bytes_sent'}), make_short(t($stats{'Bytes_sent'}))
 
733
make_short($stats{'Bytes_sent'}), t($stats{'Bytes_sent'})
628
734
Received    @>>>>>>>>  @>>>>>/s
629
 
make_short($stats{'Bytes_received'}), make_short(t($stats{'Bytes_received'}))
630
 
.
 
735
make_short($stats{'Bytes_received'}), t($stats{'Bytes_received'})
 
736
.
 
737
 
 
738
format IB =
 
739
 
 
740
__ InnoDB Buffer Pool __________________________________________________
 
741
Usage         @>>>>>> of @>>>>>>  %Used: @>>>>>
 
742
make_short($ib_bp_used, 1), make_short($ib_bp_total, 1), perc($ib_bp_used, $ib_bp_total)
 
743
Read ratio    @>>>>>>
 
744
$ib_bp_read_ratio;
 
745
Pages
 
746
  Free      @>>>>>>>>            %Total: @>>>>>
 
747
make_short($stats{'Innodb_buffer_pool_pages_free'}), perc($stats{'Innodb_buffer_pool_pages_free'}, $stats{'Innodb_buffer_pool_pages_total'})
 
748
  Data      @>>>>>>>>                    @>>>>> %Drty: @>>>>>
 
749
make_short($stats{'Innodb_buffer_pool_pages_data'}), perc($stats{'Innodb_buffer_pool_pages_data'}, $stats{'Innodb_buffer_pool_pages_total'}), perc($stats{'Innodb_buffer_pool_pages_dirty'}, $stats{'Innodb_buffer_pool_pages_data'})
 
750
  Misc      @>>>>>>>>                    @>>>>>
 
751
  $stats{'Innodb_buffer_pool_pages_misc'}, perc($stats{'Innodb_buffer_pool_pages_misc'}, $stats{'Innodb_buffer_pool_pages_total'})
 
752
  Latched   @>>>>>>>>                    @>>>>>
 
753
$stats{'Innodb_buffer_pool_pages_latched'}, perc($stats{'Innodb_buffer_pool_pages_latched'}, $stats{'Innodb_buffer_pool_pages_total'})
 
754
Reads       @>>>>>>>>  @>>>>>/s  
 
755
make_short($stats{'Innodb_buffer_pool_read_requests'}), t($stats{'Innodb_buffer_pool_read_requests'})
 
756
  From file @>>>>>>>>  @>>>>>/s          @>>>>>
 
757
make_short($stats{'Innodb_buffer_pool_reads'}), t($stats{'Innodb_buffer_pool_reads'}), perc($stats{'Innodb_buffer_pool_reads'}, $stats{'Innodb_buffer_pool_read_requests'})
 
758
  Ahead Rnd @>>>>>>>>  @>>>>>/s
 
759
$stats{'Innodb_buffer_pool_read_ahead_rnd'}, t($stats{'Innodb_buffer_pool_read_ahead_rnd'})
 
760
  Ahead Sql @>>>>>>>>  @>>>>>/s
 
761
$stats{'Innodb_buffer_pool_read_ahead_seq'}, t($stats{'Innodb_buffer_pool_read_ahead_seq'})
 
762
Writes      @>>>>>>>>  @>>>>>/s
 
763
make_short($stats{'Innodb_buffer_pool_write_requests'}), t($stats{'Innodb_buffer_pool_write_requests'})
 
764
Flushes     @>>>>>>>>  @>>>>>/s
 
765
make_short($stats{'Innodb_buffer_pool_pages_flushed'}), t($stats{'Innodb_buffer_pool_pages_flushed'})
 
766
Wait Free   @>>>>>>>>  @>>>>>/s
 
767
$stats{'Innodb_buffer_pool_wait_free'}, t($stats{'Innodb_buffer_pool_wait_free'})
 
768
.
 
769
 
 
770
format IB_LOCK =
 
771
 
 
772
__ InnoDB Lock _________________________________________________________
 
773
Waits       @>>>>>>>>  @>>>>>/s
 
774
$stats{'Innodb_row_lock_waits'}, t($stats{'Innodb_row_lock_waits'})
 
775
Current     @>>>>>>>>
 
776
$stats{'Innodb_row_lock_current_waits'}
 
777
Time acquiring
 
778
  Total     @>>>>>>>> ms
 
779
$stats{'Innodb_row_lock_time'}
 
780
  Average   @>>>>>>>> ms
 
781
$stats{'Innodb_row_lock_time_avg'}
 
782
  Max       @>>>>>>>> ms
 
783
$stats{'Innodb_row_lock_time_max'}
 
784
.
 
785
 
 
786
format IB_DPR =
 
787
 
 
788
__ InnoDB Data, Pages, Rows ____________________________________________
 
789
Data
 
790
  Reads     @>>>>>>>>  @>>>>>/s
 
791
make_short($stats{'Innodb_data_reads'}), t($stats{'Innodb_data_reads'})
 
792
  Writes    @>>>>>>>>  @>>>>>/s
 
793
make_short($stats{'Innodb_data_writes'}), t($stats{'Innodb_data_writes'})
 
794
  fsync     @>>>>>>>>  @>>>>>/s
 
795
make_short($stats{'Innodb_data_fsyncs'}), t($stats{'Innodb_data_fsyncs'})
 
796
  Pending
 
797
    Reads   @>>>>>>>>
 
798
$stats{'Innodb_data_pending_reads'}, t($stats{'Innodb_data_pending_reads'})
 
799
    Writes  @>>>>>>>>
 
800
$stats{'Innodb_data_pending_writes'}, t($stats{'Innodb_data_pending_writes'})
 
801
    fysnc   @>>>>>>>>
 
802
$stats{'Innodb_data_pending_fsyncs'}, t($stats{'Innodb_data_pending_fysncs'})
 
803
 
 
804
Pages
 
805
  Created   @>>>>>>>>  @>>>>>/s
 
806
make_short($stats{'Innodb_pages_created'}), t($stats{'Innodb_pages_created'})
 
807
  Read      @>>>>>>>>  @>>>>>/s
 
808
make_short($stats{'Innodb_pages_read'}), t($stats{'Innodb_pages_read'})
 
809
  Written   @>>>>>>>>  @>>>>>/s
 
810
make_short($stats{'Innodb_pages_written'}), t($stats{'Innodb_pages_written'})
 
811
 
 
812
Rows
 
813
  Deleted   @>>>>>>>>  @>>>>>/s
 
814
make_short($stats{'Innodb_rows_deleted'}), t($stats{'Innodb_rows_deleted'})
 
815
  Inserted  @>>>>>>>>  @>>>>>/s
 
816
make_short($stats{'Innodb_rows_inserted'}), t($stats{'Innodb_rows_inserted'})
 
817
  Read      @>>>>>>>>  @>>>>>/s
 
818
make_short($stats{'Innodb_rows_read'}), t($stats{'Innodb_rows_read'})
 
819
  Updated   @>>>>>>>>  @>>>>>/s
 
820
make_short($stats{'Innodb_rows_updated'}), t($stats{'Innodb_rows_updated'})
 
821
.
 
822