Update to 1.7

- MASTER_SITE switch to GitHub
 - Add LICENSE (GPLv2)
 - Use PLIST_FILES and delete pkg-plist

PR:		195428
Submitted by:	spil.oss@gmail.com
This commit is contained in:
Matthew Seaman 2014-12-06 17:13:15 +00:00
parent 6ac24c08b5
commit c59e25d4cb
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=374121
4 changed files with 122 additions and 90 deletions

View file

@ -2,22 +2,31 @@
# $FreeBSD$ # $FreeBSD$
PORTNAME= mytop PORTNAME= mytop
PORTVERSION= 1.6 PORTVERSION= 1.7
PORTREVISION= 12
CATEGORIES= databases CATEGORIES= databases
MASTER_SITES= http://jeremy.zawodny.com/mysql/mytop/
MAINTAINER= matthew@FreeBSD.org MAINTAINER= matthew@FreeBSD.org
COMMENT= Top clone for MySQL COMMENT= Top clone for MySQL
LICENSE= GPLv2
RUN_DEPENDS= p5-DBD-mysql>1.0:${PORTSDIR}/databases/p5-DBD-mysql \ RUN_DEPENDS= p5-DBD-mysql>1.0:${PORTSDIR}/databases/p5-DBD-mysql \
p5-DBI>=1.13:${PORTSDIR}/databases/p5-DBI \ p5-DBI>=1.13:${PORTSDIR}/databases/p5-DBI \
p5-Term-ReadKey>=2.10:${PORTSDIR}/devel/p5-Term-ReadKey p5-Term-ReadKey>=2.10:${PORTSDIR}/devel/p5-Term-ReadKey
USE_GITHUB= yes
GH_ACCOUNT= jzawodn
GH_PROJECT= mytop
GH_COMMIT= 437f2ef
GH_TAGNAME= ${GH_COMMIT}
NO_ARCH= yes NO_ARCH= yes
CONFLICTS= mariadb-scripts-[0-9]* CONFLICTS= mariadb-scripts-[0-9]*
USES+= perl5 USES+= perl5
USE_PERL5= configure USE_PERL5= configure
PLIST_FILES= bin/mytop \
man/man1/mytop.1.gz
.include <bsd.port.mk> .include <bsd.port.mk>

View file

@ -1,2 +1,2 @@
SHA256 (mytop-1.6.tar.gz) = b17c702598b10bb0ce2695f609122637c799eaaaec1afaa73246b048f07be9bd SHA256 (mytop-1.7.tar.gz) = 8471c35926b07a7a6de653b1825321bba7c36c3c7992075c908ef6bb3a844fbb
SIZE (mytop-1.6.tar.gz) = 19720 SIZE (mytop-1.7.tar.gz) = 20637

View file

@ -1,45 +1,56 @@
--- mytop.orig 2013-03-21 21:26:04 UTC
$FreeBSD$
--- mytop.orig
+++ mytop +++ mytop
@@ -153,7 +153,7 @@ @@ -189,22 +189,24 @@ if ($HAS_COLOR)
"idle|i" => \$config{idle}, }
"resolve|r" => \$config{resolve}, else
"prompt!" => \$config{prompt}, {
- "long|!" => \$config{long_nums}, - *RESET = sub { };
+ "long!" => \$config{long_nums}, - *YELLOW = sub { };
"mode|m=s" => \$config{mode}, - *RED = sub { };
"sort=s" => \$config{sort}, - *GREEN = sub { };
); - *BLUE = sub { };
@@ -193,6 +193,7 @@ - *WHITE = sub { };
*BLUE = sub { }; - *BOLD = sub { };
*WHITE = sub { }; + *RESET = sub { };
*BOLD = sub { }; + *YELLOW = sub { };
+ *RED = sub { };
+ *GREEN = sub { };
+ *BLUE = sub { };
+ *WHITE = sub { };
+ *BOLD = sub { };
+ *MAGENTA = sub { }; + *MAGENTA = sub { };
} }
my $RESET = RESET() || ''; -my $RESET = RESET() || '';
@@ -202,6 +203,7 @@ -my $YELLOW = YELLOW() || '';
my $BLUE = BLUE() || ''; -my $RED = RED() || '';
my $WHITE = WHITE() || ''; -my $GREEN = GREEN() || '';
my $BOLD = BOLD() || ''; -my $BLUE = BLUE() || '';
+my $MAGENTA= MAGENTA() || ''; -my $WHITE = WHITE() || '';
-my $BOLD = BOLD() || '';
+my $RESET = RESET() || '';
+my $YELLOW = YELLOW() || '';
+my $RED = RED() || '';
+my $GREEN = GREEN() || '';
+my $BLUE = BLUE() || '';
+my $WHITE = WHITE() || '';
+my $BOLD = BOLD() || '';
+my $MAGENTA = MAGENTA() || '';
## Connect ## Connect
@@ -369,6 +371,10 @@ @@ -372,6 +374,10 @@ while (1)
require Data::Dumper; require Data::Dumper;
print Data::Dumper::Dumper([\%config]); print Data::Dumper::Dumper([\%config]);
ReadKey(0); ReadKey(0);
+ +
+ if (-M $0) { # restart application, if it was modified - for debugging + if (-M $0) { # Restart application, if modified (for debugging)
+ exec('perl', $0, @ARGV); + exec('perl', $0, @ARGV);
+ } + }
} }
## m - mode swtich to qps ## m - mode swtich to qps
@@ -377,7 +383,7 @@ @@ -380,7 +386,7 @@ while (1)
{ {
$config{mode} = 'qps'; $config{mode} = 'qps';
Clear() unless $config{batchmode}; Clear() unless $config{batchmode};
@ -48,16 +59,7 @@ $FreeBSD$
next; next;
} }
@@ -710,7 +716,7 @@ @@ -803,8 +809,15 @@ sub GetData()
##
if ($config{header})
{
- my @recs = Hashes("show status");
+ my @recs = Hashes("SHOW /*!50002 GLOBAL */ STATUS");
## if the server died or we lost connectivity
if (not @recs)
@@ -800,8 +806,15 @@
## Queries per second... ## Queries per second...
@ -75,7 +77,7 @@ $FreeBSD$
my @t = localtime(time); my @t = localtime(time);
@@ -819,26 +832,26 @@ @@ -822,26 +835,26 @@ sub GetData()
$lines_left--; $lines_left--;
@ -112,56 +114,79 @@ $FreeBSD$
( # slow now (qps) ( # slow now (qps)
($STATUS{Slow_queries} ) ? ($STATUS{Slow_queries} ) ?
( $STATUS{Slow_queries} - $OLD_STATUS{Slow_queries} ) / $t_delta : ( $STATUS{Slow_queries} - $OLD_STATUS{Slow_queries} ) / $t_delta :
@@ -889,8 +902,42 @@ @@ -851,7 +864,7 @@ sub GetData()
$STATUS{Threads_running},
$STATUS{Threads_cached},
- (100 * ($STATUS{Com_select} - $OLD_STATUS{Com_select} +
+ (100 * ($STATUS{Com_select} - $OLD_STATUS{Com_select} +
($STATUS{Qcache_hits}||0) - ($OLD_STATUS{Qcache_hits}||0)
) ) / ($q_diff ),
(100 * ($STATUS{Com_insert} - $OLD_STATUS{Com_insert} +
@@ -869,11 +882,11 @@ sub GetData()
if ($have_query_cache and $STATUS{Com_select} and $query_cache_hits)
{
- printf(" Cache Hits: %-5s Hits/s: %4.1f Hits now: %5.1f Ratio: %4.1f%% Ratio now: %4.1f%% \n",
+ printf(" Cache Hits: %-5s Hits/s: %4.1f Hits now: %5.1f Ratio: %4.1f%% Ratio now: %4.1f%% \n",
make_short($STATUS{Qcache_hits}), # cache hits
$STATUS{Qcache_hits} / $STATUS{Uptime}, # hits / sec
($t_delta) ? ($STATUS{Qcache_hits} - $OLD_STATUS{Qcache_hits}) / $t_delta : 0, # now / s
- # ratio:
+ # ratio:
100 * ($STATUS{Qcache_hits}) / ($STATUS{Qcache_hits} + $STATUS{Com_select} ),
($t_delta) ? # ratio now
100 * ($STATUS{Qcache_hits} - $OLD_STATUS{Qcache_hits} ) /
@@ -892,7 +905,42 @@ sub GetData()
make_short(($STATUS{Bytes_received} - $OLD_STATUS{Bytes_received}) / $t_delta ), make_short(($STATUS{Bytes_received} - $OLD_STATUS{Bytes_received}) / $t_delta ),
make_short(($STATUS{Bytes_sent} - $OLD_STATUS{Bytes_sent}) / $t_delta )) make_short(($STATUS{Bytes_sent} - $OLD_STATUS{Bytes_sent}) / $t_delta ))
if ($t_delta); if ($t_delta);
- print "\n\n"; - print "\n\n";
+ print "\n"; + print "\n";
+
+ my @master_status = Hashes("show master status"); + my @master_status = Hashes("show master status");
+ if (@master_status) + if (@master_status)
+ { + {
+ foreach my $m (@master_status) { + foreach my $m (@master_status) {
+ print " Master: $m->{File}/$m->{Position} ", + print " Master: $m->{File}/$m->{Position} ",
+ "do: ", GREEN(), "$m->{Binlog_Do_DB} ", RESET(), + "do: ", GREEN(), "$m->{Binlog_Do_DB} ", RESET(),
+ "ign: ", MAGENTA(), $m->{Binlog_Ignore_DB}, RESET(), "\n"; + "ign: ", MAGENTA(), $m->{Binlog_Ignore_DB}, RESET(), "\n";
+ #$line_prefix = ' ' x length($line_prefix); + #$line_prefix = ' ' x length($line_prefix);
+ $lines_left--; + $lines_left--;
+ } + }
+ } + }
+ +
+ my @slave_status = Hashes("show slave status"); + my @slave_status = Hashes("show slave status");
+ if (@slave_status) + if (@slave_status)
+ { + {
+ my $line_prefix = " Slave: "; + my $line_prefix = " Slave: ";
+ foreach my $s (@slave_status) { + foreach my $s (@slave_status) {
+ print $line_prefix, BOLD(), + print $line_prefix, BOLD(),
+ ($s->{Slave_IO_Running} eq 'Yes' + ($s->{Slave_IO_Running} eq 'Yes'
+ && $s->{Slave_SQL_Running} eq 'Yes' + && $s->{Slave_SQL_Running} eq 'Yes'
+ && $s->{Last_Errno} == 0 + && $s->{Last_Errno} == 0
+ ? ($s->{Seconds_Behind_Master} > 60 ? BOLD('WARN') : GREEN('OK ')) : RED('ERR ') + ? ($s->{Seconds_Behind_Master} > 60 ? BOLD('WARN') : GREEN('OK ')) : RED('ERR ')
+ ), RESET(), + ), RESET(),
+ " Delay: ", + " Delay: ",
+ defined($s->{Seconds_Behind_Master}) ? sprintf('%03d:%02d', int($s->{Seconds_Behind_Master} / 60), $s->{Seconds_Behind_Master} % 60) : '---:--', + defined($s->{Seconds_Behind_Master}) ? sprintf('%03d:%02d', int($s->{Seconds_Behind_Master} / 60), $s->{Seconds_Behind_Master} % 60) : '---:--',
+ " $s->{Master_User}\@$s->{Master_Host}: ", + " $s->{Master_User}\@$s->{Master_Host}: ",
+ "$s->{Master_Log_File}/$s->{Read_Master_Log_Pos} ", + "$s->{Master_Log_File}/$s->{Read_Master_Log_Pos} ",
+ "\n"; + "\n";
+ #$line_prefix = ' ' x length($line_prefix); + #$line_prefix = ' ' x length($line_prefix);
+ $lines_left--; + $lines_left--;
+ } + }
+ } + }
+ +
+ print "\n"; + print "\n";
$lines_left--; $lines_left--;
} }
@@ -907,32 +955,22 @@ sub GetData()
@@ -904,32 +951,22 @@
## Threads ## Threads
## ##
- #my $sz = $width - 52; - #my $sz = $width - 52;
- my @sz = (8, 9, 15, 10, 9, 6); - my @sz = (9, 9, 15, 10, 9, 6);
- my $used = scalar(@sz) + Sum(@sz); - my $used = scalar(@sz) + Sum(@sz);
- my $free = $width - $used; - my $free = $width - $used;
- -
@ -173,7 +198,7 @@ $FreeBSD$
- print RESET(); - print RESET();
- -
- ## Id User Host DB - ## Id User Host DB
- printf "%8s %9s %15s %10s %9s %6s %-${free}s\n", - printf "%9s %9s %15s %10s %9s %6s %-${free}s\n",
- '--','----','-------','--','----', '---', '----------'; - '--','----','-------','--','----', '---', '----------';
- -
$lines_left -= 2; $lines_left -= 2;
@ -188,28 +213,28 @@ $FreeBSD$
{ {
last if not $lines_left; last if not $lines_left;
+ if ($max_id < $thread->{Id}) { + if ($max_id < $thread->{Id}) {
+ $max_id = $thread->{Id}; + $max_id = $thread->{Id};
+ } + }
+ +
## Drop Domain Name, unless it looks like an IP address. If ## Drop Domain Name, unless it looks like an IP address. If
## it's an IP, we'll strip the port number because it's rarely ## it's an IP, we'll strip the port number because it's rarely
## interesting. ## interesting.
@@ -952,8 +989,11 @@ @@ -955,8 +993,11 @@ sub GetData()
{ {
$thread->{Host} =~ s/:\d+$//; $thread->{Host} =~ s/:\d+$//;
my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET); my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET);
- $host =~ s/^([^.]+).*/$1/; - $host =~ s/^([^.]+).*/$1/;
- $thread->{Host} = $host; - $thread->{Host} = $host;
+ if ($host) + if ($host)
+ { + {
+ $host =~ s/^([^.]+).*/$1/; + $host =~ s/^([^.]+).*/$1/;
+ $thread->{Host} = $host; + $thread->{Host} = $host;
+ } + }
} }
## Fix possible undefs ## Fix possible undefs
@@ -990,6 +1030,23 @@ @@ -993,6 +1034,23 @@ sub GetData()
} }
@ -233,16 +258,16 @@ $FreeBSD$
## Sort by idle time (closest thing to CPU usage I can think of). ## Sort by idle time (closest thing to CPU usage I can think of).
my @sorted; my @sorted;
@@ -1044,7 +1101,7 @@ @@ -1047,7 +1105,7 @@ sub GetData()
print GREEN() if $thread->{Command} eq 'Connect'; print GREEN() if $thread->{Command} eq 'Connect';
} }
- printf "%8d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s\n", - printf "%9d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s\n",
+ printf "%${max_id_size}d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s\n", + printf "%${max_id_size}d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s\n",
$thread->{Id}, $thread->{User}, $thread->{Host}, $thread->{db}, $thread->{Id}, $thread->{User}, $thread->{Host}, $thread->{db},
$thread->{Time}, $thread->{Command}, $smInfo; $thread->{Time}, $thread->{Command}, $smInfo;
@@ -1099,8 +1156,8 @@ @@ -1102,8 +1160,8 @@ sub GetInnoDBStatus()
my @data = Hashes("SHOW INNODB STATUS"); my @data = Hashes("SHOW INNODB STATUS");
open P, "|$config{pager}" or die "$!"; open P, "|$config{pager}" or die "$!";

View file

@ -1,2 +0,0 @@
bin/mytop
man/man1/mytop.1.gz