Mytop工具來監控MySQL資源
Mytop工具來監控MySQL資源
下載地址
個人百度網盤地址:
1. 安裝TermReadKey
tar -xvf TermReadKey-2.30.tar.gz
cd TermReadKey-2.30
perl Makefile.pl
make
make test
make install
[root@mysqltest ~]# tar -xvf TermReadKey-2.30.tar.gz
TermReadKey-2.30/
TermReadKey-2.30/genchars.pl
TermReadKey-2.30/Makefile.PL
TermReadKey-2.30/Configure.pm
TermReadKey-2.30/test.pl
TermReadKey-2.30/ReadKey.pm
TermReadKey-2.30/META.yml
TermReadKey-2.30/ReadKey.xs
TermReadKey-2.30/ppport.h
TermReadKey-2.30/MANIFEST
TermReadKey-2.30/README
[root@mysqltest ~]# cd TermReadKey-2.30
[root@mysqltest TermReadKey-2.30]# ll
total 144
-rw-r--r-- 1 501 501 27633 Mar 3 2004 Configure.pm
-rw-r--r-- 1 501 501 10688 Jan 12 2005 genchars.pl
-rw-r--r-- 1 501 501 1222 Mar 3 2004 Makefile.PL
-rw-r--r-- 1 501 501 170 Jan 12 2005 MANIFEST
-rw-r--r-- 1 501 501 245 Jan 12 2005 META.yml
-rw-r--r-- 1 501 501 15782 Jan 12 2005 ppport.h
-rw-r--r-- 1 501 501 16187 Jan 12 2005 ReadKey.pm
-rw-r--r-- 1 501 501 41938 Jan 12 2005 ReadKey.xs
-rw-r--r-- 1 501 501 6357 Jan 12 2005 README
-rw-r--r-- 1 501 501 7696 Jan 12 2005 test.pl
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Term::ReadKey
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]# make
cp ReadKey.pm blib/lib/Term/ReadKey.pm
AutoSplitting blib/lib/Term/ReadKey.pm (blib/lib/auto/Term/ReadKey)
/usr/bin/perl -I/usr/lib/perl5/5.8.8 genchars.pl
Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
Sgtty NOT found.
Writing sgtty section of cchars.h... Done.
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -noprototypes -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap ReadKey.xs > ReadKey.xsc && mv ReadKey.xsc ReadKey.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"2.30\" -DXS_VERSION=\"2.30\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE" ReadKey.c
In file included from ReadKey.xs:6:
ppport.h:230:1: warning: "PERL_UNUSED_DECL" redefined
In file included from ReadKey.xs:4:
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/perl.h:163:1: warning: this is the location of the previous definition
In file included from ReadKey.xs:375:
cchars.h: In function ‘XS_Term__ReadKey_GetControlChars’:
cchars.h:244: warning: unused variable ‘i’
ReadKey.xs: In function ‘ReadMode’:
ReadKey.xs:770: warning: unused variable ‘Perl___notused’
ReadKey.c: In function ‘XS_Term__ReadKey_SetTerminalSize’:
ReadKey.c:1999: warning: unused variable ‘targ’
Running Mkbootstrap for Term::ReadKey ()
chmod 644 ReadKey.bs
rm -f blib/arch/auto/Term/ReadKey/ReadKey.so
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic ReadKey.o -o blib/arch/auto/Term/ReadKey/ReadKey.so \
\
chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
cp ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs
chmod 644 blib/arch/auto/Term/ReadKey/ReadKey.bs
Manifying blib/man3/Term::ReadKey.3pm
[root@mysqltest TermReadKey-2.30]# make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" -w test.pl
1 .. 8
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
[root@mysqltest TermReadKey-2.30]# make install
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/ReadKey.so
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/ReadKey.bs
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Term/ReadKey.pm
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/autosplit.ix
Installing /usr/share/man/man3/Term::ReadKey.3pm
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
[root@mysqltest TermReadKey-2.30]#
2. 安裝DBI
tar xzvf DBI-1.615.tar.gz
cd DBI-1.615
perl Makefile.pl
make
make test
make install
(安裝可能報錯)
或者:
[root@mysqltest mytop-1.6]# yum list|grep DBD
Unable to read consumer identity
perl-DBD-MySQL.x86_64 3.0007-2.el5 installed
perl-DBD-Pg.x86_64 1.49-2.el5_3.1 hc360
[root@mysqltest mytop-1.6]# yum -y install perl-DBD-MySQL.x86_64
3. 安裝Mytop
tar xzvf mytop-1.6.tar.gz
cd mytop-1.6
perl Makefile.pl
make
make test
make install
[root@mysqltest dudong]# tar -xvf mytop-1.6.tar.gz
mytop-1.6/
mytop-1.6/MANIFEST
mytop-1.6/test.pl
mytop-1.6/mytop
mytop-1.6/Changes
mytop-1.6/INSTALL
mytop-1.6/README
mytop-1.6/Makefile.PL
mytop-1.6/META.yml
[root@mysqltest dudong]# cd mytop-1.6
[root@mysqltest mytop-1.6]# ll
total 84
-rw-r--r-- 1 1000 1000 6647 Feb 17 2007 Changes
-rw-r--r-- 1 1000 1000 20 Apr 28 2002 INSTALL
-rw-r--r-- 1 1000 1000 730 Apr 27 2002 Makefile.PL
-rw-r--r-- 1 1000 1000 137 Feb 17 2007 MANIFEST
-rw-r--r-- 1 1000 1000 405 Feb 17 2007 META.yml
-rwxr-xr-x 1 1000 1000 51906 Feb 17 2007 mytop
-rw-r--r-- 1 1000 1000 1003 Aug 5 2003 README
-rw-r--r-- 1 1000 1000 469 Apr 27 2002 test.pl
[root@mysqltest mytop-1.6]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for mytop
[root@mysqltest mytop-1.6]#
[root@mysqltest mytop-1.6]#
[root@mysqltest mytop-1.6]# make
cp mytop blib/script/mytop
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/mytop
Manifying blib/man1/mytop.1
[root@mysqltest mytop-1.6]# cd mytop
-bash: cd: mytop: Not a directory
[root@mysqltest mytop-1.6]# make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..1
ok 1
[root@mysqltest mytop-1.6]# make install
Installing /usr/local/share/man/man1/mytop.1
Installing /usr/local/bin/mytop
Appending installation info to /usr/lib64/perl5/perllocal.pod
[root@mysqltest mytop-1.6]#
常見錯誤:
1
安裝mytop 出現 Error in option spec: "long|!"
編輯 mytop vim /usr/bin/mytop
找到 "long|!" => \$config{long_nums},
修改成 "long|long_nums|l!" => \$config{long_nums},
# "long|!" => \$config{long_nums},
"long|long_nums|l!" => \$config{long_nums},
2
執行 mytop -uroot -pxxxxx 可能會出現報錯:
MySQL on localhost (5.1.43-log) up 345+20:36:31 [09:07:11]
Queries: 3.0 qps: 0 Slow: 0.0 Se/In/Up/De(%): 00/00/00/00
Key Efficiency: 100.0% Bps in/out: 0.0/ 0.0
Id User Host/IP DB Time Cmd Query or State
-- ---- ------- -- ---- --- ----------
Use of uninitialized value in substitution (s///) at ./mytop line 955.
Use of uninitialized value in substitution (s///) at ./mytop line 955.
...................................................
Use of uninitialized value in substitution (s///) at ./mytop line 955.
解決方法:
vi mytop
跳到955行,找到
$host =~ s/^([^.]+).*/$1/;
$thread->{Host} = $host;
改為:
if ($host)
{
$host =~ s/^([^.]+).*/$1/;
$thread->{Host} = $host;
}
4. 執行Mytop進行監控
配置:
[root@nagiosdb mytop-1.6]# ./mytop -u root -p '123456' -h 172.25.128.47:3306
Cannot connect to MySQL server. Please check the:
* database you specified "test" (default is "test")
* username you specified "root" (default is "root")
* password you specified "123456" (default is "")
* hostname you specified "172.25.128.47" (default is "localhost")
* port you specified "3306" (default is 3306)
* socket you specified "" (default is "")
The options my be specified on the command-line or in a ~/.mytop
config file. See the manual (perldoc mytop) for details.
Here's the exact error from DBI. It might help you debug:
Access denied for user 'root'@'nagiosdb' (using password: YES)
【其中,-u引數後面是資料庫使用者名稱,-p引數後面是資料庫密碼,-h引數後面是資料庫伺服器地址和資料庫所用埠號】
執行監控畫面如下:
[root@nagiosdb mytop-1.6]# ./mytop
MySQL on localhost (5.6.22) up 0+21:18:24 [15:17:32]
Queries: 3.0 qps: 0 Slow: 0.0 Se/In/Up/De(%): 00/00/00/00
Key Efficiency: 99.9% Bps in/out: 0.0/ 0.2
Id User Host/IP DB Time Cmd Query or State
-- ---- ------- -- ---- --- ----------
141 centreon sznagios:38676 centreon_s 0 Sleep
147 centreon sznagios:38682 centreon_s 0 Sleep
149 centreon sznagios:38685 centreon_s 0 Sleep
153 centreon sznagios:38692 centreon_s 0 Sleep
158 centreon sznagios:38699 centreon_s 0 Sleep
134920 root localhost test 0 Query show full processlist
83433 centreon sznagios:52368 centreon 1 Sleep
83425 centreon sznagios:52342 centreon 7 Sleep
83405 centreon sznagios:52294 centreon 10 Sleep
83508 centreon sznagios:52734 centreon 10 Sleep
84001 centreon sznagios:55458 centreon 10 Sleep
83479 centreon sznagios:52610 centreon 13 Sleep
84146 centreon sznagios:56369 centreon 13 Sleep
85812 centreon sznagios:38258 centreon 14 Sleep
85775 centreon sznagios:38204 centreon 25 Sleep
83585 centreon sznagios:53207 centreon 39 Sleep
85780 centreon sznagios:38209 centreon 40 Sleep
85794 centreon sznagios:38240 centreon 43 Sleep
85990 centreon sznagios:39089 centreon 58 Sleep
83610 centreon sznagios:53365 centreon 89 Sleep
84305 centreon sznagios:57667 centreon 104 Sleep
86012 centreon sznagios:39180 centreon 179 Sleep
95078 root localhost centreon_s 644 Sleep
119618 root 172.25.1.19 centreon_s 5936 Sleep
122126 root 172.25.1.19 centreon_s 5936 Sleep
119655 root 172.25.1.19 centreon_s 7002 Sleep
119648 root 172.25.1.19 centreon_s 7004 Sleep
119642 root 172.25.1.19 centreon_s 7006 Sleep
119634 root 172.25.1.19 centreon_s 7008 Sleep
119632 root 172.25.1.19 centreon_s 7010 Sleep
119626 root 172.25.1.19 centreon_s 7012 Sleep
119620 root 172.25.1.19 centreon_s 7016 Sleep
117453 root 172.25.1.19 centreon_s 8013 Sleep
117454 root 172.25.1.19 centreon_s 8013 Sleep
96133 cactiuser sznagios:59301 cacti 17736 Sleep
96099 cactiuser sznagios:59230 cacti 17754 Sleep
說明:
第一行顯示了主機名稱,還有至今 MySQL 的執行時間 (以 days hour:minutes:seconds 為格式)。
第二、三行的 Queries 顯示了至今執行的 SQL 查詢語句總數,另外還有目前每秒處理的查詢數和速度。
第四行的 Key Efficiency 就是傳說中的快取命中率了,如果太低了你可能要調整你的 MySQL 設定,或者調整一下表的結構,後面還有目前的進出速度。
最下方的區域就是目前連結到資料庫的各個執行緒,你可以按 k 殺死一個執行緒,或者按 f 瞭解特定執行緒的資訊。
引數:
-u / --user:指定 username,預設是 root
-p / --pass / --password:指定 password,預設是 none
-h / --host:指定 MySQL server 的 hostname,預設是 localhost
-P / --port:指定連線 MySQL server 的 port,預設是 3306
-s / --delay:更新的秒數,預設是 5 秒
-d / --db / --database:指定連線的資料庫,預設是 test
-b / --batch / --batchmode:指定為 batch mode,每次更新不會清除舊的顯示結果,會將更新資料顯示上最上方,預設是 unset
-S / --socket:指定使用 MySQL socket 直接連線,而不使用 TCP/IP 連線,預設是 none (當 mytop 和 MySQL 在同一臺時才能使用)
--header or -noheader:是否要顯示錶頭,預設是 header
--color or --nocolor:是否要使用顏色,預設是 color
-i / -idle or -noidle:idle 的 thread 是否要出現在清單上,預設是 idle
mytop 快捷鍵
s:設定更新時間
p:暫停畫面更新
q:離開
u:只看某個使用者的 thread
o:反轉排列順序
下載地址
個人百度網盤地址:
1. 安裝TermReadKey
tar -xvf TermReadKey-2.30.tar.gz
cd TermReadKey-2.30
perl Makefile.pl
make
make test
make install
[root@mysqltest ~]# tar -xvf TermReadKey-2.30.tar.gz
TermReadKey-2.30/
TermReadKey-2.30/genchars.pl
TermReadKey-2.30/Makefile.PL
TermReadKey-2.30/Configure.pm
TermReadKey-2.30/test.pl
TermReadKey-2.30/ReadKey.pm
TermReadKey-2.30/META.yml
TermReadKey-2.30/ReadKey.xs
TermReadKey-2.30/ppport.h
TermReadKey-2.30/MANIFEST
TermReadKey-2.30/README
[root@mysqltest ~]# cd TermReadKey-2.30
[root@mysqltest TermReadKey-2.30]# ll
total 144
-rw-r--r-- 1 501 501 27633 Mar 3 2004 Configure.pm
-rw-r--r-- 1 501 501 10688 Jan 12 2005 genchars.pl
-rw-r--r-- 1 501 501 1222 Mar 3 2004 Makefile.PL
-rw-r--r-- 1 501 501 170 Jan 12 2005 MANIFEST
-rw-r--r-- 1 501 501 245 Jan 12 2005 META.yml
-rw-r--r-- 1 501 501 15782 Jan 12 2005 ppport.h
-rw-r--r-- 1 501 501 16187 Jan 12 2005 ReadKey.pm
-rw-r--r-- 1 501 501 41938 Jan 12 2005 ReadKey.xs
-rw-r--r-- 1 501 501 6357 Jan 12 2005 README
-rw-r--r-- 1 501 501 7696 Jan 12 2005 test.pl
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Term::ReadKey
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]#
[root@mysqltest TermReadKey-2.30]# make
cp ReadKey.pm blib/lib/Term/ReadKey.pm
AutoSplitting blib/lib/Term/ReadKey.pm (blib/lib/auto/Term/ReadKey)
/usr/bin/perl -I/usr/lib/perl5/5.8.8 genchars.pl
Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
Sgtty NOT found.
Writing sgtty section of cchars.h... Done.
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -noprototypes -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap ReadKey.xs > ReadKey.xsc && mv ReadKey.xsc ReadKey.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"2.30\" -DXS_VERSION=\"2.30\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE" ReadKey.c
In file included from ReadKey.xs:6:
ppport.h:230:1: warning: "PERL_UNUSED_DECL" redefined
In file included from ReadKey.xs:4:
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/perl.h:163:1: warning: this is the location of the previous definition
In file included from ReadKey.xs:375:
cchars.h: In function ‘XS_Term__ReadKey_GetControlChars’:
cchars.h:244: warning: unused variable ‘i’
ReadKey.xs: In function ‘ReadMode’:
ReadKey.xs:770: warning: unused variable ‘Perl___notused’
ReadKey.c: In function ‘XS_Term__ReadKey_SetTerminalSize’:
ReadKey.c:1999: warning: unused variable ‘targ’
Running Mkbootstrap for Term::ReadKey ()
chmod 644 ReadKey.bs
rm -f blib/arch/auto/Term/ReadKey/ReadKey.so
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic ReadKey.o -o blib/arch/auto/Term/ReadKey/ReadKey.so \
\
chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
cp ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs
chmod 644 blib/arch/auto/Term/ReadKey/ReadKey.bs
Manifying blib/man3/Term::ReadKey.3pm
[root@mysqltest TermReadKey-2.30]# make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" -w test.pl
1 .. 8
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
[root@mysqltest TermReadKey-2.30]# make install
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/ReadKey.so
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/ReadKey.bs
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Term/ReadKey.pm
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/autosplit.ix
Installing /usr/share/man/man3/Term::ReadKey.3pm
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Term/ReadKey/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
[root@mysqltest TermReadKey-2.30]#
2. 安裝DBI
tar xzvf DBI-1.615.tar.gz
cd DBI-1.615
perl Makefile.pl
make
make test
make install
(安裝可能報錯)
或者:
[root@mysqltest mytop-1.6]# yum list|grep DBD
Unable to read consumer identity
perl-DBD-MySQL.x86_64 3.0007-2.el5 installed
perl-DBD-Pg.x86_64 1.49-2.el5_3.1 hc360
[root@mysqltest mytop-1.6]# yum -y install perl-DBD-MySQL.x86_64
3. 安裝Mytop
tar xzvf mytop-1.6.tar.gz
cd mytop-1.6
perl Makefile.pl
make
make test
make install
[root@mysqltest dudong]# tar -xvf mytop-1.6.tar.gz
mytop-1.6/
mytop-1.6/MANIFEST
mytop-1.6/test.pl
mytop-1.6/mytop
mytop-1.6/Changes
mytop-1.6/INSTALL
mytop-1.6/README
mytop-1.6/Makefile.PL
mytop-1.6/META.yml
[root@mysqltest dudong]# cd mytop-1.6
[root@mysqltest mytop-1.6]# ll
total 84
-rw-r--r-- 1 1000 1000 6647 Feb 17 2007 Changes
-rw-r--r-- 1 1000 1000 20 Apr 28 2002 INSTALL
-rw-r--r-- 1 1000 1000 730 Apr 27 2002 Makefile.PL
-rw-r--r-- 1 1000 1000 137 Feb 17 2007 MANIFEST
-rw-r--r-- 1 1000 1000 405 Feb 17 2007 META.yml
-rwxr-xr-x 1 1000 1000 51906 Feb 17 2007 mytop
-rw-r--r-- 1 1000 1000 1003 Aug 5 2003 README
-rw-r--r-- 1 1000 1000 469 Apr 27 2002 test.pl
[root@mysqltest mytop-1.6]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for mytop
[root@mysqltest mytop-1.6]#
[root@mysqltest mytop-1.6]#
[root@mysqltest mytop-1.6]# make
cp mytop blib/script/mytop
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/mytop
Manifying blib/man1/mytop.1
[root@mysqltest mytop-1.6]# cd mytop
-bash: cd: mytop: Not a directory
[root@mysqltest mytop-1.6]# make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..1
ok 1
[root@mysqltest mytop-1.6]# make install
Installing /usr/local/share/man/man1/mytop.1
Installing /usr/local/bin/mytop
Appending installation info to /usr/lib64/perl5/perllocal.pod
[root@mysqltest mytop-1.6]#
常見錯誤:
1
安裝mytop 出現 Error in option spec: "long|!"
編輯 mytop vim /usr/bin/mytop
找到 "long|!" => \$config{long_nums},
修改成 "long|long_nums|l!" => \$config{long_nums},
# "long|!" => \$config{long_nums},
"long|long_nums|l!" => \$config{long_nums},
2
執行 mytop -uroot -pxxxxx 可能會出現報錯:
MySQL on localhost (5.1.43-log) up 345+20:36:31 [09:07:11]
Queries: 3.0 qps: 0 Slow: 0.0 Se/In/Up/De(%): 00/00/00/00
Key Efficiency: 100.0% Bps in/out: 0.0/ 0.0
Id User Host/IP DB Time Cmd Query or State
-- ---- ------- -- ---- --- ----------
Use of uninitialized value in substitution (s///) at ./mytop line 955.
Use of uninitialized value in substitution (s///) at ./mytop line 955.
...................................................
Use of uninitialized value in substitution (s///) at ./mytop line 955.
解決方法:
vi mytop
跳到955行,找到
$host =~ s/^([^.]+).*/$1/;
$thread->{Host} = $host;
改為:
if ($host)
{
$host =~ s/^([^.]+).*/$1/;
$thread->{Host} = $host;
}
4. 執行Mytop進行監控
配置:
[root@nagiosdb mytop-1.6]# ./mytop -u root -p '123456' -h 172.25.128.47:3306
Cannot connect to MySQL server. Please check the:
* database you specified "test" (default is "test")
* username you specified "root" (default is "root")
* password you specified "123456" (default is "")
* hostname you specified "172.25.128.47" (default is "localhost")
* port you specified "3306" (default is 3306)
* socket you specified "" (default is "")
The options my be specified on the command-line or in a ~/.mytop
config file. See the manual (perldoc mytop) for details.
Here's the exact error from DBI. It might help you debug:
Access denied for user 'root'@'nagiosdb' (using password: YES)
【其中,-u引數後面是資料庫使用者名稱,-p引數後面是資料庫密碼,-h引數後面是資料庫伺服器地址和資料庫所用埠號】
執行監控畫面如下:
[root@nagiosdb mytop-1.6]# ./mytop
MySQL on localhost (5.6.22) up 0+21:18:24 [15:17:32]
Queries: 3.0 qps: 0 Slow: 0.0 Se/In/Up/De(%): 00/00/00/00
Key Efficiency: 99.9% Bps in/out: 0.0/ 0.2
Id User Host/IP DB Time Cmd Query or State
-- ---- ------- -- ---- --- ----------
141 centreon sznagios:38676 centreon_s 0 Sleep
147 centreon sznagios:38682 centreon_s 0 Sleep
149 centreon sznagios:38685 centreon_s 0 Sleep
153 centreon sznagios:38692 centreon_s 0 Sleep
158 centreon sznagios:38699 centreon_s 0 Sleep
134920 root localhost test 0 Query show full processlist
83433 centreon sznagios:52368 centreon 1 Sleep
83425 centreon sznagios:52342 centreon 7 Sleep
83405 centreon sznagios:52294 centreon 10 Sleep
83508 centreon sznagios:52734 centreon 10 Sleep
84001 centreon sznagios:55458 centreon 10 Sleep
83479 centreon sznagios:52610 centreon 13 Sleep
84146 centreon sznagios:56369 centreon 13 Sleep
85812 centreon sznagios:38258 centreon 14 Sleep
85775 centreon sznagios:38204 centreon 25 Sleep
83585 centreon sznagios:53207 centreon 39 Sleep
85780 centreon sznagios:38209 centreon 40 Sleep
85794 centreon sznagios:38240 centreon 43 Sleep
85990 centreon sznagios:39089 centreon 58 Sleep
83610 centreon sznagios:53365 centreon 89 Sleep
84305 centreon sznagios:57667 centreon 104 Sleep
86012 centreon sznagios:39180 centreon 179 Sleep
95078 root localhost centreon_s 644 Sleep
119618 root 172.25.1.19 centreon_s 5936 Sleep
122126 root 172.25.1.19 centreon_s 5936 Sleep
119655 root 172.25.1.19 centreon_s 7002 Sleep
119648 root 172.25.1.19 centreon_s 7004 Sleep
119642 root 172.25.1.19 centreon_s 7006 Sleep
119634 root 172.25.1.19 centreon_s 7008 Sleep
119632 root 172.25.1.19 centreon_s 7010 Sleep
119626 root 172.25.1.19 centreon_s 7012 Sleep
119620 root 172.25.1.19 centreon_s 7016 Sleep
117453 root 172.25.1.19 centreon_s 8013 Sleep
117454 root 172.25.1.19 centreon_s 8013 Sleep
96133 cactiuser sznagios:59301 cacti 17736 Sleep
96099 cactiuser sznagios:59230 cacti 17754 Sleep
說明:
第一行顯示了主機名稱,還有至今 MySQL 的執行時間 (以 days hour:minutes:seconds 為格式)。
第二、三行的 Queries 顯示了至今執行的 SQL 查詢語句總數,另外還有目前每秒處理的查詢數和速度。
第四行的 Key Efficiency 就是傳說中的快取命中率了,如果太低了你可能要調整你的 MySQL 設定,或者調整一下表的結構,後面還有目前的進出速度。
最下方的區域就是目前連結到資料庫的各個執行緒,你可以按 k 殺死一個執行緒,或者按 f 瞭解特定執行緒的資訊。
引數:
-u / --user
-p / --pass / --password
-h / --host
-P / --port
-s / --delay
-d / --db / --database
-b / --batch / --batchmode:指定為 batch mode,每次更新不會清除舊的顯示結果,會將更新資料顯示上最上方,預設是 unset
-S / --socket
--header or -noheader:是否要顯示錶頭,預設是 header
--color or --nocolor:是否要使用顏色,預設是 color
-i / -idle or -noidle:idle 的 thread 是否要出現在清單上,預設是 idle
mytop 快捷鍵
s:設定更新時間
p:暫停畫面更新
q:離開
u:只看某個使用者的 thread
o:反轉排列順序
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8494287/viewspace-1444357/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mytop 使用介紹 mysql實時監控工具MySql
- MySQL監控工具MySql
- 安裝實時監控mysql開源工具GitHub orzdba操作指南MySql開源工具Github
- 阿里雲容器Kubernetes監控(一)-資源監控阿里
- MySQL監控-Datadog資料庫監控調研MySql資料庫
- kubenetes metrics-server監控資源Server
- shell監控mysql 8.0資料庫MySql資料庫
- shell監控mysql 5.7資料庫MySql資料庫
- 目前哪些開源雲監控工具比較好用!
- SpringBoot2.x 多資料來源切換、druid監控、tkSpring BootUI
- Grafana監控騰訊物理資源資訊Grafana
- jmeter 監控伺服器資源 求助!!!JMeter伺服器
- .NET Core 跨平臺資源監控庫及 dotnet tool 小工具
- 一鍵配置開源伺服器監控工具 NetData伺服器
- MySQL sys效能監控MySql
- 服務監控工具
- 運維監控工具運維
- Linux 效能監控工具Linux
- OceanBase 監控工具 OBAgent
- linux監控工具auditLinux
- tomcat 監控工具probeTomcat
- Mycat Web監控工具Web
- 使用 Performance API 實現前端資源監控ORMAPI前端
- 利用Resource Timing監控資源載入速度
- zabbix6.2新增mysql資料庫監控MySql資料庫
- 網路監控系統七大開源工具分析開源工具
- 阿里開源 java 專案記憶體監控工具 arthas阿里Java記憶體
- 網站監控工具有哪些,8款好用的監控工具推薦網站
- 【效能監控】如何有效監測網頁靜態資源大小?網頁
- Prometheus MySQL監控+grafana展示PrometheusMySqlGrafana
- mysql效能監控相關MySql
- 搭建Lepus 天兔 監控MySQLMySql
- Mysql事件監控日誌MySql事件
- Mysql 建立心跳錶來監控Replication的Slave是否延遲MySql
- Conntrack 監控,別等故障了再回來加監控
- capital許可監控工具API
- Mac系統監控工具Mac
- Linux 流量監控工具 iftopLinux
- 【AIX】AIX程式監控工具AI