aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew@FreeBSD.org>2013-01-23 06:17:27 +0800
committermatthew <matthew@FreeBSD.org>2013-01-23 06:17:27 +0800
commitba0f5dc623058967ddcdd07bd4c24fa1b890f791 (patch)
tree8abf0b511d497fbe1f820c0baf28c8fbec24c8e6
parenteeec38fcd02a5275681458871a0d49a50aa39b57 (diff)
downloadfreebsd-ports-gnome-ba0f5dc623058967ddcdd07bd4c24fa1b890f791.tar.gz
freebsd-ports-gnome-ba0f5dc623058967ddcdd07bd4c24fa1b890f791.tar.zst
freebsd-ports-gnome-ba0f5dc623058967ddcdd07bd4c24fa1b890f791.zip
Make the width if the Id field dynamic.
PR: ports/175476 Submitted by: ccn <ccn@ccn.tw>
-rw-r--r--databases/mytop/Makefile2
-rw-r--r--databases/mytop/files/patch-mytop84
2 files changed, 63 insertions, 23 deletions
diff --git a/databases/mytop/Makefile b/databases/mytop/Makefile
index f16e88af986e..09cf372acca3 100644
--- a/databases/mytop/Makefile
+++ b/databases/mytop/Makefile
@@ -3,7 +3,7 @@
PORTNAME= mytop
PORTVERSION= 1.6
-PORTREVISION= 9
+PORTREVISION= 10
CATEGORIES= databases
MASTER_SITES= http://jeremy.zawodny.com/mysql/mytop/
diff --git a/databases/mytop/files/patch-mytop b/databases/mytop/files/patch-mytop
index efe59ccbc660..d0d390790ff1 100644
--- a/databases/mytop/files/patch-mytop
+++ b/databases/mytop/files/patch-mytop
@@ -118,7 +118,7 @@ $FreeBSD$
if ($t_delta);
- print "\n\n";
+ print "\n";
-+
+
+ my @master_status = Hashes("show master status");
+ if (@master_status)
+ {
@@ -130,7 +130,7 @@ $FreeBSD$
+ $lines_left--;
+ }
+ }
-
++
+ my @slave_status = Hashes("show slave status");
+ if (@slave_status)
+ {
@@ -156,30 +156,46 @@ $FreeBSD$
$lines_left--;
}
-@@ -905,19 +952,19 @@
+@@ -904,32 +951,22 @@
+ ## 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 $free = $width - $used;
-
- print BOLD();
-
+- my $used = scalar(@sz) + Sum(@sz);
+- my $free = $width - $used;
+-
+- print BOLD();
+-
- printf "%8s %9s %15s %10s %9s %6s %-${free}s\n",
-+ printf "%9s %9s %15s %10s %9s %6s %-${free}s\n",
- 'Id','User','Host/IP','DB','Time', 'Cmd', 'Query or State';
+- 'Id','User','Host/IP','DB','Time', 'Cmd', 'Query or State';
+-
+- print RESET();
+-
+- ## Id User Host DB
+- printf "%8s %9s %15s %10s %9s %6s %-${free}s\n",
+- '--','----','-------','--','----', '---', '----------';
+-
+ $lines_left -= 2;
- print RESET();
+ my $proc_cmd = "show full processlist";
- ## Id User Host DB
-- printf "%8s %9s %15s %10s %9s %6s %-${free}s\n",
-+ printf "%9s %9s %15s %10s %9s %6s %-${free}s\n",
- '--','----','-------','--','----', '---', '----------';
+ my @data = Hashes($proc_cmd);
- $lines_left -= 2;
-@@ -952,8 +999,11 @@
++ my $max_id = 0;
++
+ foreach my $thread (@data)
+ {
+ last if not $lines_left;
+
++ if ($max_id < $thread->{Id}) {
++ $max_id = $thread->{Id};
++ }
++
+ ## 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
+ ## interesting.
+@@ -952,8 +989,11 @@
{
$thread->{Host} =~ s/:\d+$//;
my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET);
@@ -193,16 +209,40 @@ $FreeBSD$
}
## Fix possible undefs
-@@ -1044,7 +1094,7 @@
+@@ -990,6 +1030,23 @@
+
+ }
+
++ #my $sz = $width - 52;
++ my $max_id_size = length $max_id;
++ my @sz = ($max_id_size, 9, 15, 10, 9, 6);
++ my $used = scalar(@sz) + Sum(@sz);
++ my $free = $width - $used;
++
++ print BOLD();
++
++ printf "%${max_id_size}s %9s %15s %10s %9s %6s %-${free}s\n",
++ 'Id','User','Host/IP','DB','Time', 'Cmd', 'Query or State';
++
++ print RESET();
++
++ ## Id User Host DB
++ printf "%${max_id_size}s %9s %15s %10s %9s %6s %-${free}s\n",
++ '--','----','-------','--','----', '---', '----------';
++
+ ## Sort by idle time (closest thing to CPU usage I can think of).
+
+ my @sorted;
+@@ -1044,7 +1101,7 @@
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",
$thread->{Id}, $thread->{User}, $thread->{Host}, $thread->{db},
$thread->{Time}, $thread->{Command}, $smInfo;
-@@ -1099,8 +1149,8 @@
+@@ -1099,8 +1156,8 @@
my @data = Hashes("SHOW INNODB STATUS");
open P, "|$config{pager}" or die "$!";