首页 > 互联网技术 > cacti添加mysql监控

cacti添加mysql监控

2010年1月14日 9,584 views 发表评论 阅读评论

安装好被监控主机的snmpd
rpm -Uvh lm_sensors-2.10.7-4.el5.x86_64.rpm
rpm -Uvh net-snmp-5.3.2.2-7.el5.x86_64.rpm

安装好cacti (略)
安装Mysql模板监控mysql
Mysql cacti google

1.下载.
wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.6.tar.gz
http://code.google.com/p/mysql-cacti-templates/wiki/InstallingTemplates
2.安装
The general process is to copy the data-gathering scripts into place, and then to import the templates via the web interface.
2.1 Copy the PHP scripts into your Cacti installation’s scripts directory, on the server that hosts Cacti.
cp ~/pkgs/better-cacti-templates-1.1.6/scripts/ss_get_mysql_stats.php /home/appmgr/htdocs/cacti/scripts
更改php文件里的用户名和密码.
2.2 Now import the template files through your web browser

各个图形的study,参考.
采集使用的MySQL用户需要什么权限
GRANT PROCESS, SUPER, REPLICATION CLIENT ON *.* TO ‘cacti’@’%’
参考: 使用Cacti监控MySQL
摘录一段官方的安装介绍:

Installation Notes

The MySQL templates work by executing a PHP script that gathers information from MySQL servers and returns it to Cacti. The script makes an ordinary MySQL connection to gather its input.

It is highly recommended that you use the same MySQL username and password for all servers you want to graph, to ease the installation and configuration. If you don’t, you will need to follow the instructions in InstallingTemplates and CustomizingTemplates to accommodate your installation.

The script requires that you be able to connect to MySQL from your Cacti server. You can test this with the mysql command-line program. Debugging MySQL connection problems is beyond the scope of this documentation; refer to the MySQL manual if you have trouble.

To install,

  1. Create a MySQL user with the SUPER and PROCESS privileges on each server you want to monitor. Assuming you use “cacti” and “s3cret” as your username and password, execute the following command on each server: GRANT SUPER, PROCESS ON *.* TO 'cacti'@'%' IDENTIFIED BY "s3cret";
    1. If you want to monitor replication with mk-heartbeat from the Maatkit toolkit (recommended), you must grant SELECT on the heartbeat table also. Assuming the mk-heartbeat table is maatkit.heartbeat, execute GRANT SELECT ON maatkit.heartbeat TO 'cacti'@'%';
    2. See below for detailed information on the privileges.
  2. Copy ss_get_mysql_stats.php into your Cacti installation’s scripts/ directory.
  3. All other steps are the same as mentioned in InstallingTemplates.

If you want to specify a different MySQL port for various servers, see how to accept input in each data source.

User Privileges

The suggested user privileges mentioned above are sufficient for the common case. In some cases you might not want or have such access. The following list explains the queries that the data-gathering script executes, the functionality, and how to disable if it’s unwanted:

  • SHOW /*!50002 GLOBAL */ STATUS
    • This query requires no special privileges and is necessary for core functionality.
  • SHOW VARIABLES
    • This query requires no special privileges and is necessary for core functionality.
  • SHOW SLAVE STATUS
    • This query requires either SUPER or REPLICATION CLIENT. It is necessary for tracking replication lag on replication slaves, which is enabled by default. To disable, edit the $chk_options array in the configuration.
    • Alternatively, use mk-heartbeat and grant SELECT on the heartbeat table.
    • If disabled, parts of the the MySQL Replication Status and MySQL Binary/Relay logs graphs will be empty.
  • SHOW MASTER LOGS
    • This query is used to count up the size of binary logs. It requires the SUPER privilege.
    • If disabled in the $chk_options array, then part of the MySQL Binary/Relay logs graph will be empty.
  • SHOW PROCESSLIST
    • This query requires the PROCESS privilege to generate the MySQL Processlist graph.
    • You can disable this query by editing the $chk_options array in the configuration.
  • SHOW /*!50000 ENGINE*/ INNODB STATUS
    • This query requires the SUPER privilege. It is required for all of the InnoDB graphs.
    • You can disable this query by editing the $chk_options array in the configuration.

If you disable significant portions of the functionality, such as the InnoDB graphs, then you might want to edit the Host Template to remove unwanted graphs.

 » 转载保留版权:老陈 » 《cacti添加mysql监控》
 » 如果喜欢可以: 点此订阅本站
分类: 互联网技术 标签: , , ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.