Added GetOptions check if fails show help
Added verbose mode
This commit is contained in:
parent
5c9f9952aa
commit
6c280de32f
1 changed files with 100 additions and 84 deletions
|
@ -84,11 +84,12 @@ my %opt = (
|
||||||
"template" => 0,
|
"template" => 0,
|
||||||
"json" => 0,
|
"json" => 0,
|
||||||
"prettyjson" => 0,
|
"prettyjson" => 0,
|
||||||
"reportfile" => 0
|
"reportfile" => 0,
|
||||||
|
"verbose" => 0
|
||||||
);
|
);
|
||||||
|
|
||||||
# Gather the options from the command line
|
# Gather the options from the command line
|
||||||
GetOptions(
|
my $getOptionsCheck = GetOptions(
|
||||||
\%opt, 'nobad', 'nogood', 'noinfo',
|
\%opt, 'nobad', 'nogood', 'noinfo',
|
||||||
'debug', 'nocolor', 'forcemem=i', 'forceswap=i',
|
'debug', 'nocolor', 'forcemem=i', 'forceswap=i',
|
||||||
'host=s', 'socket=s', 'port=i', 'user=s',
|
'host=s', 'socket=s', 'port=i', 'user=s',
|
||||||
|
@ -97,9 +98,14 @@ GetOptions(
|
||||||
'passwordfile=s', 'outputfile=s', 'silent', 'dbstat',
|
'passwordfile=s', 'outputfile=s', 'silent', 'dbstat',
|
||||||
'json', 'prettyjson', 'idxstat', 'noask',
|
'json', 'prettyjson', 'idxstat', 'noask',
|
||||||
'template=s', 'reportfile=s', 'cvefile=s', 'bannedports=s',
|
'template=s', 'reportfile=s', 'cvefile=s', 'bannedports=s',
|
||||||
'updateversion', 'maxportallowed=s'
|
'updateversion', 'maxportallowed=s', 'verbose'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#If params are incorrect return help
|
||||||
|
if ($getOptionsCheck ne 1) {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
if ( defined $opt{'help'} && $opt{'help'} == 1 ) { usage(); }
|
if ( defined $opt{'help'} && $opt{'help'} == 1 ) { usage(); }
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
|
@ -150,7 +156,8 @@ sub usage {
|
||||||
. " --buffers Print global and per-thread buffer values\n"
|
. " --buffers Print global and per-thread buffer values\n"
|
||||||
. " --outputfile <path> Path to a output txt file\n" . "\n"
|
. " --outputfile <path> Path to a output txt file\n" . "\n"
|
||||||
. " --reportfile <path> Path to a report txt file\n" . "\n"
|
. " --reportfile <path> Path to a report txt file\n" . "\n"
|
||||||
. " --template <path> Path to a template file\n" . "\n";
|
. " --template <path> Path to a template file\n" . "\n"
|
||||||
|
. " --verbose Prints out all options (default: no verbose) \n" . "\n";
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +171,15 @@ my $basic_password_files =
|
||||||
$basic_password_files = "/usr/share/mysqltuner/basic_passwords.txt"
|
$basic_password_files = "/usr/share/mysqltuner/basic_passwords.txt"
|
||||||
unless -f "$basic_password_files";
|
unless -f "$basic_password_files";
|
||||||
|
|
||||||
|
# check if we need to enable verbose mode
|
||||||
|
if ($opt{verbose}) {
|
||||||
|
$opt{checkversion} = 1; #Check for updates to MySQLTuner
|
||||||
|
$opt{dbstat} = 1; #Print database information
|
||||||
|
$opt{idxstat} = 1; #Print index information
|
||||||
|
$opt{buffers} = 1; #Print global and per-thread buffer values
|
||||||
|
$opt{cvefile} = 'vulnerabilities.csv'; #CVE File for vulnerability checks
|
||||||
|
}
|
||||||
|
|
||||||
# for RPM distributions
|
# for RPM distributions
|
||||||
$opt{cvefile} = "/usr/share/mysqltuner/vulnerabilities.csv"
|
$opt{cvefile} = "/usr/share/mysqltuner/vulnerabilities.csv"
|
||||||
unless ( defined $opt{cvefile} and -f "$opt{cvefile}");
|
unless ( defined $opt{cvefile} and -f "$opt{cvefile}");
|
||||||
|
@ -3377,7 +3393,7 @@ You must provide the remote server's total memory when connecting to other serve
|
||||||
--outputfile <path> Path to a output txt file
|
--outputfile <path> Path to a output txt file
|
||||||
--reportfile <path> Path to a report txt file
|
--reportfile <path> Path to a report txt file
|
||||||
--template <path> Path to a template file
|
--template <path> Path to a template file
|
||||||
|
--verbose Prints out all options (default: no verbose)
|
||||||
=head1 PERLDOC
|
=head1 PERLDOC
|
||||||
|
|
||||||
You can find documentation for this module with the perldoc command.
|
You can find documentation for this module with the perldoc command.
|
||||||
|
|
Loading…
Reference in a new issue