@@ -1949,7 +1949,7 @@ sub execute_system_command {
19491949
19501950 # Be less verbose for commands that are expected to fail on some systems
19511951 if ( $command !~
1952- /(?:^|\/)(dmesg|lspci|dmidecode|ipconfig|isainfo|bootinfo|ver|wmic|lsattr|prtconf|swapctl|swapinfo|svcprop|ps|ping|ifconfig|ip|hostname|who|free|top|uptime|netstat|sysctl|mysql|mariadb|curl|wget)/
1952+ /(?:^|\/)(dmesg|lspci|dmidecode|ipconfig|isainfo|bootinfo|ver|wmic|lsattr|prtconf|swapctl|swapinfo|svcprop|ps|ping|ifconfig|ip|hostname|who|free|top|uptime|netstat|sysctl|mysql|mariadb|curl|wget|which )/
19531953 )
19541954 {
19551955 badprint "System command failed: $command";
@@ -1980,7 +1980,8 @@ sub mysql_setup {
19801980 }
19811981 else {
19821982 if ($transport_prefix) {
1983- my $check = execute_system_command("which mariadb-admin");
1983+ my $check = execute_system_command(
1984+ "command -v mariadb-admin || command -v mysqladmin");
19841985 $mysqladmincmd =
19851986 ( $check =~ /mariadb-admin/ ) ? "mariadb-admin" : "mysqladmin";
19861987 }
@@ -2004,7 +2005,8 @@ sub mysql_setup {
20042005 }
20052006 else {
20062007 if ($transport_prefix ) {
2007- my $check = execute_system_command(" which mariadb" );
2008+ my $check =
2009+ execute_system_command(" command -v mariadb || command -v mysql" );
20082010 $mysqlcmd = ( $check =~ /mariadb/ ) ? " mariadb" : " mysql" ;
20092011 }
20102012 else {
@@ -2160,6 +2162,10 @@ sub mysql_setup {
21602162 goodprint " Logged in using credentials passed on the command line" ;
21612163 return 1;
21622164 }
2165+ else {
2166+ badprint " Attempted to use login credentials, but they were invalid." ;
2167+ debugprint " Login failure output: $loginstatus " ;
2168+ }
21632169 }
21642170
21652171 my $svcprop = which( " svcprop" , $ENV {' PATH' } );
@@ -2318,9 +2324,11 @@ sub mysql_setup {
23182324 exit 1;
23192325 }
23202326 my ( $name , $password );
2327+ $name = " " ;
2328+ $password = " " ;
23212329
23222330 # If --user is defined no need to ask for username
2323- if ( $opt {user } ne 0 ) {
2331+ if ( $opt {user } ) {
23242332 $name = $opt {user };
23252333 }
23262334 else {
@@ -2329,7 +2337,7 @@ sub mysql_setup {
23292337 }
23302338
23312339 # If --pass is defined no need to ask for password
2332- if ( $opt {pass } ne 0 ) {
2340+ if ( $opt {pass } ) {
23332341 $password = $opt {pass };
23342342 }
23352343 else {
@@ -4466,9 +4474,9 @@ sub get_replication_status {
44664474
44674475 $result {' Replication' }{' status' } = \%myrepl ;
44684476 my ($io_running ) = $myrepl {' Replica_IO_Running' };
4469- debugprint " IO RUNNING: $io_running " ;
4477+ debugprint " IO RUNNING: " . ( $io_running // ' undef ' ) . " " ;
44704478 my ($sql_running ) = $myrepl {' Replica_SQL_Running' };
4471- debugprint " SQL RUNNING: $sql_running " ;
4479+ debugprint " SQL RUNNING: " . ( $sql_running // ' undef ' ) . " " ;
44724480
44734481 my ($seconds_behind_replica ) = $myrepl {' Seconds_Behind_Replica' };
44744482 $seconds_behind_replica = 1000000 unless defined ($seconds_behind_replica );
@@ -5500,9 +5508,9 @@ sub mysql_stats {
55005508 subheaderprint " Performance Metrics" ;
55015509
55025510 # Show uptime, queries per second, connections, traffic stats
5503- my $qps ;
5504- if ( $mystat {' Uptime' } > 0 ) {
5505- $qps = sprintf ( " %.3f" , $mystat {' Questions' } / $mystat {' Uptime' } );
5511+ my $qps = 0 ;
5512+ if ( ( $mystat {' Uptime' } || 0 ) > 0 ) {
5513+ $qps = sprintf ( " %.3f" , ( $mystat {' Questions' } || 0 ) / $mystat {' Uptime' } );
55065514 }
55075515 push ( @generalrec ,
55085516" MySQL was started within the last 24 hours: recommendations may be inaccurate"
@@ -5595,40 +5603,40 @@ sub mysql_stats {
55955603
55965604 if ( $arch
55975605 && $arch == 32
5598- && $mycalc {' max_used_memory' } > 2 * 1024 * 1024 * 1024 )
5606+ && ( $mycalc {' max_used_memory' } || 0 ) > 2 * 1024 * 1024 * 1024 )
55995607 {
56005608 badprint
56015609 " Allocating > 2GB RAM on 32-bit systems can cause system instability" ;
56025610 badprint " Maximum reached memory usage: "
56035611 . hr_bytes( $mycalc {' max_used_memory' } )
5604- . " ($mycalc {'pct_max_used_memory'}% of installed RAM)" ;
5612+ . " (" . ( $mycalc {' pct_max_used_memory' } // 0 ) . " % of installed RAM)" ;
56055613 }
5606- elsif ( $mycalc {' pct_max_used_memory' } > 85 ) {
5614+ elsif ( ( $mycalc {' pct_max_used_memory' } || 0 ) > 85 ) {
56075615 badprint " Maximum reached memory usage: "
56085616 . hr_bytes( $mycalc {' max_used_memory' } )
5609- . " ($mycalc {'pct_max_used_memory'}% of installed RAM)" ;
5617+ . " (" . ( $mycalc {' pct_max_used_memory' } // 0 ) . " % of installed RAM)" ;
56105618 }
56115619 else {
56125620 goodprint " Maximum reached memory usage: "
56135621 . hr_bytes( $mycalc {' max_used_memory' } )
5614- . " ($mycalc {'pct_max_used_memory'}% of installed RAM)" ;
5622+ . " (" . ( $mycalc {' pct_max_used_memory' } // 0 ) . " % of installed RAM)" ;
56155623 }
56165624
5617- if ( $mycalc {' pct_max_physical_memory' } > 85 ) {
5625+ if ( ( $mycalc {' pct_max_physical_memory' } || 0 ) > 85 ) {
56185626 badprint " Maximum possible memory usage: "
56195627 . hr_bytes( $mycalc {' max_peak_memory' } )
5620- . " ($mycalc {'pct_max_physical_memory'}% of installed RAM)" ;
5628+ . " (" . ( $mycalc {' pct_max_physical_memory' } // 0 ) . " % of installed RAM)" ;
56215629 push ( @generalrec ,
56225630 " Reduce your overall MySQL memory footprint for system stability" );
56235631 }
56245632 else {
56255633 goodprint " Maximum possible memory usage: "
56265634 . hr_bytes( $mycalc {' max_peak_memory' } )
5627- . " ($mycalc {'pct_max_physical_memory'}% of installed RAM)" ;
5635+ . " (" . ( $mycalc {' pct_max_physical_memory' } // 0 ) . " % of installed RAM)" ;
56285636 }
56295637
5630- if ( $physical_memory <
5631- ( $mycalc {' max_peak_memory' } + get_other_process_memory() ) )
5638+ if ( ( $physical_memory || 0 ) <
5639+ ( ( $mycalc {' max_peak_memory' } || 0 ) + get_other_process_memory() ) )
56325640 {
56335641 if ( $opt {nondedicated } ) {
56345642 infoprint " No warning with --nondedicated option" ;
@@ -5649,13 +5657,15 @@ sub mysql_stats {
56495657 }
56505658
56515659 # Slow queries
5652- if ( $mycalc {' pct_slow_queries' } > 5 ) {
5653- badprint " Slow queries: $mycalc {'pct_slow_queries'}% ("
5660+ if ( ( $mycalc {' pct_slow_queries' } || 0 ) > 5 ) {
5661+ badprint " Slow queries: "
5662+ . ( $mycalc {' pct_slow_queries' } // 0 ) . " % ("
56545663 . hr_num( $mystat {' Slow_queries' } ) . " /"
56555664 . hr_num( $mystat {' Questions' } ) . " )" ;
56565665 }
56575666 else {
5658- goodprint " Slow queries: $mycalc {'pct_slow_queries'}% ("
5667+ goodprint " Slow queries: "
5668+ . ( $mycalc {' pct_slow_queries' } // 0 ) . " % ("
56595669 . hr_num( $mystat {' Slow_queries' } ) . " /"
56605670 . hr_num( $mystat {' Questions' } ) . " )" ;
56615671 }
@@ -5670,33 +5680,33 @@ sub mysql_stats {
56705680 }
56715681
56725682 # Connections
5673- if ( $mycalc {' pct_connections_used' } > 85 ) {
5683+ if ( ( $mycalc {' pct_connections_used' } || 0 ) > 85 ) {
56745684 badprint
5675- " Highest connection usage: $mycalc {'pct_connections_used'}% ($mystat {'Max_used_connections'}/ $myvar {'max_connections'})" ;
5685+ " Highest connection usage: " . ( $mycalc {' pct_connections_used' } // 0 ) . " % (" . ( $mystat {' Max_used_connections' } // 0 ) . " / " . ( $myvar {' max_connections' } // 0 ) . " )" ;
56765686 push ( @adjvars ,
5677- " max_connections (> " . $myvar {' max_connections' } . " )" );
5687+ " max_connections (> " . ( $myvar {' max_connections' } // 0 ) . " )" );
56785688 push ( @adjvars ,
5679- " wait_timeout (< " . $myvar {' wait_timeout' } . " )" ,
5680- " interactive_timeout (< " . $myvar {' interactive_timeout' } . " )" );
5689+ " wait_timeout (< " . ( $myvar {' wait_timeout' } // 0 ) . " )" ,
5690+ " interactive_timeout (< " . ( $myvar {' interactive_timeout' } // 0 ) . " )" );
56815691 push ( @generalrec ,
56825692" Reduce or eliminate persistent connections to reduce connection usage"
56835693 );
56845694 }
56855695 else {
56865696 goodprint
5687- " Highest usage of available connections: $mycalc {'pct_connections_used'}% ($mystat {'Max_used_connections'}/ $myvar {'max_connections'})" ;
5697+ " Highest usage of available connections: " . ( $mycalc {' pct_connections_used' } // 0 ) . " % (" . ( $mystat {' Max_used_connections' } // 0 ) . " / " . ( $myvar {' max_connections' } // 0 ) . " )" ;
56885698 }
56895699
56905700 # Aborted Connections
5691- if ( $mycalc {' pct_connections_aborted' } > 3 ) {
5701+ if ( ( $mycalc {' pct_connections_aborted' } || 0 ) > 3 ) {
56925702 badprint
5693- " Aborted connections: $mycalc {'pct_connections_aborted'}% ($mystat {'Aborted_connects'}/ $mystat {'Connections'})" ;
5703+ " Aborted connections: " . ( $mycalc {' pct_connections_aborted' } // 0 ) . " % (" . ( $mystat {' Aborted_connects' } // 0 ) . " / " . ( $mystat {' Connections' } // 0 ) . " )" ;
56945704 push ( @generalrec ,
56955705 " Reduce or eliminate unclosed connections and network issues" );
56965706 }
56975707 else {
56985708 goodprint
5699- " Aborted connections: $mycalc {'pct_connections_aborted'}% ($mystat {'Aborted_connects'}/ $mystat {'Connections'})" ;
5709+ " Aborted connections: " . ( $mycalc {' pct_connections_aborted' } // 0 ) . " % (" . ( $mystat {' Aborted_connects' } // 0 ) . " / " . ( $mystat {' Connections' } // 0 ) . " )" ;
57005710 }
57015711
57025712 # name resolution
@@ -9082,7 +9092,7 @@ sub mysql_innodb {
90829092 }
90839093
90849094 # InnoDB Buffer Pool Size
9085- if ( $myvar {' innodb_file_per_table' } eq " ON" ) {
9095+ if ( ( $myvar {' innodb_file_per_table' } // ' ' ) eq " ON" ) {
90869096 goodprint " InnoDB File per table is activated" ;
90879097 }
90889098 else {
@@ -9091,7 +9101,9 @@ sub mysql_innodb {
90919101 }
90929102
90939103 # InnoDB Buffer Pool Size
9094- if ( $arch == 32 && $myvar {' innodb_buffer_pool_size' } > 4294967295 ) {
9104+ if ( ( $arch // 0 ) == 32
9105+ && ( $myvar {' innodb_buffer_pool_size' } // 0 ) > 4294967295 )
9106+ {
90959107 badprint
90969108 " InnoDB Buffer Pool size limit reached for 32 bits architecture: ("
90979109 . hr_bytes(4294967295) . " )" ;
@@ -9100,14 +9112,16 @@ sub mysql_innodb {
91009112 . hr_bytes(4294967295)
91019113 . " for 32 bits architecture" );
91029114 }
9103- if ( $arch == 32 && $myvar {' innodb_buffer_pool_size' } < 4294967295 ) {
9115+ if ( ( $arch // 0 ) == 32
9116+ && ( $myvar {' innodb_buffer_pool_size' } // 0 ) < 4294967295 )
9117+ {
91049118 goodprint " InnoDB Buffer Pool size ( "
91059119 . hr_bytes( $myvar {' innodb_buffer_pool_size' } )
91069120 . " ) under limit for 32 bits architecture: ("
91079121 . hr_bytes(4294967295) . " )" ;
91089122 }
9109- if ( $arch == 64
9110- && $myvar {' innodb_buffer_pool_size' } > 18446744073709551615 )
9123+ if ( ( $arch // 0 ) == 64
9124+ && ( $myvar {' innodb_buffer_pool_size' } // 0 ) > 18446744073709551615 )
91119125 {
91129126 badprint " InnoDB Buffer Pool size limit("
91139127 . hr_bytes(18446744073709551615)
@@ -9118,15 +9132,17 @@ sub mysql_innodb {
91189132 . " for 64 bits architecture" );
91199133 }
91209134
9121- if ( $arch == 64
9122- && $myvar {' innodb_buffer_pool_size' } < 18446744073709551615 )
9135+ if ( ( $arch // 0 ) == 64
9136+ && ( $myvar {' innodb_buffer_pool_size' } // 0 ) < 18446744073709551615 )
91239137 {
91249138 goodprint " InnoDB Buffer Pool size ( "
91259139 . hr_bytes( $myvar {' innodb_buffer_pool_size' } )
91269140 . " ) under limit for 64 bits architecture: ("
91279141 . hr_bytes(18446744073709551615) . " )" ;
91289142 }
9129- if ( $myvar {' innodb_buffer_pool_size' } > $enginestats {' InnoDB' } ) {
9143+ if ( ( $myvar {' innodb_buffer_pool_size' } // 0 ) >
9144+ ( $enginestats {' InnoDB' } // 0 ) )
9145+ {
91309146 goodprint " InnoDB buffer pool / data size: "
91319147 . hr_bytes( $myvar {' innodb_buffer_pool_size' } ) . " / "
91329148 . hr_bytes( $enginestats {' InnoDB' } ) . " " ;
@@ -10926,7 +10942,7 @@ sub get_template_model {
1092610942sub dump_result {
1092710943
1092810944 # debugprint Dumper( \%result ) if ( $opt{'debug'} );
10929- debugprint " HTML REPORT: $opt {'reportfile'}" ;
10945+ debugprint " HTML REPORT: " . ( $opt {' reportfile' } // ' undef ' ) ;
1093010946
1093110947 if ( $opt {' reportfile' } ) {
1093210948 eval { require Text::Template };
@@ -11322,18 +11338,26 @@ =head1 CONTRIBUTORS
1132211338
1132311339=item *
1132411340
11325- Major Hayden
11341+ Daniel Lewart
1132611342
1132711343=item *
1132811344
11329- Joe Ashcraft
11345+ Jason Gill
1133011346
1133111347=item *
1133211348
1133311349Jean-Marie Renouard
1133411350
1133511351=item *
1133611352
11353+ Major Hayden
11354+
11355+ =item *
11356+
11357+ Matthew Montgomery
11358+
11359+ =item *
11360+
1133711361Stephan GroBberndt
1133811362
1133911363=item *
@@ -11397,3 +11421,8 @@ =head1 COPYRIGHT AND LICENSE
1139711421
1139811422nd:
1139911423
11424+ ndent-level: 8
11425+ # End:
11426+
11427+ nd:
11428+
0 commit comments