Added GetOptions check if fails show help

Added verbose mode
This commit is contained in:
DutchProgrammer 2016-03-24 22:48:07 +01:00
parent 5c9f9952aa
commit 6c280de32f

View file

@ -84,11 +84,12 @@ my %opt = (
"template" => 0,
"json" => 0,
"prettyjson" => 0,
"reportfile" => 0
"reportfile" => 0,
"verbose" => 0
);
# Gather the options from the command line
GetOptions(
my $getOptionsCheck = GetOptions(
\%opt, 'nobad', 'nogood', 'noinfo',
'debug', 'nocolor', 'forcemem=i', 'forceswap=i',
'host=s', 'socket=s', 'port=i', 'user=s',
@ -97,9 +98,14 @@ GetOptions(
'passwordfile=s', 'outputfile=s', 'silent', 'dbstat',
'json', 'prettyjson', 'idxstat', 'noask',
'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(); }
sub usage {
@ -150,7 +156,8 @@ sub usage {
. " --buffers Print global and per-thread buffer values\n"
. " --outputfile <path> Path to a output 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;
}
@ -164,6 +171,15 @@ my $basic_password_files =
$basic_password_files = "/usr/share/mysqltuner/basic_passwords.txt"
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
$opt{cvefile} = "/usr/share/mysqltuner/vulnerabilities.csv"
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
--reportfile <path> Path to a report txt file
--template <path> Path to a template file
--verbose Prints out all options (default: no verbose)
=head1 PERLDOC
You can find documentation for this module with the perldoc command.