[Pkg-mysql-commits] r1039 - in branches/sid-5.0/debian: . additions
Norbert Tretkowski
nobse at alioth.debian.org
Wed Dec 5 22:21:44 UTC 2007
Author: nobse
Date: 2007-12-05 22:21:43 +0000 (Wed, 05 Dec 2007)
New Revision: 1039
Modified:
branches/sid-5.0/debian/additions/mysqlreport
branches/sid-5.0/debian/changelog
Log:
Update mysqlreport to 3.2 release.
Modified: branches/sid-5.0/debian/additions/mysqlreport
===================================================================
--- branches/sid-5.0/debian/additions/mysqlreport 2007-12-04 22:57:54 UTC (rev 1038)
+++ branches/sid-5.0/debian/additions/mysqlreport 2007-12-05 22:21:43 UTC (rev 1039)
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
-# mysqlreport v3.0a Dec 12 2006
+# mysqlreport v3.2 May 26 2007
# http://hackmysql.com/mysqlreport
# mysqlreport makes an easy-to-read report of important MySQL status values.
@@ -42,7 +42,10 @@
my ($qc_mem_used, $qc_hi_r, $qc_ip_r); # Query Cache
my ($need_myisam_vals, $need_innodb_vals);
my ($ib_bp_used, $ib_bp_total, $ib_bp_read_ratio);
-
+my ($relative_live, $relative_infiles);
+my $real_uptime;
+my (%stats_present, %stats_past); # For relative reports
+
GetOptions (
\%op,
"user=s",
@@ -65,7 +68,11 @@
"outfile=s",
"flush-status",
"email=s",
- "help|?"
+ "r|relative:i",
+ "c|report-count=i",
+ "detach",
+ "help|?",
+ "debug"
);
show_help_and_exit() if $op{'help'};
@@ -78,11 +85,7 @@
$mycnf{'socket'} = $op{'socket'} if have_op 'socket';
$mycnf{'user'} = $op{'user'} if have_op 'user';
-# Default values if nothing else
-$mycnf{'host'} ||= 'localhost';
-$mycnf{'port'} ||= 3306;
-$mycnf{'socket'} ||= '/var/run/mysqld/mysqld.sock'; # Debian default
-$mycnf{'user'} ||= $ENV{'USER'};
+$mycnf{'user'} ||= $ENV{'USER'};
if(exists $op{'password'})
{
@@ -99,77 +102,101 @@
if($op{'all'} and not defined $op{'com'}) { $op{'com'} = 3; }
if(defined $op{'com'} and $op{'com'} == 0) { $op{'com'} = 3; }
-# Connect to MySQL
-if(!have_op 'infile')
+$op{'c'} ||= 1; # Used in collect_reports() if --r given integer value
+
+if(defined $op{'r'})
{
- my $dsn;
-
- if(-S $mycnf{'socket'} && !have_op 'host') { $dsn = "DBI:mysql:mysql_socket=$mycnf{socket}"; }
- else { $dsn = "DBI:mysql:host=$mycnf{host};port=$mycnf{port}"; }
-
- $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die;
+ if($op{r}) { $relative_live = 1; }
+ else { $relative_infiles = 1; }
}
# The report is written to a tmp file first.
# Later it will be moved to $op{'outfile'} or emailed $op{'email'} if needed.
-($tmpfile_fh, $tmpfile) = tempfile() or die("Can't open temporary file for writing: $!\n");
+($tmpfile_fh, $tmpfile) = tempfile() or die("Cannot open temporary file for writing: $!\n");
-# Determine if we need MyISAM, InnoDB, or both vals, then
-# get vals and system vars from MySQL or infile, then
-# set vals for our own vars
-which_vals();
-get_vals_vars();
-set_myisam_vals() if $need_myisam_vals;
-set_ib_vals() if $need_innodb_vals;
+if($op{'detach'})
+{
+ $SIG{'TERM'} = 'sig_handler';
+ if(fork())
+ {
+ print "mysqlreport has forked and detached.\n";
+ print "While running detached, mysqlreport writes reports to '$tmpfile'.\n";
-# Write the reports
+ exit;
+ }
+
+ open(STDIN, "</dev/null");
+ open(STDOUT, "> $tmpfile") or die "Cannot dup STDOUT: $!\n";
+ open(STDERR, "> $tmpfile") or die "Cannot dup STDERR: $!\n";
+}
+
select $tmpfile_fh;
-$~ = 'MYSQL_TIME', write;
-if($need_myisam_vals)
+$| = 1 if ($op{'detach'} || $relative_live);
+
+# Connect to MySQL
+if(!$op{'infile'} && !$relative_infiles)
{
- $~ = '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; }
+ my $dsn;
+
+ if($mycnf{'socket'} && -S $mycnf{'socket'})
+ {
+ $dsn = "DBI:mysql:mysql_socket=$mycnf{socket}";
+ }
+ elsif($mycnf{'host'})
+ {
+ $dsn = "DBI:mysql:host=$mycnf{host}" . ($mycnf{port} ? ";port=$mycnf{port}" : "");
+ }
+ else
+ {
+ $dsn = "DBI:mysql:host=localhost";
+ }
+
+ if($op{debug})
+ {
+ print "DBI DSN: $dsn\n";
+ }
+
+ $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die;
}
-write_InnoDB() if $need_innodb_vals;
-close $tmpfile_fh and select STDOUT;
-email_report($tmpfile) if have_op 'email';
+# Determine if we need values from MyISAM, InnoDB, or both
+which_vals();
-cat_report($tmpfile);
+if(defined $op{'r'})
+{
+ if($relative_live)
+ {
+ print STDERR "mysqlreport is writing relative reports to '$tmpfile'.\n" unless $op{'detach'};
+ get_MySQL_version();
+ collect_reports();
+ }
-if(have_op 'outfile')
-{
- if($WIN) { `move $tmpfile $op{outfile}`; }
- else { `mv $tmpfile $op{outfile}`; }
+ if($relative_infiles) { read_relative_infiles(); }
}
else
{
- if($WIN) { `del $tmpfile`; }
- else { `rm -f $tmpfile`; }
-}
-
-if(!have_op 'infile')
-{
- if($op{'flush-status'})
+ if(!$op{'infile'})
{
- $query = $dbh->prepare("FLUSH STATUS;");
- $query->execute();
+ get_MySQL_version();
+ get_vals();
+ get_vars();
}
+ else
+ {
+ read_infile($op{'infile'});
+ }
- $query->finish();
- $dbh->disconnect();
+ get_Com_values();
+
+ set_myisam_vals() if $need_myisam_vals;
+ set_ib_vals() if $need_innodb_vals;
+
+ write_report();
}
+exit_tasks_and_cleanup();
+
exit;
#
@@ -178,31 +205,40 @@
sub show_help_and_exit
{
print <<"HELP";
-mysqlreport v3.0a Dec 12 2006
+mysqlreport v3.2 May 26 2007
mysqlreport makes an easy-to-read report of important MySQL status values.
Command line options (abbreviations work):
- --user USER Connect to MySQL as USER
- --password PASS Use PASS or prompt for MySQL user's password
- --host ADDRESS Connect to MySQL at ADDRESS
- --port PORT Connect to MySQL at PORT
- --socket SOCKET Connect to MySQL at SOCKET
- --no-mycnf Don't read ~/.my.cnf
+ --user USER Connect to MySQL as USER
+ --password PASS Use PASS or prompt for MySQL user's password
+ --host ADDRESS Connect to MySQL at ADDRESS
+ --port PORT Connect to MySQL at PORT
+ --socket SOCKET Connect to MySQL at SOCKET
+ --no-mycnf Don't read ~/.my.cnf
+ --infile FILE Read status values from FILE instead of MySQL
+ --outfile FILE Write report to FILE
+ --email ADDRESS Email report to ADDRESS (doesn't work on Windows)
+ --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.
+ --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
- --qcache Show Query Cache report
--innodb Show InnoDB report
- --innodb-only Show only InnoDB report (hide all other reports)
+ --innodb-only Show only InnoDB report (hide ALL other reports)
--dpr Show Data, Pages, Rows report in InnoDB report
- --all Show --dtq --dms --com 3 --sas --tab --qcache --innodb --dpr
- --infile FILE Read status values from FILE instead of MySQL
- --outfile FILE Write report to FILE
- --email ADDRESS Email report to ADDRESS (doesn't work on Windows)
- --flush-status Issue FLUSH STATUS; after getting current values
- --help Prints this
+ --all Show ALL extra reports (if possible)
Visit http://hackmysql.com/mysqlreport for more information.
HELP
@@ -214,7 +250,14 @@
{
return if $WIN;
open MYCNF, "$ENV{HOME}/.my.cnf" or return;
- while(<MYCNF>) { $mycnf{$1} = $2 if /^(.+?)\s*=\s*"?(.+?)"?\s*$/; }
+ while(<MYCNF>)
+ {
+ if(/^(.+?)\s*=\s*"?(.+?)"?\s*$/)
+ {
+ $mycnf{$1} = $2;
+ print "get_user_mycnf: read '$1 = $2'\n" if $op{debug};
+ }
+ }
$mycnf{'pass'} ||= $mycnf{'password'} if exists $mycnf{'password'};
close MYCNF;
}
@@ -228,69 +271,237 @@
$need_innodb_vals = 0, return if (!$op{'id'} && !$op{'id-only'} && !$op{'all'});
}
-sub get_vals_vars
+sub collect_reports
{
- if(!have_op 'infile')
+ my $i;
+
+ get_vals();
+ get_vars();
+
+ get_Com_values();
+
+ %stats_past = %stats;
+
+ set_myisam_vals() if $need_myisam_vals;
+ set_ib_vals() if $need_innodb_vals;
+
+ print "#\n# Begining report @ 0 0:0:0\n#\n";
+
+ write_report();
+
+ for($i = 0; $i < $op{'c'}; $i++)
{
- my @row;
+ sleep($op{'r'});
- get_MySQL_version();
+ print "\n#\n# Interval report " , $i + 1 , " @ +", sec_to_dhms(($i + 1) * $op{'r'}), "\n#\n";
- # Get status values
- if($major >= 5 && (($minor == 0 && $patch >= 2) || $minor > 0)) {
- $query = $dbh->prepare("SHOW GLOBAL STATUS;");
- }
- else {
- $query = $dbh->prepare("SHOW STATUS;");
- $need_innodb_vals = 0;
- }
- $query->execute();
- while(@row = $query->fetchrow_array()) { $stats{$row[0]} = $row[1]; }
+ get_vals();
- # Get server system variables
- $query = $dbh->prepare("SHOW VARIABLES;");
- $query->execute();
- while(@row = $query->fetchrow_array()) { $vars{$row[0]} = $row[1]; }
+ write_relative_report();
}
- else
+}
+
+sub read_relative_infiles
+{
+ my $slurp; # Used to check infiles for multiple sets of status values
+ my $n_stats; # Number of multiple sets of status values in an infile
+ my $infile;
+ my $report_n; # Report number
+
+ $report_n = 1;
+
+ foreach $infile (@ARGV)
{
- # Default values if not set in INFILE
- $vars{'version'} = "0.0.0";
- $vars{'table_cache'} = 64;
- $vars{'max_connections'} = 100;
- # key_cache_block_size
- $vars{'key_buffer_size'} = 8388600; # 8M
- # query_cache_size
- $vars{'thread_cache_size'} = 0;
+ # Read all of infile into $slurp
+ open INFILE, "< $infile" or warn and next;
+ $slurp = do { local $/; <INFILE> };
+ close INFILE;
- open INFILE, "< $op{infile}" or die;
- while(<INFILE>)
+ $n_stats = 0;
+
+ # Count number of status value sets
+ $n_stats++ while $slurp =~ /Variable_name[\s|]+Value/g;
+
+ if($n_stats == 1)
{
- next if /^\+\-/;
- next if /^$/;
+ read_infile($infile);
+ relative_infile_report($report_n++);
+ }
- chomp;
+ if($n_stats > 1)
+ {
+ my @tmpfile_fh;
+ my @tmpfile_name;
+ my $i;
+ my $stat_n; # Status value set number
- if(/([A-Za-z_]+)[\s|]+(\d+)/)
+ # Create a tmp file for each set of status values
+ for($i = 0; $i < $n_stats; $i++)
{
- $stats{$1} = $2;
- next;
+ my ($fh, $name) = tempfile() or die("Cannot open temporary file for writing: $!\n");
+ push(@tmpfile_fh, $fh);
+ push(@tmpfile_name, $name);
}
- # 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";
+ $i = 0;
+ $stat_n = 0;
+
+ select $tmpfile_fh[$i];
+
+ # Read infile again and copy each set of status values
+ # to seperate tmp files
+ open INFILE, "< $infile" or warn and next;
+ while(<INFILE>)
+ {
+ next if /^\+/;
+ next if /^$/;
+
+ print;
+
+ if(/Variable_name[\s|]+Value/)
+ {
+ # 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 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/
+ # occurs again. Then begins the second and subsequent sets
+ # of status values.
+ next if $stat_n++ == 0;
+
+ select $tmpfile_fh[++$i];
+ }
+ }
+ close INFILE;
+
+ # Re-select the main tmp file into which the reports are being written.
+ select $tmpfile_fh;
+
+ for($i = 0; $i < $n_stats; $i++)
+ {
+ close $tmpfile_fh[$i];
+
+ read_infile($tmpfile_name[$i]);
+ relative_infile_report($report_n++);
+
+ if($WIN) { `del $tmpfile_name[$i]`; }
+ else { `rm -f $tmpfile_name[$i]`; }
+ }
+
+ } # if($n_stats > 1)
+ } # foreach $infile (@files)
+}
+
+sub relative_infile_report
+{
+ my $report_n = shift;
+
+ if($report_n == 1)
+ {
+ get_Com_values();
+
+ %stats_past = %stats;
+
+ set_myisam_vals() if $need_myisam_vals;
+ set_ib_vals() if $need_innodb_vals;
+
+ print "#\n# Begining 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";
+ write_relative_report();
+ }
+}
+
+sub get_vals
+{
+ my @row;
+
+ # Get status values
+ if($major >= 5 && (($minor == 0 && $patch >= 2) || $minor > 0))
+ {
+ $query = $dbh->prepare("SHOW GLOBAL STATUS;");
+ }
+ else
+ {
+ $query = $dbh->prepare("SHOW STATUS;");
+ }
+ $query->execute();
+ while(@row = $query->fetchrow_array()) { $stats{$row[0]} = $row[1]; }
+
+ $real_uptime = $stats{'Uptime'};
+}
+
+sub get_vars
+{
+ my @row;
+
+ # Get server system variables
+ $query = $dbh->prepare("SHOW VARIABLES;");
+ $query->execute();
+ while(@row = $query->fetchrow_array()) { $vars{$row[0]} = $row[1]; }
+
+ # table_cache was renamed to table_open_cache in MySQL 5.1.3
+ if($major >= 5 && (($minor == 1 && $patch >= 3) || $minor > 1))
+ {
+ $vars{'table_cache'} = $vars{'table_open_cache'};
+ }
+}
+
+sub read_infile
+{
+ my $infile = shift;
+
+ # Default values if not set in INFILE
+ $vars{'version'} = "0.0.0" if !exists $vars{'version'};
+ $vars{'table_cache'} = 64 if !exists $vars{'table_cache'};
+ $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'};
+
+ # One should also add:
+ # key_cache_block_size
+ # query_cache_size
+ # to their infile if needed.
+
+ open INFILE, "< $infile" or warn;
+ while(<INFILE>)
+ {
+ next if /^\+\-/;
+ next if /^$/;
+
+ chomp;
+
+ if(/([A-Za-z_]+)[\s\t|]+(\d+)/)
+ {
+ $stats{$1} = $2;
+ next;
}
- close INFILE;
- get_MySQL_version();
+ # 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";
}
+ close INFILE;
+
+ $real_uptime = $stats{'Uptime'};
+
+ $vars{'table_cache'} = $vars{'table_open_cache'} if exists $vars{'table_open_cache'};
+
+ get_MySQL_version();
}
sub get_MySQL_version
{
- if(have_op 'infile')
+ return if $major;
+
+ if($op{'infile'} || $relative_infiles)
{
($major, $minor, $patch) = ($vars{'version'} =~ /(\d{1,2})\.(\d{1,2})\.(\d{1,2})/);
}
@@ -303,20 +514,27 @@
@row = $query->fetchrow_array();
($major, $minor, $patch) = ($row[1] =~ /(\d{1,2})\.(\d{1,2})\.(\d{1,2})/);
}
+
+ # Innodb_ status values were added in 5.0.2
+ if($major <= 4 || $patch < 2)
+ {
+ $need_innodb_vals = 0;
+ print "get_MySQL_version: no InnoDB reports because MySQL version is older than 5.0.2\n" if $op{debug};
+ }
}
sub set_myisam_vals
{
$questions = $stats{'Questions'};
- $key_read_ratio = sprintf "%.3f",
+ $key_read_ratio = sprintf "%.2f",
($stats{'Key_read_requests'} ?
- $stats{'Key_reads'} / $stats{'Key_read_requests'} :
+ 100 - ($stats{'Key_reads'} / $stats{'Key_read_requests'}) * 100 :
0);
- $key_write_ratio = sprintf "%.3f",
+ $key_write_ratio = sprintf "%.2f",
($stats{'Key_write_requests'} ?
- $stats{'Key_writes'} / $stats{'Key_write_requests'} :
+ 100 - ($stats{'Key_writes'} / $stats{'Key_write_requests'}) * 100 :
0);
$key_cache_block_size = (defined $vars{'key_cache_block_size'} ?
@@ -325,14 +543,16 @@
$key_buffer_used = $stats{'Key_blocks_used'} * $key_cache_block_size;
- if(defined $stats{'Key_blocks_unused'}) { # MySQL 4.1.2+
+ if(defined $stats{'Key_blocks_unused'}) # MySQL 4.1.2+
+ {
$key_buffer_usage = $vars{'key_buffer_size'} -
($stats{'Key_blocks_unused'} * $key_cache_block_size);
}
else { $key_buffer_usage = -1; }
# Data Manipulation Statements: http://dev.mysql.com/doc/refman/5.0/en/data-manipulation.html
- %DMS_vals = (
+ %DMS_vals =
+ (
SELECT => $stats{'Com_select'},
INSERT => $stats{'Com_insert'} + $stats{'Com_insert_select'},
REPLACE => $stats{'Com_replace'} + $stats{'Com_replace_select'},
@@ -359,6 +579,64 @@
0);
}
+sub write_relative_report
+{
+ %stats_present = %stats;
+
+ for(keys %stats)
+ {
+ if($stats_past{$_} =~ /\d+/)
+ {
+ if($stats_present{$_} >= $stats_past{$_}) # Avoid negative values
+ {
+ $stats{$_} = $stats_present{$_} - $stats_past{$_};
+ }
+ }
+ }
+
+ # 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.
+ $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'};
+ $stats{'Threads_running'} = $stats_present{'Threads_running'};
+ $stats{'Threads_connected'} = $stats_present{'Threads_connected'};
+ $stats{'Threads_cached'} = $stats_present{'Threads_cached'};
+ $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'};
+
+ get_Com_values();
+
+ %stats_past = %stats_present;
+
+ set_myisam_vals() if $need_myisam_vals;
+ set_ib_vals() if $need_innodb_vals;
+
+ write_report();
+}
+
+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;
+}
+
sub sec_to_dhms # Seconds to days hours:minutes:seconds
{
my $s = shift;
@@ -423,7 +701,7 @@
open SENDMAIL, "|/usr/sbin/sendmail -t";
print SENDMAIL "From: mysqlreport\n";
print SENDMAIL "To: $op{email}\n";
- print SENDMAIL "Subject: MySQL status report on $mycnf{'host'}\n\n";
+ print SENDMAIL "Subject: MySQL status report on " . ($mycnf{'host'} || 'localhost') . "\n\n";
print SENDMAIL `cat $report`;
close SENDMAIL;
}
@@ -441,6 +719,8 @@
sub get_Com_values
{
+ %Com_vals = ();
+
# Make copy of just the Com_ values
for(keys %stats)
{
@@ -470,8 +750,6 @@
my %DTQ;
my $first = 1;
- get_Com_values();
-
# Total Com values
$stat_val = 0;
for(values %Com_vals) { $stat_val += $_; }
@@ -483,7 +761,8 @@
$stat_val = 0;
for(values %DTQ) { $stat_val += $_; }
- if($questions != $stat_val) {
+ if($questions != $stat_val)
+ {
$DTQ{($questions > $stat_val ? '+Unknown' : '-Unknown')} = abs $questions - $stat_val;
}
@@ -512,10 +791,10 @@
sub write_Com # Write COM report in descending order by values
{
+ my $i = $op{'com'};
+
$~ = 'COM_1';
- get_Com_values() if !$op{'dtq'};
-
# Total Com values and write first line of COM report
$stat_label = '%Total:' unless $op{'dtq'};
$stat_val = 0;
@@ -531,7 +810,7 @@
$stat_val = $Com_vals{$_};
write;
- last if !(--$op{'com'});
+ last if !(--$i);
}
}
@@ -540,6 +819,7 @@
# Query cache was added in 4.0.1, but have_query_cache was added in 4.0.2,
# ergo this method is slightly more reliable
return if not exists $vars{'query_cache_size'};
+ return if $vars{'query_cache_size'} == 0;
$qc_mem_used = $vars{'query_cache_size'} - $stats{'Qcache_free_memory'};
$qc_hi_r = sprintf "%.2f", $stats{'Qcache_hits'} / ($stats{'Qcache_inserts'} ||= 1);
@@ -582,14 +862,53 @@
return 0;
}
+sub sig_handler
+{
+ print "\nReceived signal at " , scalar localtime , "\n";
+ exit_tasks_and_cleanup();
+ exit;
+}
+sub exit_tasks_and_cleanup
+{
+ close $tmpfile_fh;
+ select STDOUT unless $op{'detach'};
+
+ email_report($tmpfile) if $op{'email'};
+
+ cat_report($tmpfile) unless $op{'detach'};
+
+ if($op{'outfile'})
+ {
+ if($WIN) { `move $tmpfile $op{outfile}`; }
+ else { `mv $tmpfile $op{outfile}`; }
+ }
+ else
+ {
+ if($WIN) { `del $tmpfile`; }
+ else { `rm -f $tmpfile`; }
+ }
+
+ if(!$op{'infile'} && !$relative_infiles)
+ {
+ if($op{'flush-status'})
+ {
+ $query = $dbh->prepare("FLUSH STATUS;");
+ $query->execute();
+ }
+
+ $query->finish();
+ $dbh->disconnect();
+ }
+}
+
#
# Formats
#
format MYSQL_TIME =
MySQL @<<<<<<<<<<<<<<<< uptime @<<<<<<<<<<< @>>>>>>>>>>>>>>>>>>>>>>>>
-$vars{'version'}, sec_to_dhms($stats{'Uptime'}), scalar localtime
+$vars{'version'}, sec_to_dhms($real_uptime), (($op{infile} || $relative_infiles) ? '' : scalar localtime)
.
format KEY_BUFF_MAX =
@@ -605,9 +924,9 @@
.
format KEY_RATIOS =
-Write ratio @>>>>>>
+Write hit @>>>>>%
$key_write_ratio
-Read ratio @>>>>>>
+Read hit @>>>>>%
$key_read_ratio
__ Questions ___________________________________________________________
@@ -691,7 +1010,7 @@
__ Tables ______________________________________________________________
Open @>>>>>>>> of @>>> %Cache: @>>>>>
-make_short($stats{'Open_tables'}), $vars{'table_cache'}, perc($stats{'Open_tables'}, $vars{'table_cache'})
+$stats{'Open_tables'}, $vars{'table_cache'}, perc($stats{'Open_tables'}, $vars{'table_cache'})
Opened @>>>>>>>> @>>>>>/s
make_short($stats{'Opened_tables'}), t($stats{'Opened_tables'})
@@ -798,8 +1117,8 @@
$stats{'Innodb_data_pending_reads'}, t($stats{'Innodb_data_pending_reads'})
Writes @>>>>>>>>
$stats{'Innodb_data_pending_writes'}, t($stats{'Innodb_data_pending_writes'})
- fysnc @>>>>>>>>
-$stats{'Innodb_data_pending_fsyncs'}, t($stats{'Innodb_data_pending_fysncs'})
+ fsync @>>>>>>>>
+$stats{'Innodb_data_pending_fsyncs'}, t($stats{'Innodb_data_pending_fsyncs'})
Pages
Created @>>>>>>>> @>>>>>/s
Modified: branches/sid-5.0/debian/changelog
===================================================================
--- branches/sid-5.0/debian/changelog 2007-12-04 22:57:54 UTC (rev 1038)
+++ branches/sid-5.0/debian/changelog 2007-12-05 22:21:43 UTC (rev 1039)
@@ -13,8 +13,9 @@
(patch from Edward Allcutt). (closes: #453127)
* New Finnish debconf translation from Esko Arajärvi. (closes: #448776)
* Add Vcs-* and Homepage fields to source stanza in control file.
+ * Update mysqlreport to 3.2 release.
- -- Norbert Tretkowski <nobse at debian.org> Tue, 04 Dec 2007 23:56:23 +0100
+ -- Norbert Tretkowski <nobse at debian.org> Wed, 05 Dec 2007 23:20:47 +0100
mysql-dfsg-5.0 (5.0.45-3) unstable; urgency=high
More information about the Pkg-mysql-commits
mailing list