[Bug 303960] [NEW] mytop wrap problem with high thread ids

Troy Jendra troybie at gmail.com
Mon Dec 1 11:16:45 UTC 2008


Public bug reported:

Binary package hint: mytop

When mysql has been running for a while, and the thread ids get above
99999999, mytop becomes unusable, because every line wraps, eg on an 80
column terminal

      Id      User         Host/IP         DB      Time    Cmd Query or State   
      --      ----         -------         --      ----    --- ----------       
121417123 adaggrega    adagcluster1 adaggregat         0  Query UPDATE `table_st
u

This is because mytop uses a fixed width of 8 characters for thread id,
but doesn't enforce it.

I've added a bit of code to truncate the output string to the width of
the display.  Here is a diff:

$ diff -u mytop.orig mytop
--- mytop.orig	2008-12-01 11:12:49.000000000 +0000
+++ mytop	2008-12-01 11:13:15.000000000 +0000
@@ -1047,9 +1047,11 @@
             print GREEN()  if $thread->{Command} eq 'Connect';
         }
 
-        printf "%8d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s\n",
+        # truncate output to $width characters to prevent wrapping
+        my $output = sprintf "%8d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s",
             $thread->{Id}, $thread->{User}, $thread->{Host}, $thread->{db},
             $thread->{Time}, $thread->{Command}, $smInfo;
+	printf "%s\n", substr($output, 0, $width);
 
         print RESET() if $HAS_COLOR;


Version of Ubuntu
# lsb_release -rd
Description:	Ubuntu 8.04.1
Release:	8.04

Verion of mytop
# apt-cache policy mytop
mytop:
  Installed: 1.6-1
  Candidate: 1.6-1

** Affects: mytop (Ubuntu)
     Importance: Undecided
         Status: New

-- 
mytop wrap problem with high thread ids
https://bugs.launchpad.net/bugs/303960
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs




More information about the universe-bugs mailing list