{"id":1187,"date":"2021-09-04T14:57:11","date_gmt":"2021-09-04T09:27:11","guid":{"rendered":"http:\/\/www.webhostingchennai.co.in\/blog\/?p=1187"},"modified":"2021-09-27T17:21:12","modified_gmt":"2021-09-27T11:51:12","slug":"mytop-a-useful-tool-for-monitoring","status":"publish","type":"post","link":"https:\/\/chennaiwebhosting.in\/blog\/mytop-a-useful-tool-for-monitoring\/","title":{"rendered":"Mytop \u2013 A Useful Tool for Monitoring MySQL\/MariaDB"},"content":{"rendered":"<p><strong>Mytop \u2013 A Useful Tool for Monitoring MySQL\/MariaDB<\/strong><\/p>\n<p>Mytop is an open source and free monitoring program for MySQL and MariaDB databases was written by Jeremy Zawodny using Perl language. It is much similar in look and feel of the most famous <a href=\"https:\/\/www.webhostingchennai.co.in\/web-host-chennai.html\" rel=\"nofollow noopener\" target=\"_blank\">linux<\/a> system monitoring tool called top.<\/p>\n<p>Mytop program provides a command-line shell interface to monitor real time MySQL\/MariaDB threads, queries per second, process list and performance of databases and gives a idea for the database administrator to better optimize the server to handle heavy load.<\/p>\n<p>By default Mytop tool is included in the Fedora and Debian\/Ubuntu repositories, so you just have to install it using your default package manager.<\/p>\n<p>If you are using RHEL\/CentOS distributions, then you need to enable third party EPEL repository to install it.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/chennaiwebhosting.in\/blog\/mytop-a-useful-tool-for-monitoring\/#CentOS_7_64_Bit\" >CentOS 7 64 Bit<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/chennaiwebhosting.in\/blog\/mytop-a-useful-tool-for-monitoring\/#CentOS_6_32-64_Bit\" >CentOS 6 32-64 Bit<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/chennaiwebhosting.in\/blog\/mytop-a-useful-tool-for-monitoring\/#Installing_Mytop\" >Installing Mytop<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/chennaiwebhosting.in\/blog\/mytop-a-useful-tool-for-monitoring\/#Using_Mytop_to_Monitor_MySQL\" >Using Mytop to Monitor MySQL<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"CentOS_7_64_Bit\"><\/span>CentOS 7 64 Bit<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre># wget http:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-7.noarch.rpm\r\n# rpm -ivh epel-release-latest-7.noarch.rpm<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"CentOS_6_32-64_Bit\"><\/span>CentOS 6 32-64 Bit<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre>&lt;b&gt;## RHEL\/CentOS 6 32-Bit ##&lt;\/b&gt;\r\n# wget http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/i386\/epel-release-6-8.noarch.rpm\r\n# rpm -ivh epel-release-6-8.noarch.rpm\r\n\r\n&lt;b&gt;## RHEL\/CentOS 6 64-Bit ##&lt;\/b&gt;\r\n# wget http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm\r\n# rpm -ivh epel-release-6-8.noarch.rpm<\/pre>\n<p>For other Linux distributions you can get <a href=\"http:\/\/jeremy.zawodny.com\/mysql\/mytop\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">mytop source package<\/a> and compile it from source as shown.<\/p>\n<pre># tar -zxvf mytop-&lt;version&gt;.tar.gz\r\n# cd mytop-\r\n# perl Makefile.PL\r\n# make\r\n# make test\r\n# make install<\/pre>\n<p>In this MySQL monitoring tutorial, we will show you how to install, configure and use <strong>mytop<\/strong> on various Linux distributions.<\/p>\n<p>Please note you must have running MySQL\/MariaDB Server on the system to install and use <strong>Mytop<\/strong>.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Installing_Mytop\"><\/span>Installing Mytop<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>To install <strong>Mytop<\/strong>, run the appropriate command below for your Linux distribution to install it.<\/p>\n<pre>$ sudo apt install mytop\t#Debian\/Ubuntu\r\n# yum install mytop\t        #RHEL\/CentOS\r\n# dnf install mytop\t        #Fedora 22+\r\n# pacman -S mytop\t        #Arch Linux\r\n# zypper in mytop\t        #openSUSE<\/pre>\n<p><strong>Output :<\/strong><\/p>\n<pre>[root@server ~]# yum install mytop\r\nLoaded plugins: fastestmirror\r\nbase                                                                                                           | 3.6 kB  00:00:00\r\ncentosplus                                                                                                     | 3.4 kB  00:00:00\r\nepel\/x86_64\/metalink                                                                                           | 3.4 kB  00:00:00\r\nepel                                                                                                           | 4.7 kB  00:00:00\r\nextras                                                                                                         | 3.4 kB  00:00:00\r\nupdates                                                                                                        | 3.4 kB  00:00:00\r\nDetermining fastest mirrors\r\n * base: centos.excellmedia.net\r\n * centosplus: centos.excellmedia.net\r\n * epel: repos.del.extreme-ix.org\r\n * extras: centos.excellmedia.net\r\n * updates: centos.excellmedia.net\r\nResolving Dependencies\r\n--&gt; Running transaction check\r\n---&gt; Package mytop.noarch 0:1.7-10.b737f60.el7 will be installed\r\n--&gt; Processing Dependency: perl(DBD::mysql) &gt;= 1 for package: mytop-1.7-10.b737f60.el7.noarch\r\n--&gt; Processing Dependency: perl(Term::ReadKey) &gt;= 2.1 for package: mytop-1.7-10.b737f60.el7.noarch\r\n--&gt; Processing Dependency: perl(DBI) for package: mytop-1.7-10.b737f60.el7.noarch\r\n--&gt; Running transaction check\r\n---&gt; Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed\r\n---&gt; Package perl-DBI.x86_64 0:1.627-4.el7 will be installed\r\n--&gt; Processing Dependency: perl(RPC::PlServer) &gt;= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64\r\n--&gt; Processing Dependency: perl(RPC::PlClient) &gt;= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64\r\n---&gt; Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed\r\n--&gt; Running transaction check\r\n---&gt; Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed\r\n--&gt; Processing Dependency: perl(Net::Daemon) &gt;= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; Running transaction check\r\n---&gt; Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed\r\n--&gt; Processing Dependency: perl(Compress::Raw::Zlib) &gt;= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch\r\n--&gt; Processing Dependency: perl(Compress::Raw::Bzip2) &gt;= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch\r\n---&gt; Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed\r\n--&gt; Running transaction check\r\n---&gt; Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed\r\n---&gt; Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed\r\n--&gt; Finished Dependency Resolution\r\n\r\nDependencies Resolved\r\n\r\n==================================================================================================\r\n Package                       Arch         Version               Repository              Size\r\n==================================================================================================\r\n mytop                        noarch       1.7-10.b737f60.el7     epel                    33 k\r\nInstalling for dependencies:\r\n perl-Compress-Raw-Bzip2      x86_64       2.061-3.el7            base                    32 k\r\n perl-Compress-Raw-Zlib       x86_64       1:2.061-4.el7          base                    57 k\r\n perl-DBD-MySQL               x86_64       4.023-6.el7            base                   140 k\r\n perl-DBI                     x86_64       1.627-4.el7            base                   802 k\r\n perl-IO-Compress             noarch       2.061-2.el7            base                   260 k\r\n perl-Net-Daemon              noarch       0.48-5.el7             base                    51 k\r\n perl-PlRPC                   noarch       0.2020-14.el7          base                    36 k\r\n perl-TermReadKey             x86_64       2.30-20.el7            base                    31 k\r\n\r\nTransaction Summary\r\n===================================================================================================\r\nInstall  1 Package (+8 Dependent packages)\r\n\r\nTotal download size: 1.4 M\r\nInstalled size: 3.5 M\r\nIs this ok [y\/d\/N]:y<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"Using_Mytop_to_Monitor_MySQL\"><\/span>Using Mytop to Monitor MySQL<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>Mytop<\/strong> needs <strong>MySQL\/MariaDB<\/strong> login credentials to monitor databases and connects to the server with the root username by default. You can specify the necessary options for connecting to the database server on the command-line as you run it or in the file <code>~\/.mytop<\/code> .<\/p>\n<p>Edit .mytop file as follows<\/p>\n<pre>#nano \/root\/.mytop\r\n\r\n<\/pre>\n<p>Now, add the below lines in mytop config file<\/p>\n<pre>host=localhost\r\ndb=mysql\r\ndelay=3\r\nport=3306\r\nsocket=\r\nbatchmode=0\r\ncolor=1\r\nidle=1<\/pre>\n<p>Just run the following command to start the <strong>mytop<\/strong> and provide your <strong>MySQL\/MariaDB<\/strong> root user password, when prompted. This will connect to the <strong>test<\/strong> database by default.<\/p>\n<pre># mytop --prompt\r\nPassword:<\/pre>\n<p>You will get output as follows.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-243 size-full\" src=\"http:\/\/chennaihosting.net\/blog\/wp-content\/uploads\/2019\/03\/output.jpg\" alt=\"Mytop \u2013 A Useful Tool for Monitoring MySQL\" width=\"891\" height=\"211\" \/><\/p>\n<pre>MySQL on localhost (5.5.60-MariaDB)                                                                           up 0+00:06:42 [09:58:01]\r\n Queries: 144.0  qps:    0 Slow:     0.0         Se\/In\/Up\/De(%):    00\/00\/00\/00\r\n             qps now:    1 Slow qps: 0.0  Threads:    1 (   1\/   0) 00\/00\/00\/00\r\n Key Efficiency: 100.0%  Bps in\/out:   9.6\/ 2.0k   Now in\/out:  16.2\/ 3.8k\r\n\r\n      Id      User         Host\/IP         DB      Time    Cmd Query or State\r\n       --      ----         -------         --      ----    --- ----------\r\n        4      root       localhost      mysql         0  Query show full processlist\r\n\r\n<\/pre>\n<p>If you would like to monitor specific database, then use the <code>-d<\/code> option as shown below. For example the below command will monitor database<\/p>\n<pre># mytop --prompt -d test\r\nPassword:<\/pre>\n<pre>MySQL on localhost (5.5.60-MariaDB)                                                                          \r\n Queries: 353.0  qps:    0 Slow:     0.0         Se\/In\/Up\/De(%):    00\/00\/00\/00\r\n\r\n Key Efficiency: 100.0%  Bps in\/out:  11.6\/ 2.5k\r\n\r\n      Id      User         Host\/IP         DB      Time    Cmd Query or State\r\n       --      ----         -------         --      ----    --- ----------\r\n      4657      root       localhost      test         0  Query show full processlist\r\n      4665      root       localhost      test         0  sleep\r\n\r\n\r\n[root@server ~]#\r\n\r\n<\/pre>\n<p>Hope, this will help you in finding your needs, please share your valuable comments to improve us.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mytop \u2013 A Useful Tool for Monitoring MySQL\/MariaDB Mytop is an open source and free monitoring program for MySQL and MariaDB databases was written by Jeremy Zawodny using Perl language. It is much similar in look and feel of the most famous linux system monitoring tool called top. Mytop program provides a command-line shell interface [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1559,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[11,79,74],"tags":[78,80],"class_list":["post-1187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-mysql","category-vps","tag-installing-mytop-in-centos","tag-mytop-installing"],"_links":{"self":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/1187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=1187"}],"version-history":[{"count":1,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/1187\/revisions"}],"predecessor-version":[{"id":1540,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/1187\/revisions\/1540"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/media\/1559"}],"wp:attachment":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=1187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=1187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=1187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}