Bug 175476 - [PATCH] databases/mytop: [SUMMARIZE CHANGES]
Summary: [PATCH] databases/mytop: [SUMMARIZE CHANGES]
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Matthew Seaman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-21 11:10 UTC by ccn
Modified: 2013-01-22 22:26 UTC (History)
1 user (show)

See Also:


Attachments
mytop-1.6_10.patch (5.87 KB, patch)
2013-01-21 11:10 UTC, ccn
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ccn 2013-01-21 11:10:00 UTC
dynamic field width by max length of Id

Port maintainer (matthew@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: ports)
Comment 1 Edwin Groothuis freebsd_committer 2013-01-21 11:12:20 UTC
Responsible Changed
From-To: freebsd-ports-bugs->matthew

Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175476 

Date: Mon, 21 Jan 2013 19:18:28 +0000
Comment 2 dfilter service freebsd_committer 2013-01-22 22:17:41 UTC
Author: matthew
Date: Tue Jan 22 22:17:27 2013
New Revision: 310838
URL: http://svnweb.freebsd.org/changeset/ports/310838

Log:
  Make the width if the Id field dynamic.
  
  PR:		ports/175476
  Submitted by:	ccn <ccn@ccn.tw>

Modified:
  head/databases/mytop/Makefile
  head/databases/mytop/files/patch-mytop   (contents, props changed)

Modified: head/databases/mytop/Makefile
==============================================================================
--- head/databases/mytop/Makefile	Tue Jan 22 22:01:17 2013	(r310837)
+++ head/databases/mytop/Makefile	Tue Jan 22 22:17:27 2013	(r310838)
@@ -3,7 +3,7 @@
 
 PORTNAME=	mytop
 PORTVERSION=	1.6
-PORTREVISION=	9
+PORTREVISION=	10
 CATEGORIES=	databases
 MASTER_SITES=	http://jeremy.zawodny.com/mysql/mytop/
 

Modified: head/databases/mytop/files/patch-mytop
==============================================================================
--- head/databases/mytop/files/patch-mytop	Tue Jan 22 22:01:17 2013	(r310837)
+++ head/databases/mytop/files/patch-mytop	Tue Jan 22 22:17:27 2013	(r310838)
@@ -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 "$!";
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 3 Matthew Seaman freebsd_committer 2013-01-22 22:20:39 UTC
State Changed
From-To: open->closed

Committed, thanks!