Have a Question?

If you have any question you can ask below or enter what you are looking for!

Installing and Using mytop for MySQL Performance Monitoring on a cPanel Server

In another article, we showed you how to install htop which a great alternative to native ‘top’ utility that provides an enhanced top-like experience. This article will show you how to install mytop which is a similar tool specifically designed for MySQL.

Background

If you were wondering why there is even a need for mytop, the fact is that cPanel offers no tools for MySQL monitoring. Also, while phpMyAdmin does have built-in monitoring, there may be significant lag on large amounts of data which can cause additional server load.

With WHM, all you will get is a static snapshot of MySQL process list if you enable it by navigating to SQL Services >> Show MySQL Processes page.

How to Install mytop

You can find the latest version of mytop here; it is maintained by Mark Grennan. It is recommended that you install mytop from the source and to make sure that these requirements are met before you proceed with the mytop installation.

  1. Install perl-TermReadKey package.
yum install perl-TermReadKey

Either the package will be fetched and installed, or you’ll get a notification that it is already installed on your server.

  1. Check if DBD::mysql Perl module is installed by navigating to Software >> Install a Perl module. If it is installed, you will see DBD::mysql in the list of installed modules, and if not, you can use that page to install it through the ‘Search’ or ‘Show Available Perl Modules’ function.
  2. Install mytop by executing these commands one at a time. Make sure that you are logged into your server via SSH as a root user.

cd /root
wget http://www.mysqlfanboy.com/mytop/mytop-1.9.1.tar.gz
tar zxpfv mytop-1.9.1.tar.gz
cd ./mytop-1.9.1
perl Makefile.PL
make install
cd ..

  1. You can now use mytop.

Using mytop

Unlike with top and htop where you only need to type the command and hit ‘Enter’ to start up, it is a tad more complicated to do so with mytop wherein you need to connect to a database on start. Generally, it will look like this:

mytop -d database -u user -p password

Remember to replace ‘database’, ‘user’ and ‘password’ with your actual values. Afterwards, something like this should appear:

mytop in action

Naturally, this example will differ from that of the output on your server. The above example shows a connection to one of WHM’s databases (horde) on a VPS.

Advanced Usage

There are quite a few command-line arguments, shortcuts, and configuration file support for mytop which are documented on its website.

Make sure to read through the website, and while you’re at it, perhaps you’d want to say cheers to Mark Grennan for maintaining mytop.

To learn more about SQL, visit How to Use SQL Database in cPanel.

Leave a Reply

You must be logged in to post a comment.