【Mysql监控工具之mytop】

要对mysql的运行性能进行监控的话工具也非常多。强大复杂的有 oracle官方提供的mysql 企业监控器(当然是收费的),当然开源的配置nagios、cacti上运行的mysql-monitor插件也不少。而想要实时的观察的话,也有mytop、mycheckpoint(绘图显示)、mtop(托管在sourceforge,从04年至今没见更新了。还有一个mongodb 的监控工具也要mtop,托管在github)等等。

该工具说白了就是一段perl脚本,依赖于别外一个perl包。主页上作者说的也比较明白了:

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. As of version 0.7, it even runs on Windows (somewhat)



 

 mytop的设计灵感来自于系统监视工具top,两者的很多功能命令非常相似,Linux、FreeBSD和Solaris用户应该对此命令较为熟悉。mytop将连接到一个MySQL服务器,定时运行SHOW PROCESSLIST和SHOW STATUS命令,并试图以一个有用的格式汇总这些信息。

INSTALLATION

 tar -zxvf mytop-<version>.tar.gz

  cd mytop-<version>

  perl Makefile.PL

  make

  make test

  make install

  The test is a bit stupid, but it's there from completeness.

DOCUMENTATION

  man mytop

Arguments

mytop handles long and short command-line arguments. Not all options have both long and short formats, however. The long arguments can start with one or two dashes `-' or `--'. They are shown here with just one.

-u or -user username

Username to use when logging in to the MySQL server. Default: ``root''.

-p or -pass or -password password

Password to use when logging in to the MySQL server. Default: none.

-h or -host hostname[:port]

Hostname of the MySQL server. The hostname may be followed by an option port number. Note that the port is specified separate from the host when using a config file. Default: ``localhost''.

-port or -P port

If you're running MySQL on a non-standard port, use this to specify the port number. Default: 3306.

-s or -delay seconds

How long between display refreshes. Default: 5

-d or -db or -database database

Use if you'd like mytop to connect to a specific database by default. Default: ``test''.

-b or -batch or -batchmode

In batch mode, mytop runs only once, does not clear the screen, and places no limit on the number of lines it will print. This is suitable for running periodically (perhaps from cron) to capture the information into a file for later viewing. You might use batch mode in a CGI script to occasionally display your MySQL server status on the web.

Default: unset.

-S or -socket /path/to/socket

If you're running mytop on the same host as MySQL, you may wish to have it use the MySQL socket directly rather than a standard TCP/IP connection. If you do,just specify one.

Note that specifying a socket will make mytop ignore any host and/or port that you might have specified. If the socket does not exist (or the file specified is not a socket), this option will be ignored and mytop will use the hostname and port number instead.

Default: none.

-header or -noheader

Sepcify if you want the header to display or not. You can toggle this with the h key while mytop is running.

Default: header.

-color or -nocolor

Specify if you want a color display. This has no effect if you don't have color support available.

Default: If you have color support, mytop will try color unless you tell it not to.

-i or -idle or -noidle

Specify if you want idle (sleeping) threads to appear in the list. If sleeping threads are omitted, the default sorting order is reversed so that the longest running queries appear at the top of the list.

Default: idle.

Command-line arguments will always take precedence over config file options. That happens because the config file is read BEFORE the command-line arguments are applied

.

猜你喜欢

转载自gaojingsong.iteye.com/blog/2381355