linux下cacti监控mysql数据库_linux下Cacti监控MySQL数据库状态例子

更新时间:2019-10-11    来源:Google    手机版     字体:

【www.bbyears.com--Google】

1、监控脚本下载及配置

wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz
tar zxvf better-cacti-templates-1.1.8.tar.gz
cd better-cacti-templates-1.1.8
cp scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/

监控mysql只需要用到两个文件:

模板文件:./templates/cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml
插件:./scriptsss_get_mysql_stats.php
修改ss_get_mysql_stats.php 文件:

vim /var/www/html/cacti/scripts/ss_get_mysql_stats.php

 

cacti_mysql_1


 
配置MySQL服务器,让cacti所在机器能够访问MySQL服务器的状态信息,必须拥有”process”权限。如果要监控InnoDB状态,还必须有”SUPER”权限。

mysql> grant process,super on *.* to \"cactiuser\"@\"%\" identified by \"cactiuser\"; mysql> grant all privileges on cacti.*  to cactiuser@"%" identified by "cactiuser"; mysql> flush privileges;

 

3、导入模板
将模板cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml从linux下到本地电脑,登陆web导入:
cacti_import_templates


 

4、添加mysql监控
在Console选项卡下的左侧菜单栏中选择Devices,选择一个Device或新建一个Device,在Associated Graph Templates中添加要监控的mysql状态:
cacti_mysql_2


 

在Create Graphs for this Host中选中刚才添加的模板,在点击下方create创建图像:
cacti_mysql_3


 

5、最后在左上角的graphs选项卡,查看设备图像,就可以查看到监控的mysql图像:
cacti_mysql

本文来源:http://www.bbyears.com/seo/72458.html