Lines 153-159
Link Here
|
153 |
"idle|i" => \$config{idle}, |
153 |
"idle|i" => \$config{idle}, |
154 |
"resolve|r" => \$config{resolve}, |
154 |
"resolve|r" => \$config{resolve}, |
155 |
"prompt!" => \$config{prompt}, |
155 |
"prompt!" => \$config{prompt}, |
156 |
"long|!" => \$config{long_nums}, |
156 |
"long!" => \$config{long_nums}, |
157 |
"mode|m=s" => \$config{mode}, |
157 |
"mode|m=s" => \$config{mode}, |
158 |
"sort=s" => \$config{sort}, |
158 |
"sort=s" => \$config{sort}, |
159 |
); |
159 |
); |
Lines 193-198
Link Here
|
193 |
*BLUE = sub { }; |
193 |
*BLUE = sub { }; |
194 |
*WHITE = sub { }; |
194 |
*WHITE = sub { }; |
195 |
*BOLD = sub { }; |
195 |
*BOLD = sub { }; |
|
|
196 |
*MAGENTA = sub { }; |
196 |
} |
197 |
} |
197 |
|
198 |
|
198 |
my $RESET = RESET() || ''; |
199 |
my $RESET = RESET() || ''; |
Lines 202-207
Link Here
|
202 |
my $BLUE = BLUE() || ''; |
203 |
my $BLUE = BLUE() || ''; |
203 |
my $WHITE = WHITE() || ''; |
204 |
my $WHITE = WHITE() || ''; |
204 |
my $BOLD = BOLD() || ''; |
205 |
my $BOLD = BOLD() || ''; |
|
|
206 |
my $MAGENTA= MAGENTA() || ''; |
205 |
|
207 |
|
206 |
## Connect |
208 |
## Connect |
207 |
|
209 |
|
Lines 369-374
Link Here
|
369 |
require Data::Dumper; |
371 |
require Data::Dumper; |
370 |
print Data::Dumper::Dumper([\%config]); |
372 |
print Data::Dumper::Dumper([\%config]); |
371 |
ReadKey(0); |
373 |
ReadKey(0); |
|
|
374 |
|
375 |
if (-M $0) { # restart application, if it was modified - for debugging |
376 |
exec('perl', $0, @ARGV); |
377 |
} |
372 |
} |
378 |
} |
373 |
|
379 |
|
374 |
## m - mode swtich to qps |
380 |
## m - mode swtich to qps |
Lines 377-383
Link Here
|
377 |
{ |
383 |
{ |
378 |
$config{mode} = 'qps'; |
384 |
$config{mode} = 'qps'; |
379 |
Clear() unless $config{batchmode}; |
385 |
Clear() unless $config{batchmode}; |
380 |
print "Queries Per Second [hit q to exit this mode]\n"; |
386 |
print "Queries Per Second [hit q to exit, hit t for top mode]\n"; |
381 |
next; |
387 |
next; |
382 |
} |
388 |
} |
383 |
|
389 |
|
Lines 710-716
Link Here
|
710 |
## |
716 |
## |
711 |
if ($config{header}) |
717 |
if ($config{header}) |
712 |
{ |
718 |
{ |
713 |
my @recs = Hashes("show status"); |
719 |
my @recs = Hashes("SHOW /*!50002 GLOBAL */ STATUS"); |
714 |
|
720 |
|
715 |
## if the server died or we lost connectivity |
721 |
## if the server died or we lost connectivity |
716 |
if (not @recs) |
722 |
if (not @recs) |
Lines 819-825
Link Here
|
819 |
$lines_left--; |
825 |
$lines_left--; |
820 |
|
826 |
|
821 |
|
827 |
|
822 |
printf " Queries: %-5s qps: %4.0f Slow: %7s Se/In/Up/De(%%): %02.0f/%02.0f/%02.0f/%02.0f \n", |
828 |
printf " Queries: %-6s qps: %4.0f Slow: %7s Se/In/Up/De(%%): %02.0f/%02.0f/%02.0f/%02.0f \n", |
823 |
make_short( $STATUS{Questions} ), # q total |
829 |
make_short( $STATUS{Questions} ), # q total |
824 |
$STATUS{Questions} / $STATUS{Uptime}, # qps, average |
830 |
$STATUS{Questions} / $STATUS{Uptime}, # qps, average |
825 |
make_short( $STATUS{Slow_queries} ), # slow |
831 |
make_short( $STATUS{Slow_queries} ), # slow |
Lines 889-896
Link Here
|
889 |
make_short(($STATUS{Bytes_received} - $OLD_STATUS{Bytes_received}) / $t_delta ), |
895 |
make_short(($STATUS{Bytes_received} - $OLD_STATUS{Bytes_received}) / $t_delta ), |
890 |
make_short(($STATUS{Bytes_sent} - $OLD_STATUS{Bytes_sent}) / $t_delta )) |
896 |
make_short(($STATUS{Bytes_sent} - $OLD_STATUS{Bytes_sent}) / $t_delta )) |
891 |
if ($t_delta); |
897 |
if ($t_delta); |
892 |
print "\n\n"; |
898 |
print "\n"; |
|
|
899 |
|
900 |
my @master_status = Hashes("show master status"); |
901 |
if (@master_status) |
902 |
{ |
903 |
foreach my $m (@master_status) { |
904 |
print " Master: $m->{File}/$m->{Position} ", |
905 |
"do: ", GREEN(), "$m->{Binlog_Do_DB} ", RESET(), |
906 |
"ign: ", MAGENTA(), $m->{Binlog_Ignore_DB}, RESET(), "\n"; |
907 |
#$line_prefix = ' ' x length($line_prefix); |
908 |
$lines_left--; |
909 |
} |
910 |
} |
911 |
|
912 |
my @slave_status = Hashes("show slave status"); |
913 |
if (@slave_status) |
914 |
{ |
915 |
my $line_prefix = " Slave: "; |
916 |
foreach my $s (@slave_status) { |
917 |
print $line_prefix, BOLD(), |
918 |
($s->{Slave_IO_Running} eq 'Yes' |
919 |
&& $s->{Slave_SQL_Running} eq 'Yes' |
920 |
&& $s->{Last_Errno} == 0 |
921 |
? ($s->{Seconds_Behind_Master} > 60 ? BOLD('WARN') : GREEN('OK ')) : RED('ERR ') |
922 |
), RESET(), |
923 |
" Delay: ", |
924 |
defined($s->{Seconds_Behind_Master}) ? sprintf('%03d:%02d', int($s->{Seconds_Behind_Master} / 60), $s->{Seconds_Behind_Master} % 60) : '---:--', |
925 |
" $s->{Master_User}\@$s->{Master_Host}: ", |
926 |
"$s->{Master_Log_File}/$s->{Read_Master_Log_Pos} ", |
927 |
"\n"; |
928 |
#$line_prefix = ' ' x length($line_prefix); |
929 |
$lines_left--; |
930 |
} |
931 |
} |
893 |
|
932 |
|
|
|
933 |
print "\n"; |
894 |
$lines_left--; |
934 |
$lines_left--; |
895 |
} |
935 |
} |
896 |
|
936 |
|
Lines 952-959
Link Here
|
952 |
{ |
992 |
{ |
953 |
$thread->{Host} =~ s/:\d+$//; |
993 |
$thread->{Host} =~ s/:\d+$//; |
954 |
my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET); |
994 |
my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET); |
955 |
$host =~ s/^([^.]+).*/$1/; |
995 |
if ($host) |
956 |
$thread->{Host} = $host; |
996 |
{ |
|
|
997 |
$host =~ s/^([^.]+).*/$1/; |
998 |
$thread->{Host} = $host; |
999 |
} |
957 |
} |
1000 |
} |
958 |
|
1001 |
|
959 |
## Fix possible undefs |
1002 |
## Fix possible undefs |
Lines 1099-1106
Link Here
|
1099 |
my @data = Hashes("SHOW INNODB STATUS"); |
1142 |
my @data = Hashes("SHOW INNODB STATUS"); |
1100 |
|
1143 |
|
1101 |
open P, "|$config{pager}" or die "$!"; |
1144 |
open P, "|$config{pager}" or die "$!"; |
1102 |
print keys %{$data[0]}; |
1145 |
print P keys %{$data[0]}; |
1103 |
print $data[0]->{Status},"\n"; |
1146 |
print P $data[0]->{Status},"\n"; |
1104 |
close P; |
1147 |
close P; |
1105 |
} |
1148 |
} |