#164 removing by default check for 10 opened ports. option maxallowedport added for this case.

This commit is contained in:
root 2016-03-23 16:33:02 +01:00
parent 95c1397289
commit 30b7f2e52c

View file

@ -1,5 +1,5 @@
#!/usr/bin/env perl #!/usr/bin/env perl
# mysqltuner.pl - Version 1.6.7 # mysqltuner.pl - Version 1.6.8
# High Performance MySQL Tuning Script # High Performance MySQL Tuning Script
# Copyright (C) 2006-2015 Major Hayden - major@mhtx.net # Copyright (C) 2006-2015 Major Hayden - major@mhtx.net
# #
@ -51,7 +51,7 @@ use Data::Dumper;
$Data::Dumper::Pair = " : "; $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.7"; my $tunerversion = "1.6.8";
my ( @adjvars, @generalrec ); my ( @adjvars, @generalrec );
# Set defaults # Set defaults
@ -74,6 +74,7 @@ my %opt = (
"buffers" => 0, "buffers" => 0,
"passwordfile" => 0, "passwordfile" => 0,
"bannedports" => '', "bannedports" => '',
"maxportallowed"= >0,
"outputfile" => 0, "outputfile" => 0,
"dbstat" => 0, "dbstat" => 0,
"idxstat" => 0, "idxstat" => 0,
@ -93,7 +94,7 @@ GetOptions(
'mysqlcmd=s', 'help', 'buffers', 'skippassword', 'mysqlcmd=s', 'help', 'buffers', 'skippassword',
'passwordfile=s', 'outputfile=s', 'silent', 'dbstat', 'json', 'passwordfile=s', 'outputfile=s', 'silent', 'dbstat', 'json',
'idxstat', 'noask', 'template=s', 'reportfile=s', 'cvefile=s', 'idxstat', 'noask', 'template=s', 'reportfile=s', 'cvefile=s',
'bannedports=s', 'bannedports=s','maxportallowed=s'
); );
if ( defined $opt{'help'} && $opt{'help'} == 1 ) { usage(); } if ( defined $opt{'help'} && $opt{'help'} == 1 ) { usage(); }
@ -136,7 +137,8 @@ sub usage {
. " --debug Print debug information\n" . " --debug Print debug information\n"
. " --dbstat Print database information\n" . " --dbstat Print database information\n"
. " --idxstat Print index information\n" . " --idxstat Print index information\n"
. " --bannedports ports banned separated by comma(,)\n" . " --bannedports Ports banned separated by comma(,)\n"
. " --maxportallowed Number of ports opened allowed on this hosts\n"
. " --cvefile CVE File for vulnerability checks\n" . " --cvefile CVE File for vulnerability checks\n"
. " --nocolor Don't print output in color\n" . " --nocolor Don't print output in color\n"
. " --json Print result as JSON string\n" . " --json Print result as JSON string\n"
@ -955,16 +957,17 @@ sub system_recommendations {
#if ($omem > #if ($omem >
#exit 0; #exit 0;
my @opened_ports=get_opened_ports; if ($opt{'maxportallowed'} > 0) {
infoprint "There is ". scalar @opened_ports. " listening port(s) on this server."; my @opened_ports=get_opened_ports;
if (scalar(@opened_ports) > 10) { infoprint "There is ". scalar @opened_ports. " listening port(s) on this server.";
badprint "There is too many listening ports: ". scalar(@opened_ports). " > 10"; if (scalar(@opened_ports) > $opt{'maxportallowed'}) {
push( @generalrec, "Consider dedicating a server for your database installation with less services running on !" ); badprint "There is too many listening ports: ". scalar(@opened_ports). " > 10";
} else { push( @generalrec, "Consider dedicating a server for your database installation with less services running on !" );
goodprint "There is less than 10 opened ports on this server."; } else {
goodprint "There is less than ".$opt{'maxportallowed'}." opened ports on this server.";
}
} }
# if ( is_open_port(80) or is_open_port(443) ) {
# if ( is_open_port(80) or is_open_port(443) ) {
# badprint "There is Apache like server running on 80 or 443 port."; # badprint "There is Apache like server running on 80 or 443 port.";
# push( @generalrec, "Consider dedicating a server for Web server in production !" ); # push( @generalrec, "Consider dedicating a server for Web server in production !" );
# } else { # } else {
@ -3264,7 +3267,7 @@ __END__
=head1 NAME =head1 NAME
MySQLTuner 1.6.7 - MySQL High Performance Tuning Script MySQLTuner 1.6.8 - MySQL High Performance Tuning Script
=head1 IMPORTANT USAGE GUIDELINES =head1 IMPORTANT USAGE GUIDELINES
@ -3302,7 +3305,8 @@ You must provide the remote server's total memory when connecting to other serve
--debug Print debug information --debug Print debug information
--dbstat Print database information --dbstat Print database information
--idxstat Print index information --idxstat Print index information
--bannedports ports banned separated by comma(,) --bannedports Ports banned separated by comma(,)
--maxportallowed Number of ports opened allowed on this hosts
--cvefile CVE File for vulnerability checks --cvefile CVE File for vulnerability checks
--nocolor Don't print output in color --nocolor Don't print output in color
--json Print result as JSON string --json Print result as JSON string