Adding stop after dumping option
This commit is contained in:
parent
29ad424da2
commit
96fbedff72
1 changed files with 24 additions and 2 deletions
|
@ -111,6 +111,7 @@ my %opt = (
|
|||
"defaults-extra-file" => '',
|
||||
"protocol" => '',
|
||||
"dumpdir" => '',
|
||||
"stop-after-dumping" => 0,
|
||||
);
|
||||
|
||||
# Gather the options from the command line
|
||||
|
@ -143,6 +144,7 @@ GetOptions(
|
|||
'idxstat', 'noidxstat',
|
||||
'server-log=s', 'protocol=s',
|
||||
'defaults-extra-file=s', 'dumpdir=s',
|
||||
'stop-after-dumping'
|
||||
)
|
||||
or pod2usage(
|
||||
-exitval => 1,
|
||||
|
@ -1035,17 +1037,35 @@ sub select_array {
|
|||
return @result;
|
||||
}
|
||||
|
||||
# MySQL Request Array
|
||||
sub select_array_with_headers {
|
||||
my $req = shift;
|
||||
debugprint "PERFORM: $req ";
|
||||
my @result = `$mysqlcmd $mysqllogin -Bs --column-name -e "\\w$req" 2>>/dev/null`;
|
||||
if ( $? != 0 ) {
|
||||
badprint "Failed to execute: $req";
|
||||
badprint "FAIL Execute SQL / return code: $?";
|
||||
debugprint "CMD : $mysqlcmd";
|
||||
debugprint "OPTIONS: $mysqllogin";
|
||||
debugprint `$mysqlcmd $mysqllogin -Bse "$req" 2>&1`;
|
||||
|
||||
#exit $?;
|
||||
}
|
||||
debugprint "select_array: return code : $?";
|
||||
chomp(@result);
|
||||
return @result;
|
||||
}
|
||||
# MySQL Request Array
|
||||
sub select_csv_file {
|
||||
my $tfile = shift;
|
||||
my $req = shift;
|
||||
debugprint "PERFORM: $req CSV into $tfile";
|
||||
my @result = select_array($req);
|
||||
my @result = select_array_with_headers($req);
|
||||
open( my $fh, '>', $tfile ) or die "Could not open file '$tfile' $!";
|
||||
for my $l (@result) {
|
||||
$l =~ s/\t/","/g;
|
||||
$l =~ s/^/"/;
|
||||
$l =~ s/$/"/;
|
||||
$l =~ s/$/"\n/;
|
||||
print $fh $l;
|
||||
}
|
||||
close $fh;
|
||||
|
@ -2653,6 +2673,7 @@ sub calculations {
|
|||
exit 2;
|
||||
}
|
||||
|
||||
# Per-thread memory
|
||||
# Per-thread memory
|
||||
if ( mysql_version_ge(4) ) {
|
||||
$mycalc{'per_thread_buffers'} =
|
||||
|
@ -3951,6 +3972,7 @@ sub mysqsl_pfs {
|
|||
);
|
||||
}
|
||||
}
|
||||
exit 0 if ( $opt{stop-after-dumping} == 1 );
|
||||
|
||||
# Top user per connection
|
||||
subheaderprint "Performance schema: Top 5 user per connection";
|
||||
|
|
Loading…
Reference in a new issue