Merge pull request #137 from cloos/dependencies
Dependencies Thanks @cloos This solution is nicer than the way I try to do it :)
This commit is contained in:
commit
8935266d06
1 changed files with 30 additions and 45 deletions
|
@ -36,14 +36,20 @@
|
||||||
# http://forge.mysql.com/projects/view.php?id=44
|
# http://forge.mysql.com/projects/view.php?id=44
|
||||||
#
|
#
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
|
use 5.005;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use diagnostics;
|
use diagnostics;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Cwd 'abs_path';
|
use Cwd 'abs_path';
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
$Data::Dumper::Pair = " : ";
|
||||||
|
|
||||||
# Set up a few variables for use in the script
|
# Set up a few variables for use in the script
|
||||||
my $tunerversion = "1.6.1";
|
my $tunerversion = "1.6.1";
|
||||||
my ( @adjvars, @generalrec );
|
my ( @adjvars, @generalrec );
|
||||||
|
@ -365,23 +371,23 @@ sub validate_tuner_version {
|
||||||
chomp($httpcli);
|
chomp($httpcli);
|
||||||
if ( 1 != 1 and defined($httpcli) and -e "$httpcli" ) {
|
if ( 1 != 1 and defined($httpcli) and -e "$httpcli" ) {
|
||||||
debugprint "$httpcli is available.";
|
debugprint "$httpcli is available.";
|
||||||
|
|
||||||
debugprint "$httpcli --connect-timeout 5 -silent '$url' 2>/dev/null | grep 'my \$tunerversion'| cut -d\\\" -f2";
|
debugprint "$httpcli --connect-timeout 5 -silent '$url' 2>/dev/null | grep 'my \$tunerversion'| cut -d\\\" -f2";
|
||||||
$update = `$httpcli --connect-timeout 5 -silent '$url' 2>/dev/null | grep 'my \$tunerversion'| cut -d\\\" -f2`;
|
$update = `$httpcli --connect-timeout 5 -silent '$url' 2>/dev/null | grep 'my \$tunerversion'| cut -d\\\" -f2`;
|
||||||
chomp($update);
|
chomp($update);
|
||||||
debugprint "VERSION: $update";
|
debugprint "VERSION: $update";
|
||||||
|
|
||||||
|
|
||||||
compare_tuner_version($update);
|
compare_tuner_version($update);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$httpcli=`which wget`;
|
$httpcli=`which wget`;
|
||||||
chomp($httpcli);
|
chomp($httpcli);
|
||||||
if ( defined($httpcli) and -e "$httpcli" ) {
|
if ( defined($httpcli) and -e "$httpcli" ) {
|
||||||
debugprint "$httpcli is available.";
|
debugprint "$httpcli is available.";
|
||||||
|
|
||||||
debugprint "$httpcli -e timestamping=off -T 5 -O - '$url' 2>$devnull| grep 'my \$tunerversion'| cut -d\\\" -f2";
|
debugprint "$httpcli -e timestamping=off -T 5 -O - '$url' 2>$devnull| grep 'my \$tunerversion'| cut -d\\\" -f2";
|
||||||
$update = `$httpcli -e timestamping=off -T 5 -O - '$url' 2>$devnull| grep 'my \$tunerversion'| cut -d\\\" -f2`;
|
$update = `$httpcli -e timestamping=off -T 5 -O - '$url' 2>$devnull| grep 'my \$tunerversion'| cut -d\\\" -f2`;
|
||||||
chomp($update);
|
chomp($update);
|
||||||
|
@ -639,19 +645,6 @@ sub mysql_setup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub try_load {
|
|
||||||
my $mod = shift;
|
|
||||||
|
|
||||||
eval("use $mod");
|
|
||||||
|
|
||||||
if ($@) {
|
|
||||||
#print "\$@ = $@\n";
|
|
||||||
return(0);
|
|
||||||
} else {
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# MySQL Request Array
|
# MySQL Request Array
|
||||||
sub select_array {
|
sub select_array {
|
||||||
my $req = shift;
|
my $req = shift;
|
||||||
|
@ -1132,7 +1125,7 @@ sub check_storage_engines {
|
||||||
chomp($db);
|
chomp($db);
|
||||||
if ( $db eq "information_schema"
|
if ( $db eq "information_schema"
|
||||||
or $db eq "performance_schema"
|
or $db eq "performance_schema"
|
||||||
or $db eq "mysql"
|
or $db eq "mysql"
|
||||||
or $db eq "lost+found" )
|
or $db eq "lost+found" )
|
||||||
{
|
{
|
||||||
next;
|
next;
|
||||||
|
@ -1687,7 +1680,7 @@ sub mysql_stats {
|
||||||
|
|
||||||
if ( defined $myvar{'query_cache_type'} ) {
|
if ( defined $myvar{'query_cache_type'} ) {
|
||||||
infoprint "Query Cache Buffers";
|
infoprint "Query Cache Buffers";
|
||||||
infoprint " +-- Query Cache: "
|
infoprint " +-- Query Cache: "
|
||||||
. $myvar{'query_cache_type'} . " - "
|
. $myvar{'query_cache_type'} . " - "
|
||||||
. (
|
. (
|
||||||
$myvar{'query_cache_type'} eq 0 |
|
$myvar{'query_cache_type'} eq 0 |
|
||||||
|
@ -2161,7 +2154,7 @@ sub mysql_myisam {
|
||||||
. " used / "
|
. " used / "
|
||||||
. hr_num( $myvar{'key_buffer_size'} )
|
. hr_num( $myvar{'key_buffer_size'} )
|
||||||
. " cache)";
|
. " cache)";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Key buffer
|
# Key buffer
|
||||||
if ( !defined( $mycalc{'total_myisam_indexes'} ) and $doremote == 1 ) {
|
if ( !defined( $mycalc{'total_myisam_indexes'} ) and $doremote == 1 ) {
|
||||||
|
@ -2639,7 +2632,7 @@ FROM INFORMATION_SCHEMA.STATISTICS s
|
||||||
ON s.TABLE_SCHEMA = t.TABLE_SCHEMA
|
ON s.TABLE_SCHEMA = t.TABLE_SCHEMA
|
||||||
AND s.TABLE_NAME = t.TABLE_NAME
|
AND s.TABLE_NAME = t.TABLE_NAME
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
TABLE_SCHEMA
|
TABLE_SCHEMA
|
||||||
, TABLE_NAME
|
, TABLE_NAME
|
||||||
, INDEX_NAME
|
, INDEX_NAME
|
||||||
|
@ -2688,12 +2681,12 @@ ENDSQL
|
||||||
and $myvar{'performance_schema'} eq 'ON' );
|
and $myvar{'performance_schema'} eq 'ON' );
|
||||||
|
|
||||||
$selIdxReq = <<'ENDSQL';
|
$selIdxReq = <<'ENDSQL';
|
||||||
SELECT CONCAT(CONCAT(object_schema,'.'),object_name) AS 'table', index_name
|
SELECT CONCAT(CONCAT(object_schema,'.'),object_name) AS 'table', index_name
|
||||||
FROM performance_schema.table_io_waits_summary_by_index_usage
|
FROM performance_schema.table_io_waits_summary_by_index_usage
|
||||||
WHERE index_name IS NOT NULL
|
WHERE index_name IS NOT NULL
|
||||||
AND count_star =0
|
AND count_star =0
|
||||||
AND index_name <> 'PRIMARY'
|
AND index_name <> 'PRIMARY'
|
||||||
AND object_schema != 'mysql'
|
AND object_schema != 'mysql'
|
||||||
ORDER BY count_star, object_schema, object_name;
|
ORDER BY count_star, object_schema, object_name;
|
||||||
ENDSQL
|
ENDSQL
|
||||||
@idxinfo = select_array($selIdxReq);
|
@idxinfo = select_array($selIdxReq);
|
||||||
|
@ -2792,34 +2785,26 @@ END_TEMPLATE
|
||||||
}
|
}
|
||||||
sub dump_result {
|
sub dump_result {
|
||||||
if ($opt{'debug'}) {
|
if ($opt{'debug'}) {
|
||||||
|
|
||||||
if (try_load('Data::Dumper')) {
|
|
||||||
badprint "Data::Dumper Module is needed.";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
use Data::Dumper qw/Dumper/;
|
|
||||||
$Data::Dumper::Pair = " : ";
|
|
||||||
debugprint Dumper( \%result );
|
debugprint Dumper( \%result );
|
||||||
}
|
}
|
||||||
|
|
||||||
debugprint "HTML REPORT: $opt{'reportfile'}";
|
debugprint "HTML REPORT: $opt{'reportfile'}";
|
||||||
|
|
||||||
if ($opt{'reportfile'} ne 0 ) {
|
if ($opt{'reportfile'} ne 0 ) {
|
||||||
if (try_load('Text::Template')) {
|
eval "{ use Text::Template }";
|
||||||
|
if ($@) {
|
||||||
badprint "Text::Template Module is needed.";
|
badprint "Text::Template Module is needed.";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
if (try_load('Data::Dumper')) {
|
|
||||||
badprint "Data::Dumper Module is needed.";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
use Text::Template;
|
|
||||||
use Data::Dumper qw/Dumper/;
|
|
||||||
$Data::Dumper::Pair = " : ";
|
|
||||||
my $vars= {'data' => Dumper( \%result ) };
|
my $vars= {'data' => Dumper( \%result ) };
|
||||||
|
|
||||||
my $template = Text::Template->new(TYPE => 'STRING', PREPEND => q{;}, SOURCE => $templateModel)
|
my $template;
|
||||||
or die "Couldn't construct template: $Text::Template::ERROR";
|
{
|
||||||
|
no warnings 'once';
|
||||||
|
$template = Text::Template->new(TYPE => 'STRING', PREPEND => q{;}, SOURCE => $templateModel)
|
||||||
|
or die "Couldn't construct template: $Text::Template::ERROR";
|
||||||
|
}
|
||||||
open my $fh, q(>), $opt{'reportfile'}
|
open my $fh, q(>), $opt{'reportfile'}
|
||||||
or die "Unable to open $opt{'reportfile'} in write mode. please check permissions for this file or directory";
|
or die "Unable to open $opt{'reportfile'} in write mode. please check permissions for this file or directory";
|
||||||
$template->fill_in(HASH =>$vars, OUTPUT=>$fh );
|
$template->fill_in(HASH =>$vars, OUTPUT=>$fh );
|
||||||
|
@ -2893,7 +2878,7 @@ You must provide the remote server's total memory when connecting to other serve
|
||||||
--forcemem <size> Amount of RAM installed in megabytes
|
--forcemem <size> Amount of RAM installed in megabytes
|
||||||
--forceswap <size> Amount of swap memory configured in megabytes
|
--forceswap <size> Amount of swap memory configured in megabytes
|
||||||
--passwordfile <path>Path to a password file list(one password by line)
|
--passwordfile <path>Path to a password file list(one password by line)
|
||||||
|
|
||||||
=head1 OUTPUT OPTIONS
|
=head1 OUTPUT OPTIONS
|
||||||
--silent Don't output anything on screen
|
--silent Don't output anything on screen
|
||||||
--nogood Remove OK responses
|
--nogood Remove OK responses
|
||||||
|
|
Loading…
Reference in a new issue