From nobody@FreeBSD.org  Wed Oct 14 23:04:36 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D76A010656A6
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 23:04:36 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id C60698FC25
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 23:04:36 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n9EN4aRB003969
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 23:04:36 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n9EN4aIu003968;
	Wed, 14 Oct 2009 23:04:36 GMT
	(envelope-from nobody)
Message-Id: <200910142304.n9EN4aIu003968@www.freebsd.org>
Date: Wed, 14 Oct 2009 23:04:36 GMT
From: Miroslav Lachman <000.fbsd@quip.cz>
To: freebsd-gnats-submit@FreeBSD.org
Subject: databases/mytop - error in case of client IP without hostname
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: m.seaman@infracaninophile.co.uk

>Number:         139615
>Category:       ports
>Synopsis:       databases/mytop - error in case of client IP without hostname
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 14 23:10:01 UTC 2009
>Closed-Date:    Mon Oct 26 15:56:19 UTC 2009
>Last-Modified:  Mon Oct 26 16:00:07 UTC 2009
>Originator:     Miroslav Lachman
>Release:        7.2-RELEASE-p4
>Organization:
codeLab.cz
>Environment:
FreeBSD 7.2-RELEASE-p4 #0: Fri Oct  2 08:22:32 UTC 2009     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
On machine with private network IP address (192.168.1.xx) without DNS or entry in /etc/hosts mytop command shows following error message for each line containing hosts connected from unresolvable IP:
Use of uninitialized value in substitution (s///) at /usr/local/bin/mytop line 998.

It is old known problem. The fix can be found on other systems:
http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/7ac750bd208e819a?pli=1
>How-To-Repeat:
Install and use mytop on machine with LAN clients without IP to hostname entry in DNS or /etc/hosts.

For example machine with 192.168.1.2, run mytop, connect to configurred mysql server from client with IP 192.168.1.3 and mytop show:
Use of uninitialized value in substitution (s///) at /usr/local/bin/mytop line 998.
>Fix:
@@ -952,8 +955,11 @@
         {
             $thread->{Host} =~ s/:\d+$//;
             my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET);
-            $host =~ s/^([^.]+).*/$1/;
-            $thread->{Host} = $host;
+            if ($host)
+            {
+              $host =~ s/^([^.]+).*/$1/;
+              $thread->{Host} = $host;
+            }
         }


Attached patch is reorganized original patch-mytop including fix above.

Patch attached with submission follows:

--- mytop.orig	2007-02-17 05:57:46.000000000 +0100
+++ mytop	2009-10-15 00:19:14.000000000 +0200
@@ -153,7 +153,7 @@
     "idle|i"              => \$config{idle},
     "resolve|r"           => \$config{resolve},
     "prompt!"             => \$config{prompt},
-    "long|!"              => \$config{long_nums},
+    "long!"               => \$config{long_nums},
     "mode|m=s"            => \$config{mode},
     "sort=s"              => \$config{sort},
 );
@@ -193,6 +193,7 @@
     *BLUE   = sub { };
     *WHITE  = sub { };
     *BOLD   = sub { };
+    *MAGENTA = sub { };
 }
 
 my $RESET  = RESET()   || '';
@@ -202,6 +203,7 @@
 my $BLUE   = BLUE()    || '';
 my $WHITE  = WHITE()   || '';
 my $BOLD   = BOLD()    || '';
+my $MAGENTA= MAGENTA() || '';
 
 ## Connect
 
@@ -369,6 +371,10 @@
         require Data::Dumper;
         print Data::Dumper::Dumper([\%config]);
         ReadKey(0);
+
+		if (-M $0) { # restart application, if it was modified - for debugging
+			exec('perl', $0, @ARGV);
+		}
     }
 
     ## m - mode swtich to qps
@@ -377,7 +383,7 @@
     {
         $config{mode} = 'qps';
         Clear() unless $config{batchmode};
-        print "Queries Per Second [hit q to exit this mode]\n";
+        print "Queries Per Second [hit q to exit, hit t for top mode]\n";
         next;
     }
 
@@ -710,7 +716,7 @@
     ##
     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)
@@ -819,7 +825,7 @@
         $lines_left--;
 
 
-        printf " Queries: %-5s  qps: %4.0f Slow: %7s         Se/In/Up/De(%%):    %02.0f/%02.0f/%02.0f/%02.0f \n",
+        printf " Queries: %-6s qps: %4.0f Slow: %7s         Se/In/Up/De(%%):    %02.0f/%02.0f/%02.0f/%02.0f \n",
                make_short( $STATUS{Questions} ),  # q total
                $STATUS{Questions} / $STATUS{Uptime},  # qps, average
                make_short( $STATUS{Slow_queries} ),    # slow
@@ -889,8 +895,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);
-        print "\n\n";
+        print "\n";
+
+        my @master_status = Hashes("show master status");
+        if (@master_status)
+        {
+			foreach my $m (@master_status) {
+				print " Master: $m->{File}/$m->{Position} ",
+					"do: ", GREEN(), "$m->{Binlog_Do_DB} ", RESET(),
+					 "ign: ", MAGENTA(), $m->{Binlog_Ignore_DB}, RESET(), "\n";
+				#$line_prefix = ' ' x length($line_prefix);
+				$lines_left--;
+			}
+		}
+
+        my @slave_status = Hashes("show slave status");
+        if (@slave_status)
+        {
+			my $line_prefix = "  Slave: ";
+			foreach my $s (@slave_status) {
+				print $line_prefix, BOLD(),
+					($s->{Slave_IO_Running} eq 'Yes'
+						&& $s->{Slave_SQL_Running} eq 'Yes'
+						&& $s->{Last_Errno} == 0
+						? ($s->{Seconds_Behind_Master} > 60 ? BOLD('WARN') : GREEN('OK  ')) : RED('ERR ')
+					), RESET(),
+					" Delay: ",
+					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_Log_File}/$s->{Read_Master_Log_Pos} ",
+					"\n";
+				#$line_prefix = ' ' x length($line_prefix);
+				$lines_left--;
+			}
+		}
 
+        print "\n";
         $lines_left--;
     }
 
@@ -952,8 +992,11 @@
         {
             $thread->{Host} =~ s/:\d+$//;
             my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET);
-            $host =~ s/^([^.]+).*/$1/;
-            $thread->{Host} = $host;
+            if ($host)
+            {
+              $host =~ s/^([^.]+).*/$1/;
+              $thread->{Host} = $host;
+            }
         }
 
         ## Fix possible undefs
@@ -1099,8 +1142,8 @@
     my @data = Hashes("SHOW INNODB STATUS");
 
     open P, "|$config{pager}" or die "$!";
-    print keys %{$data[0]};
-    print $data[0]->{Status},"\n";
+    print P keys %{$data[0]};
+    print P $data[0]->{Status},"\n";
     close P;
 }
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Wed Oct 14 23:10:11 UTC 2009 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

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

From: Edwin Groothuis <edwin@FreeBSD.org>
To: m.seaman@infracaninophile.co.uk
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/139615: databases/mytop - error in case of client IP without hostname
Date: Wed, 14 Oct 2009 23:10:09 UT

 Maintainer of databases/mytop,
 
 Please note that PR ports/139615 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/139615
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Matthew Seaman <m.seaman@infracaninophile.co.uk>
To: bug-followup@FreeBSD.ORG
Cc:  
Subject: Re: ports/139615: databases/mytop - error in case of client IP without
 hostname
Date: Thu, 15 Oct 2009 07:39:14 +0100

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enigDD54C60AC61B71E64758A2FC
 Content-Type: text/plain; charset=UTF-8; format=flowed
 Content-Transfer-Encoding: quoted-printable
 
 Edwin Groothuis wrote:
 > Maintainer of databases/mytop,
 >=20
 > Please note that PR ports/139615 has just been submitted.
 >=20
 > If it contains a patch for an upgrade, an enhancement or a bug fix
 > you agree on, reply to this email stating that you approve the patch
 > and a committer will take care of it.
 >=20
 > The full text of the PR can be found at:
 >     http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/139615
 >=20
 
 Approved, and thanks.
 
 	Cheers,
 
 	Matthew
 
 
 --=20
 Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                   Flat 3
 PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                   Kent, CT11 9PW
 
 
 --------------enigDD54C60AC61B71E64758A2FC
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.13 (FreeBSD)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
 iEYEAREIAAYFAkrWw5gACgkQ8Mjk52CukIyJWwCgiE6DNvZ3skWDh6aRYFFV+UHW
 beoAnA1DO24jpYZ6NgtbPks/IiPZPwC3
 =yx2R
 -----END PGP SIGNATURE-----
 
 --------------enigDD54C60AC61B71E64758A2FC--
State-Changed-From-To: feedback->open 
State-Changed-By: linimon 
State-Changed-When: Thu Oct 15 07:04:34 UTC 2009 
State-Changed-Why:  
Maintainer approved. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139615 
State-Changed-From-To: open->closed 
State-Changed-By: pav 
State-Changed-When: Mon Oct 26 15:49:30 UTC 2009 
State-Changed-Why:  
Committed, thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/139615: commit references a PR
Date: Mon, 26 Oct 2009 15:56:16 +0000 (UTC)

 pav         2009-10-26 15:56:07 UTC
 
   FreeBSD ports repository
 
   Modified files:
     databases/mytop      Makefile 
     databases/mytop/files patch-mytop 
   Log:
   - Squelch perl warning triggered when a client is connected to the server and
     his IP cannot be resolved into a hostname
   
   PR:             ports/139615
   Submitted by:   Miroslav Lachman <000.fbsd@quip.cz>
   Approved by:    Matthew Seaman <m.seaman@infracaninophile.co.uk> (maintainer)
   
   Revision  Changes    Path
   1.22      +1 -1      ports/databases/mytop/Makefile
   1.8       +44 -32    ports/databases/mytop/files/patch-mytop
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
