给Cacti安装mysql服务监控插件
原创文章,转载请注明: 转载自听风细雨 – 大型网站运维
本文链接地址: 给Cacti安装mysql服务监控插件
给Cacti安装监控mysql插件
插件一(可用,推荐):
来源:http://code.google.com/p/mysql-cacti-templates/
一,脚本下载以及设置
tar -xzvf mysql-cacti-templates-1.1.2.tar.gz
cd mysql-cacti-templates-1.1.2
cp ss_get_mysql_stats.php /xok.la/cacti/scripts
可以看到里面有多个监控项目,报告监控apache和nginx.我这只测试mysql,mysql相关的就2个文件:
模板文件:cacti_host_template_x_db_server_ht_0.8.6i.xml
插件:ss_get_mysql_stats.php
修改ss_get_mysql_stats.php 文件 第30行
$mysql_pass = 'cacti';
$cache_dir = “/data/cacti/cache/”;
设置准备监控的数据库的账户相关信息
chown -R vhost.vhost /data/cacti/cache/
chmod 777 -R /data/cacti/cache/
二,创建监控Mysql需要的账户以及权限
配置MySQL服务器,让cacti所在机器能够访问MySQL服务器的状态信息,必须拥有”process”权限。如果要监控InnoDB状态,还必须有”SUPER”权限。
三,模板导入
在cacti管理界面(Import Templates)导入cacti_host_template_x_db_server_ht_0.8.6i.xml。
四,添加设备
创建Graph。在Console选项卡下的左侧菜单栏中选择Devices,为要监控的主机新建一个Devices或选择已有Devices。在Associated Graph Templates中添加想要监控MySQL状态的Graph Templates(如X MySQL Connections GT模板)。并点击最上面的Create Graphs for this Host链接,在Graph Templates的选择框中选择X MySQL Connections GT,然后点击Create按钮,出现以下WEB页。
监控的对象有:
X InnoDB Buffer Pool Activity GT
X InnoDB Buffer Pool GT
X InnoDB I/O GT
X InnoDB I/O Pending GT
X InnoDB Insert Buffer GT
X InnoDB Log GT
X InnoDB Row Operations GT
X InnoDB Semaphores GT
X InnoDB Transactions GT
X MyISAM Indexes GT
X MySQL Binary/Relay Logs GT
X MySQL Command Counters GT
X MySQL Connections GT
X MySQL Files and Tables GT
X MySQL Handlers GT
X MySQL Network Traffic GT
X MySQL Processlist GT
X MySQL Query Cache GT
X MySQL Query Cache Memory GT
X MySQL Replication GT
X MySQL Select Types GT
X MySQL Sorts GT
X MySQL Table Locks GT
X MySQL Temporary Objects GT
X MySQL Threads GT
X MySQL Transaction Handler GT
一,脚本下载
tar -xzvf teMySQLcacti-20060810.tar.gz
cd teMySQLcacti
cp mysql_stats.php /data/cacti/scripts/
cp dumpMemcachedStats.php /data/cacti/scripts/
在cacti管理界面(Import Templates)导入cacti_host_template_temysql_host-step300-heartbeat600.xml 与cacti_host_template_memcached_host-step300-heartbeat600.xml模板文件。
三,创建监控Mysql需要的账户以及权限
配置MySQL服务器,让cacti所在机器能够访问MySQL服务器的状态信息,必须拥有”process”权限。如果要监控InnoDB状态,还必须有”SUPER”权限。
mysql> grant process,super on *.* to 'cacti'@'%' identified by 'cacti';
四,添加设备
创建Graph。在Console选项卡下的左侧菜单栏中选择Devices,为要监控的主机新建一个Devices或选择已有Devices。在Associated Graph Templates中添加想要监控MySQL状态的Graph Templates(如teMySQL – Index Usage模板,此套模板是以teMySQL开头的一系列模板)。并点击最上面的Create Graphs for this Host链接,在Graph Templates的选择框中选择teMySQL – Locking and Slow,然后点击Create按钮,出现以下WEB页。
监控的对象有:
teMySQL – Index Usage
teMySQL – InnoDB Buffers Pages/Mem
teMySQL – InnoDB File I/O
teMySQL – InnoDB InsBuffer
teMySQL – InnoDB Locks
teMySQL – InnoDB Row
teMySQL – Load Average
teMySQL – Locking and Slow
teMySQL – Network Usage
teMySQL – Old Command Stats
teMySQL – Old Handler Stats
teMySQL – Query Cache
teMySQL – Replication
teMySQL – Select Handler
teMySQL – Select Queries
teMySQL – Sorts
teMySQL – Temporary Objects
teMySQL – Threads/Abends
teMySQL – Volatile Handler
teMySQL – Volatile Queries
插件三
来源:http://forums.cacti.net/about6108-0-asc-0.html
下载地址:
mysql_stats.zip
方法同上。
我只用了2个模板:
cacti_graph_template_mysql_connections.xml
cacti_graph_template_mysql_thread_statistics.xml
成功后的效果图:
总结:这三个都测试过了,但有可用但也有部分没有图的现象,没有去做仔细的深入研究
文章的脚注信息由WordPress的wp-posturl插件自动生成


1条评论▼