Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jan 2013 18:54:13 +0800 (CST)
From:      ccn <ccn@ccn.tw>
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        matthew@FreeBSD.org
Subject:   ports/175476: [PATCH] databases/mytop: [SUMMARIZE CHANGES]
Message-ID:  <20130121105413.C0472747605@goingmarry.kkbox.com>
Resent-Message-ID: <201301211110.r0LBA0BW056603@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         175476
>Category:       ports
>Synopsis:       [PATCH] databases/mytop: [SUMMARIZE CHANGES]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 21 11:10:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     ccnchien
>Release:        FreeBSD 9.1-RC1 amd64
>Organization:
>Environment:
System: FreeBSD goingmarry 9.1-RC1 FreeBSD 9.1-RC1 #0: Tue Aug 14 04:25:06 UTC 2012
>Description:
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)
>How-To-Repeat:
>Fix:

--- mytop-1.6_10.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/databases/mytop/Makefile ./Makefile
--- /usr/ports/databases/mytop/Makefile	2012-12-15 17:34:23.000000000 +0800
+++ ./Makefile	2013-01-21 18:46:06.000000000 +0800
@@ -3,7 +3,7 @@
 
 PORTNAME=	mytop
 PORTVERSION=	1.6
-PORTREVISION=	9
+PORTREVISION=	10
 CATEGORIES=	databases
 MASTER_SITES=	http://jeremy.zawodny.com/mysql/mytop/
 
diff -ruN --exclude=CVS /usr/ports/databases/mytop/files/patch-mytop ./files/patch-mytop
--- /usr/ports/databases/mytop/files/patch-mytop	2013-01-21 17:49:32.000000000 +0800
+++ ./files/patch-mytop	2013-01-21 18:42:27.000000000 +0800
@@ -1,13 +1,14 @@
 --- ./mytop.orig	2007-02-17 12:57:46.000000000 +0800
-+++ ./mytop	2013-01-21 17:49:21.000000000 +0800
-@@ -1,5 +1,6 @@
++++ ./mytop	2013-01-21 18:42:17.000000000 +0800
+@@ -1,5 +1,7 @@
  #!/usr/bin/perl -w
  #
 +#
++#
  # $Id: mytop,v 1.53 2003/09/18 17:58:36 jzawodn Exp $
  
  =pod
-@@ -153,7 +154,7 @@
+@@ -153,7 +155,7 @@
      "idle|i"              => \$config{idle},
      "resolve|r"           => \$config{resolve},
      "prompt!"             => \$config{prompt},
@@ -16,7 +17,7 @@
      "mode|m=s"            => \$config{mode},
      "sort=s"              => \$config{sort},
  );
-@@ -193,6 +194,7 @@
+@@ -193,6 +195,7 @@
      *BLUE   = sub { };
      *WHITE  = sub { };
      *BOLD   = sub { };
@@ -24,7 +25,7 @@
  }
  
  my $RESET  = RESET()   || '';
-@@ -202,6 +204,7 @@
+@@ -202,6 +205,7 @@
  my $BLUE   = BLUE()    || '';
  my $WHITE  = WHITE()   || '';
  my $BOLD   = BOLD()    || '';
@@ -32,7 +33,7 @@
  
  ## Connect
  
-@@ -369,6 +372,10 @@
+@@ -369,6 +373,10 @@
          require Data::Dumper;
          print Data::Dumper::Dumper([\%config]);
          ReadKey(0);
@@ -43,7 +44,7 @@
      }
  
      ## m - mode swtich to qps
-@@ -377,7 +384,7 @@
+@@ -377,7 +385,7 @@
      {
          $config{mode} = 'qps';
          Clear() unless $config{batchmode};
@@ -52,7 +53,7 @@
          next;
      }
  
-@@ -710,7 +717,7 @@
+@@ -710,7 +718,7 @@
      ##
      if ($config{header})
      {
@@ -61,7 +62,7 @@
  
          ## if the server died or we lost connectivity
          if (not @recs)
-@@ -800,8 +807,15 @@
+@@ -800,8 +808,15 @@
  
          ## Queries per second...
  
@@ -79,7 +80,7 @@
  
          my @t = localtime(time);
  
-@@ -819,26 +833,26 @@
+@@ -819,26 +834,26 @@
          $lines_left--;
  
  
@@ -116,7 +117,7 @@
                   ( # slow now (qps)
                    ($STATUS{Slow_queries} ) ?
                    ( $STATUS{Slow_queries} - $OLD_STATUS{Slow_queries} ) / $t_delta :
-@@ -889,8 +903,42 @@
+@@ -889,8 +904,42 @@
                 make_short(($STATUS{Bytes_received} - $OLD_STATUS{Bytes_received}) / $t_delta ),
                 make_short(($STATUS{Bytes_sent} - $OLD_STATUS{Bytes_sent}) / $t_delta ))
            if ($t_delta);
@@ -160,30 +161,46 @@
          $lines_left--;
      }
  
-@@ -905,19 +953,19 @@
+@@ -904,21 +953,6 @@
+     ## 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;
+-    my $used = scalar(@sz) + Sum(@sz);
+-    my $free = $width - $used;
+-
+-    print BOLD();
+-
+-    printf "%8s %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 "%8s %9s %15s %10s %9s %6s %-${free}s\n",
+-        '--','----','-------','--','----', '---', '----------';
  
-     print BOLD();
+     $lines_left -= 2;
  
--    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';
+@@ -926,10 +960,16 @@
  
-     print RESET();
+     my @data = Hashes($proc_cmd);
  
-     ##      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 $max_id = 0;
++
+     foreach my $thread (@data)
+     {
+         last if not $lines_left;
  
-     $lines_left -= 2;
-@@ -952,8 +1000,11 @@
++        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 +992,11 @@
          {
              $thread->{Host} =~ s/:\d+$//;
              my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET);
@@ -197,16 +214,39 @@
          }
  
          ## Fix possible undefs
-@@ -1044,7 +1095,7 @@
+@@ -990,6 +1033,22 @@
+ 
+     }
+ 
++    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 +1103,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 +1150,8 @@
+@@ -1099,8 +1158,8 @@
      my @data = Hashes("SHOW INNODB STATUS");
  
      open P, "|$config{pager}" or die "$!";
--- mytop-1.6_10.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130121105413.C0472747605>