[Pkg-mysql-commits] r1129 - in trunk/debian: . additions/mysqlreport

Norbert Tretkowski nobse at alioth.debian.org
Wed Jan 23 22:09:15 UTC 2008


Author: nobse
Date: 2008-01-23 22:09:15 +0000 (Wed, 23 Jan 2008)
New Revision: 1129

Modified:
   trunk/debian/additions/mysqlreport/mysqlreport
   trunk/debian/changelog
Log:
Update mysqlreport to 3.4a release.

Modified: trunk/debian/additions/mysqlreport/mysqlreport
===================================================================
--- trunk/debian/additions/mysqlreport/mysqlreport	2008-01-23 15:06:21 UTC (rev 1128)
+++ trunk/debian/additions/mysqlreport/mysqlreport	2008-01-23 22:09:15 UTC (rev 1129)
@@ -1,10 +1,10 @@
 #!/usr/bin/perl -w
 
-# mysqlreport v3.2 May 26 2007
+# mysqlreport v3.4a Jan 23 2008 
 # http://hackmysql.com/mysqlreport
 
 # mysqlreport makes an easy-to-read report of important MySQL status values.
-# Copyright (C) 2006  Daniel Nichter
+# Copyright 2006-2008 Daniel Nichter
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -37,10 +37,10 @@
 my (%stats, %vars); # SHOW STATUS, SHOW VARIABLES
 my (%DMS_vals, %Com_vals, %ib_vals);
 my ($dbh, $query);
-my ($questions, $key_read_ratio, $key_write_ratio, $dms);
+my ($questions, $key_read_ratio, $key_write_ratio, $dms, $slow_query_t);
 my ($key_cache_block_size, $key_buffer_used, $key_buffer_usage);
 my ($qc_mem_used, $qc_hi_r, $qc_ip_r); # Query Cache
-my ($need_myisam_vals, $need_innodb_vals);
+my $have_innodb_vals;
 my ($ib_bp_used, $ib_bp_total, $ib_bp_read_ratio);
 my ($relative_live, $relative_infiles);
 my $real_uptime;
@@ -54,16 +54,6 @@
    "port=s",
    "socket=s",
    "no-mycnf",
-   "dtq|tdq|dq",
-   "dms",
-   "com:i",
-   "sas",
-   "tab",
-   "qcache",
-   "id-only|ido|innodb-only",
-   "id|innodb",
-   "dpr|drp",
-   "all",
    "infile|in=s",
    "outfile=s",
    "flush-status",
@@ -99,11 +89,9 @@
    else { $mycnf{'pass'} = $op{'password'}; } # Use password given on command line
 }
 
-if($op{'all'} and not defined $op{'com'})  { $op{'com'} = 3; }
-if(defined $op{'com'} and $op{'com'} == 0) { $op{'com'} = 3; }
+$op{'com'} ||= 3;
+$op{'c'}   ||= 1; # Used in collect_reports() if --r given integer value
 
-$op{'c'} ||= 1; # Used in collect_reports() if --r given integer value
-
 if(defined $op{'r'})
 {
    if($op{r}) { $relative_live    = 1; }
@@ -160,8 +148,7 @@
    $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die;
 }
 
-# Determine if we need values from MyISAM, InnoDB, or both
-which_vals();
+$have_innodb_vals = 1; # This might be set to 0 later in get_MySQL_version()
 
 if(defined $op{'r'})
 {
@@ -189,8 +176,8 @@
 
    get_Com_values();
 
-   set_myisam_vals() if $need_myisam_vals;
-   set_ib_vals()     if $need_innodb_vals;
+   set_myisam_vals();
+   set_ib_vals() if $have_innodb_vals;
 
    write_report();
 }
@@ -205,7 +192,7 @@
 sub show_help_and_exit
 {
    print <<"HELP";
-mysqlreport v3.2 May 26 2007
+mysqlreport v3.4a Jan 23 2008
 mysqlreport makes an easy-to-read report of important MySQL status values.
 
 Command line options (abbreviations work):
@@ -221,25 +208,14 @@
    --flush-status    Issue FLUSH STATUS; after getting current values
    --relative X      Generate relative reports. If X is an integer,
                      reports are live from the MySQL server X seconds apart.
-                     If X is a list of infiles, reports are generated
-                     from the infiles in the order that the infiles are given.
+                     If X is a list of infiles (file1 file2 etc.),
+                     reports are generated from the infiles in the order
+                     that they are given.
    --report-count N  Collect N number of live relative reports (default 1)
    --detach          Fork and detach from terminal (run in background)
    --help            Prints this
    --debug           Print debugging information
 
-   Extra Reports:
-   --dtq           Show Distribution of Total Questions
-   --dms           Show DMS details
-   --com N         Show top N number of non-DMS questions
-   --sas           Show SELECT and Sort report
-   --qcache        Show Query Cache report
-   --tab           Show Thread, Aborts, and Bytes reports
-   --innodb        Show InnoDB report
-   --innodb-only   Show only InnoDB report (hide ALL other reports)
-   --dpr           Show Data, Pages, Rows report in InnoDB report
-   --all           Show ALL extra reports (if possible)
-
 Visit http://hackmysql.com/mysqlreport for more information.
 HELP
 
@@ -262,15 +238,6 @@
    close MYCNF;
 }
 
-sub which_vals
-{
-   $need_myisam_vals = 1;
-   $need_innodb_vals = 1; # This could be set to 0 later in get_vals_vars()
-
-   $need_myisam_vals = 0, return if have_op 'id-only';
-   $need_innodb_vals = 0, return if (!$op{'id'} && !$op{'id-only'} && !$op{'all'});
-}
-
 sub collect_reports
 {
    my $i;
@@ -282,10 +249,10 @@
 
    %stats_past = %stats;
 
-   set_myisam_vals() if $need_myisam_vals;
-   set_ib_vals()     if $need_innodb_vals;
+   set_myisam_vals();
+   set_ib_vals() if $have_innodb_vals;
 
-   print "#\n# Begining report @ 0 0:0:0\n#\n";
+   print "#\n# Beginning report, 0 0:0:0\n#\n";
 
    write_report();
 
@@ -293,7 +260,7 @@
    {
       sleep($op{'r'});
 
-      print "\n#\n# Interval report " , $i + 1 , " @ +", sec_to_dhms(($i + 1) * $op{'r'}), "\n#\n";
+      print "\n#\n# Interval report " , $i + 1 , ", +", sec_to_dhms(($i + 1) * $op{'r'}), "\n#\n";
 
       get_vals();
 
@@ -320,8 +287,11 @@
       $n_stats = 0;
 
       # Count number of status value sets
-      $n_stats++ while $slurp =~ /Variable_name[\s|]+Value/g;
+      $n_stats++ while $slurp =~ /Aborted_clients/g;
 
+      print "read_relative_infiles: found $n_stats sets of status values in file '$infile'\n"
+         if $op{debug};
+
       if($n_stats == 1)
       {
          read_infile($infile);
@@ -338,9 +308,13 @@
          # Create a tmp file for each set of status values
          for($i = 0; $i < $n_stats; $i++)
          {
-            my ($fh, $name) = tempfile() or die("Cannot open temporary file for writing: $!\n");
+            my ($fh, $name) = tempfile()
+               or die("read_relative_infiles: cannot open temporary file for writing: $!\n");
+
             push(@tmpfile_fh, $fh);
             push(@tmpfile_name, $name);
+
+            print "read_relative_infiles: created tmp file '$name'\n" if $op{debug};
          }
 
          $i = 0;
@@ -358,15 +332,15 @@
 
             print;
 
-            if(/Variable_name[\s|]+Value/)
+            if(/Aborted_clients/)
             {
                # The infile should begin with manually inserted system
                # var values (like key_buffer_size = 128M). Therefore,
-               # the first occurance of /Variable_name[\s|]+Value/ indicates
+               # the first occurance of /Aborted_clients/ indicates
                # the first set of status values only if no sets have
                # occured yet ($stat_n = 0). In this case, the following
                # status values are printed to the current fh along with
-               # the system var values read so far until /Variable_name[\s|]+Value/
+               # the system var values read so far until /Aborted_clients/
                # occurs again. Then begins the second and subsequent sets
                # of status values.
                next if $stat_n++ == 0;
@@ -388,6 +362,9 @@
 
             if($WIN) { `del $tmpfile_name[$i]`;   }
             else     { `rm -f $tmpfile_name[$i]`; }
+
+            print "read_relative_infiles: deleted tmp file '$tmpfile_name[$i]'\n"
+               if $op{debug};
          }
 
       } # if($n_stats > 1)
@@ -404,16 +381,19 @@
 
       %stats_past = %stats;
 
-      set_myisam_vals() if $need_myisam_vals;
-      set_ib_vals()     if $need_innodb_vals;
+      set_myisam_vals();
+      set_ib_vals() if $have_innodb_vals;
 
-      print "#\n# Begining report @ 0 0:0:0\n#\n";
+      print "#\n# Beginning report, 0 0:0:0\n#\n";
 
       write_report();
    }
    else
    {
-      print "\n#\n# Interval report $report_n @ +" , sec_to_dhms($stats{Uptime} - $stats_past{Uptime}), "\n#\n";
+      print "\n#\n# Interval report ", $report_n - 1, ", +",
+         sec_to_dhms($stats{Uptime} - $stats_past{Uptime}),
+         "\n#\n";
+
       write_relative_report();
    }
 }
@@ -463,6 +443,9 @@
    $vars{'max_connections'} = 100     if !exists $vars{'max_connections'};
    $vars{'key_buffer_size'} = 8388600 if !exists $vars{'key_buffer_size'}; # 8M
    $vars{'thread_cache_size'} = 0     if !exists $vars{'thread_cache_size'}; 
+   $vars{'tmp_table_size'} = 0        if !exists $vars{'tmp_table_size'};
+   $vars{'long_query_time'} = '?'     if !exists $vars{'long_query_time'};
+   $vars{'log_slow_queries'} = '?'    if !exists $vars{'log_slow_queries'};
 
    # One should also add:
    #    key_cache_block_size
@@ -484,9 +467,16 @@
       }
 
       # Explicit var = val (e.g. key_buffer_size = 128M)
-      $vars{$1} = ($3 ? $2 * 1024 * 1024 : $2) and next if(/^\s*(\w+)\s*=\s*([0-9.]+)(M*)\s*$/);
-
-      # print "Unrecognized line in infile: $_\n";
+      if( /^\s*(\w+)\s*=\s*([0-9.]+)(M*)\s*$/ )
+      {
+         $vars{$1} = ($3 ? $2 * 1024 * 1024 : $2);
+         print "read_infile: read '$_' as $1 = $vars{$1}\n" if $op{debug};
+         next;
+      }
+      else
+      {
+         print "read_infile: unrecognized line: '$_'\n" if $op{debug};
+      }
    }
    close INFILE;
 
@@ -518,7 +508,7 @@
    # Innodb_ status values were added in 5.0.2
    if($major <= 4 || $patch < 2)
    {
-      $need_innodb_vals = 0;
+      $have_innodb_vals = 0;
       print "get_MySQL_version: no InnoDB reports because MySQL version is older than 5.0.2\n" if $op{debug};
    }
 }
@@ -563,6 +553,9 @@
    );
 
    $dms = $DMS_vals{SELECT} + $DMS_vals{INSERT} + $DMS_vals{REPLACE} + $DMS_vals{UPDATE} + $DMS_vals{DELETE};
+
+   $slow_query_t = "($vars{long_query_time})";
+
 }
 
 sub set_ib_vals
@@ -573,9 +566,10 @@
 
    $ib_bp_total = $stats{'Innodb_buffer_pool_pages_total'} * $stats{'Innodb_page_size'};
 
-   $ib_bp_read_ratio = sprintf "%.3f",
+   $ib_bp_read_ratio = sprintf "%.2f",
                        ($stats{'Innodb_buffer_pool_read_requests'} ?
-                        $stats{'Innodb_buffer_pool_reads'} / $stats{'Innodb_buffer_pool_read_requests'} :
+                        100 - ($stats{'Innodb_buffer_pool_reads'} /
+                           $stats{'Innodb_buffer_pool_read_requests'}) * 100 :
                         0);
 }
 
@@ -595,8 +589,8 @@
       }
 
       # These values are either "at present" or "high water marks".
-      # IMO, it is more logical not to relativize these values. Doing
-      # otherwise causes them to display strange and misleading values.
+      # Therefore, it is more logical to not relativize these values.
+      # Doing otherwise causes strange and misleading values.
       $stats{'Key_blocks_used'}      = $stats_present{'Key_blocks_used'};
       $stats{'Open_tables'}          = $stats_present{'Open_tables'};
       $stats{'Max_used_connections'} = $stats_present{'Max_used_connections'};
@@ -606,13 +600,34 @@
       $stats{'Qcache_free_blocks'}   = $stats_present{'Qcache_free_blocks'};
       $stats{'Qcache_total_blocks'}  = $stats_present{'Qcache_total_blocks'};
       $stats{'Qcache_free_memory'}   = $stats_present{'Qcache_free_memory'};
+      if($have_innodb_vals)
+      {
+         $stats{'Innodb_page_size'}                 = $stats_present{'Innodb_page_size'};
+         $stats{'Innodb_buffer_pool_pages_data'}    = $stats_present{'Innodb_buffer_pool_pages_data'};
+         $stats{'Innodb_buffer_pool_pages_dirty'}   = $stats_present{'Innodb_buffer_pool_pages_dirty'};
+         $stats{'Innodb_buffer_pool_pages_free'}    = $stats_present{'Innodb_buffer_pool_pages_free'};
+         $stats{'Innodb_buffer_pool_pages_latched'} = $stats_present{'Innodb_buffer_pool_pages_latched'};
+         $stats{'Innodb_buffer_pool_pages_misc'}    = $stats_present{'Innodb_buffer_pool_pages_misc'};
+         $stats{'Innodb_buffer_pool_pages_total'}   = $stats_present{'Innodb_buffer_pool_pages_total'};
+         $stats{'Innodb_data_pending_fsyncs'}       = $stats_present{'Innodb_data_pending_fsyncs'};
+         $stats{'Innodb_data_pending_reads'}        = $stats_present{'Innodb_data_pending_reads'};
+         $stats{'Innodb_data_pending_writes'}       = $stats_present{'Innodb_data_pending_writes'};
 
+         # Innodb_row_lock_ values were added in MySQL 5.0.3
+         if((($minor == 0 && $patch >= 3) || $minor > 0))
+         {
+            $stats{'Innodb_row_lock_current_waits'} = $stats_present{'Innodb_row_lock_current_waits'};
+            $stats{'Innodb_row_lock_time_avg'}      = $stats_present{'Innodb_row_lock_time_avg'};
+            $stats{'Innodb_row_lock_time_max'}      = $stats_present{'Innodb_row_lock_time_max'};
+         }
+      }
+
       get_Com_values();
 
       %stats_past = %stats_present;
 
-      set_myisam_vals() if $need_myisam_vals;
-      set_ib_vals()     if $need_innodb_vals;
+      set_myisam_vals();
+      set_ib_vals() if $have_innodb_vals;
 
       write_report();
 }
@@ -620,21 +635,19 @@
 sub write_report
 {
    $~ = 'MYSQL_TIME', write;
-   if($need_myisam_vals)
-   {
-      $~ = 'KEY_BUFF_MAX', write;
-      if($key_buffer_usage != -1)     { $~ = 'KEY_BUFF_USAGE', write }
-      $~ = 'KEY_RATIOS', write;
-      if($op{'dtq'}    or $op{'all'}) { write_DTQ(); }
-      $~ = 'SLOW_DMS', write;
-      if($op{'dms'}    or $op{'all'}) { write_DMS(); }
-      if($op{'com'}    or $op{'all'}) { write_Com(); }
-      if($op{'sas'}    or $op{'all'}) { $~ = 'SAS', write; }
-      if($op{'qcache'} or $op{'all'}) { write_qcache(); }
-      $~ = 'REPORT_END', write;
-      if($op{'tab'}    or $op{'all'}) { $~ = 'TAB', write; }
-   }
-   write_InnoDB() if $need_innodb_vals;
+   $~ = 'KEY_BUFF_MAX', write;
+   if($key_buffer_usage != -1) { $~ = 'KEY_BUFF_USAGE', write }
+   $~ = 'KEY_RATIOS', write;
+   write_DTQ();
+   $~ = 'SLOW_DMS', write;
+   write_DMS();
+   write_Com();
+   $~ = 'SAS', write; 
+   write_qcache(); 
+   $~ = 'REPORT_END', write;
+   $~ = 'TAB', write;
+
+   write_InnoDB() if $have_innodb_vals;
 }
 
 sub sec_to_dhms # Seconds to days hours:minutes:seconds
@@ -848,11 +861,9 @@
       write;
    }
 
-   if($op{'dpr'} || $op{'all'}) # Data, Pages, Rows
-   {
-      $~ = 'IB_DPR';
-      write;
-   }
+   # Data, Pages, Rows
+   $~ = 'IB_DPR';
+   write;
 }
 
 sub have_op
@@ -940,8 +951,8 @@
 .
 
 format SLOW_DMS =
-Slow        @>>>>>>>>  @>>>>>/s  @>>>>>> @>>>>>  %DMS: @>>>>>
-make_short($stats{'Slow_queries'}), t($stats{'Slow_queries'}), ($op{'dtq'} || $op{'all'} ? '' : '%Total:'), perc($stats{'Slow_queries'}, $questions), perc($stats{'Slow_queries'}, $dms)
+Slow @<<<<< @>>>>>>>>  @>>>>>/s          @>>>>>  %DMS: @>>>>>  Log: @>> 
+$slow_query_t, make_short($stats{'Slow_queries'}), t($stats{'Slow_queries'}), perc($stats{'Slow_queries'}, $questions), perc($stats{'Slow_queries'}, $dms), $vars{'log_slow_queries'}
 DMS         @>>>>>>>>  @>>>>>/s          @>>>>>
 make_short($dms), t($dms), perc($dms, $questions)
 .
@@ -1023,8 +1034,8 @@
 __ Created Temp ________________________________________________________
 Disk table  @>>>>>>>>  @>>>>>/s
 make_short($stats{'Created_tmp_disk_tables'}), t($stats{'Created_tmp_disk_tables'})
-Table       @>>>>>>>>  @>>>>>/s
-make_short($stats{'Created_tmp_tables'}), t($stats{'Created_tmp_tables'})
+Table       @>>>>>>>>  @>>>>>/s    Size: @>>>>>
+make_short($stats{'Created_tmp_tables'}), t($stats{'Created_tmp_tables'}), make_short($vars{'tmp_table_size'}, 1, 1)
 File        @>>>>>>>>  @>>>>>/s
 make_short($stats{'Created_tmp_files'}), t($stats{'Created_tmp_files'})
 .
@@ -1059,7 +1070,7 @@
 __ InnoDB Buffer Pool __________________________________________________
 Usage         @>>>>>> of @>>>>>>  %Used: @>>>>>
 make_short($ib_bp_used, 1), make_short($ib_bp_total, 1), perc($ib_bp_used, $ib_bp_total)
-Read ratio    @>>>>>>
+Read hit      @>>>>>%
 $ib_bp_read_ratio;
 Pages
   Free      @>>>>>>>>            %Total: @>>>>>
@@ -1138,4 +1149,3 @@
   Updated   @>>>>>>>>  @>>>>>/s
 make_short($stats{'Innodb_rows_updated'}), t($stats{'Innodb_rows_updated'})
 .
-

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-01-23 15:06:21 UTC (rev 1128)
+++ trunk/debian/changelog	2008-01-23 22:09:15 UTC (rev 1129)
@@ -2,8 +2,9 @@
 
   * Add recommendation on libhtml-template-perl to -server package, used by
     ndb_size. (closes: #462265)
+  * Update mysqlreport to 3.4a release.
 
- -- Norbert Tretkowski <nobse at debian.org>  Wed, 23 Jan 2008 16:01:17 +0100
+ -- Norbert Tretkowski <nobse at debian.org>  Wed, 23 Jan 2008 23:08:17 +0100
 
 mysql-dfsg-5.0 (5.0.51-3) unstable; urgency=high
 




More information about the Pkg-mysql-commits mailing list