After a long period of not integrating patches, I've released the newest version of mytop.

mytop is a console-based (non-gui) tool for monitoring the threads and overall performance of MySQL 3.22.x, 3.23.x, and 4.x servers. It runs on most Unix systems (including Mac OS X) which have Perl, DBI, and Term::ReadKey installed. And with Term::ANSIColor installed you even get color. If you install Time::HiRes, you'll get good real-time queries/second stats.

Version 1.4 contains several new features, including a revamped display at the top of the screen. See the Changes file for a details about what's new.

Give it a whirl and let me know of bugs or feature requests. To discuss, hop on the mailing list.

Posted by jzawodn at August 04, 2003 10:45 AM

Reader Comments
# LenZ said:

Thanks, keep up the good work! Two things:

The "Download" link on top of the mytop page still points to the 1.3 tarball
RPMs for SuSE Linux 8.2 can be downloaded from here: http://www.lenzg.org/RPMs/8.2-i386/

on August 4, 2003 12:39 PM
# Jeremy Zawodny said:

Link fixed, thanks.

on August 4, 2003 01:10 PM
# François said:

Very nice tool indeed. I installed it successfully on both Solaris 2.8 and Mac OS X 10.2.6.

Looking forward to reading this book ;-)

on August 4, 2003 01:18 PM
# DarrellGolliher said:

I like it. I had been using mtop by Marc Prewitt. I think when I last tried mytop I gave up because it segfaulted on me. This version did too, but I tracked it down to the mysql_read_default_group in $dns. Upgrading my DBD::mysql didn't help, but I got mytop running by removing mysql_read_default_group from the dsn.

I've noticed two things that you might consider bugs.
1) After pressing 'm' to get a scrolling view of querries per second the intructions are to hit q to exit this mode. q actually exits mytop and drops the user to the command line.

2) Switching off the header also appears to switch off the clearing of the screen between refreshes.

on August 5, 2003 09:36 AM
# Jeremy Zawodny said:

Odd. I haven't heard of *that* causing a segfault before.

Anyway, I'll get the other bugs fixed. They should be easy. :-)

Thanks!

on August 5, 2003 10:29 AM
# Ben Margolin said:

Hmm, I keep meaning to try mysqltop. I wrote something similar-ish a while back, but much simpler. It seems when I have difficulty on my site I'm always banging at w, pstree and mysqles (mysqlextendedstatus--my version), to see what's what. (Typically, it's the FT search swapping its indices out to disk, yay.) Anyhow, perhaps other folks might want to try my script. I've only tested this on linux, so no idea if it works elsewhere, but should as it's plain ugly perl. It gives similar types of info as mysqltop, but in a slightly more compact way, well, in a way I'm used to, anyhow. See if you like it. (BTW yes I know this isn't the prettiest thing.)

Typical output:

Server up 457.0 hours
Bytes I/O: 3608.2 / 2692.6 (MB)
Keycache hit rate: 99.9999%
Threads connected: 40, running: 2 (5.0%)

Command profile:
admin_commands 3771823 (11.5%)
alter_table 6 ( 0.0%)
change_db 6750774 (20.6%)
check 11 ( 0.0%)
delete 45436 ( 0.1%)
flush 19 ( 0.0%)
insert 439441 ( 1.3%)
insert_select 7652 ( 0.0%)
lock_tables 58 ( 0.0%)
optimize 38 ( 0.0%)
repair 3 ( 0.0%)
replace 606630 ( 1.8%)
select 17203467 (52.5%)
show_databases 11 ( 0.0%)
show_fields 398 ( 0.0%)
show_keys 8 ( 0.0%)
show_processlist 1 ( 0.0%)
show_slave_hosts 6 ( 0.0%)
show_status 5485 ( 0.0%)
show_tables 13 ( 0.0%)
unlock_tables 58 ( 0.0%)
update 3963950 (12.1%)
Total commands processed: 32795288

Users:
ben 1 0 s
jaiba_slurp 1 0 s
loquo_bcn_user 4 26 s
loquo_madrid_user 1 4 s
princeorg 16 27 s
sessions 16 27 s
stage_bcn_user 1 5 s

Running requests:
ben/1440095: show processlist


You can download the script from http://www.homiez.com/mysqles

on August 14, 2003 06:02 AM
# cancel said:

Neateo! I learn or find something new all the time around here. MyTop will be put to use.

on September 27, 2003 08:23 PM
# Los said:

Jeremy,

It's many years later and I'm still a fan of this tool. I'm not sure what others are using but this is simple and does the trick for me. I made a couple of changes so that it works with MySQL 5 -- use show global status when the version is 5 or greater. This resolves the issue with Cache hit data not showing up. If you are interested I'd be glad to send it over to you.

-Los

on October 16, 2008 07:15 PM
# KB said:

Jeremy,

First, thanks bunches for mytop – it’s been my monitoring friend for years.

I found that changing line 955 of mytop to this got rid of uninitialized value warnings from Perl. You may want to do something similar in all the places where it’s possible to do a regex replace on an undefined variable like this.

$host =~ s/^([^.]+).*/$1/ if defined $host;

The only change was to add the if defined $host part

To put it into context:

else
{
$thread->{Host} =~ s/^([^.]+).*/$1/;
}

## Otherwise, look up the IP (if resolve is set) and strip the
## name
if ($is_ip and $config{resolve})
{
$thread->{Host} =~ s/:\d+$//;
my $host = gethostbyaddr(inet_aton($thread->{Host}), AF_INET);
$host =~ s/^([^.]+).*/$1/ if defined $host;
$thread->{Host} = $host;
}

## Fix possible undefs

$thread->{db} ||= '';
$thread->{Info} ||= '';
$thread->{Time} ||= 0 ;
$thread->{Id} ||= 0 ;
$thread->{User} ||= '';
$thread->{Command} ||= '';
$thread->{Host} ||= '';

## Normalize spaces -- mostly disabled for now. This can
## break EXPLAIN if you try to explain a mangled query. It

FYI - I tried sending you a private email, but both the emails I used bounced.

on December 22, 2008 12:33 PM
# GB said:

Hi Los,
We'd love to get mytop to work on MySQL 5.
Any directions, or links appreciated.
Thanks,
-GB

on April 5, 2009 10:08 AM
Disclaimer: The opinions expressed here are mine and mine alone. My current, past, or previous employers are not responsible for what I write here, the comments left by others, or the photos I may share. If you have questions, please contact me. Also, I am not a journalist or reporter. Don't "pitch" me.

 

Privacy: I do not share or publish the email addresses or IP addresses of anyone posting a comment here without consent. However, I do reserve the right to remove comments that are spammy, off-topic, or otherwise unsuitable based on my comment policy. In a few cases, I may leave spammy comments but remove any URLs they contain.