From 33928700a3b73d63d92d3bfaa1bd1483ed36ae6a Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Tue, 6 Nov 2007 23:20:09 +0000 Subject: [PATCH] * Added NetBSD support (thanks to Dave Burgess) * Switched username/password prompts to STDERR so they won't appear in printouts --- mysqltuner.pl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index a070732..fbe9fcc 100644 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -6,7 +6,8 @@ # http://forge.mysql.com/projects/view.php?id=44 # # Other Contributors: -# Paul Kehrer +# Paul Kehrer +# Dave Burgess # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -103,7 +104,10 @@ sub os_setup { $duflags = '-b'; } elsif ($os =~ /Darwin/) { $physical_memory = `sysctl -n hw.memsize`; - $swap_memory = `sysctl -n vm.swapusage | awk '{print \$3}' | sed 's/\..*\$//'`; + $swap_memory = `sysctl -n vm.swapusage | awk '{print \$3}' | sed 's/\..*\$//'`; + } elsif ($os =~ /NetBSD/) { + $physical_memory = `sysctl -n hw.physmem`; + $swap_memory = `swapctl -l | grep '^/' | awk '{ s+= \$2 } END { print s }'`; } elsif ($os =~ /BSD/) { $physical_memory = `sysctl -n hw.realmem`; $swap_memory = `swapinfo | grep '^/' | awk '{ s+= \$2 } END { print s }'`; @@ -146,19 +150,19 @@ sub mysql_setup { } return 1; } else { - print "Please enter your MySQL login: "; + print STDERR "Please enter your MySQL login: "; my $name = <>; - print "Please enter your MySQL password: "; - system("stty -echo"); #don't show the password + print STDERR "Please enter your MySQL password: "; + system("stty -echo"); my $password = <>; - system("stty echo"); #plz give echo back + system("stty echo"); chomp($password); chomp($name); $mysqllogin = "-u $name -p'$password'"; my $loginstatus = `mysqladmin ping $mysqllogin 2>&1`; if ($loginstatus =~ /mysqld is alive/) { # Login was successful, but we won't say anything to save space - print "\n"; + print STDERR "\n"; return 1; } else { print "\n".$bad." Attempted to use login credentials, but they were invalid.\n";