您的位置:首页 > 数据库 > SQL

配置CACTI监控MySQL数据库状态(5)增加MySQL监控模板

2014-02-09 17:27 549 查看

4、增加MySQL监控模板

下载模板:#wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz# tar xvfz better-cacti-templates-1.1.8.tar.gz # cd better-cacti-templates-1.1.8# cp scripts/ss_get_mysql_stats.php /data/www/cacti/scripts/

导入模板,在cacti管理界面(Import Templates)导入templates/cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml文件。如无异常应显示[success]。
修改脚本文件:# vi /data/www/cacti/scripts/ss_get_mysql_stats.php

修改$mysql_user = ¨cacti¨;$mysql_pass = ¨cacti¨;$mysql_port = 3306;$cache_dir = ¨/data/www/cacti/cache¨;

创建缓存目录并授予所有用户读写权限:# mkdir /data/www/cacti/cache# chown cacti:cacti /data/www/cacti/cache# chmod 777 /data/www/cacti/cache

客户端的配置以MySQL服务器172.16.1.110为例,创建监控mysql的用户并授予所需要的权限:mysql> grant process,super,replication client on *.* to ¨cacti¨@¨10.0.0.116¨ identified by ¨cacti¨;

安装net-snmp及关联组件,为简化操作直接使用yum安装了:# yum -y install net-snmp net-snmp-utils net-snmp-devel net-snmp-libs

配置net-snmp:# vi /etc/snmp/snmpd.conf

修改:access notConfigGroup "" any noauth exact all none nonecom2sec local localhost publiccom2sec mynetwork 10.0.0.0/24 publicview all included .1 80

启动服务:# /etc/init.d/snmpd start

执行下列命令检查:# snmpwalk -v 2c -c public localhost sysUpTime

正常情况下应有返回。
返回到cacti浏览器管理界面,创建对刚刚配置好的客户端的监控,按照下列步骤操作:Devices->AddDescription填写描述,Hostname填写客户端IP地址,这里是172.16.1.110,Host Template选择一个模板,这里选择的是预先定制好的模板MYSQLDB(如果没有,选择Local Linux Machine也可以,模板的优点是方便对监控项管理),其它不变,点击create。Devices->[刚刚创建的客户端名称]->Create Graphs for this host根据需要,增加监控项即可。
配置完成后,就可以进入Graph Management中查看具体的监控项了。点击就可以看到图片。默认情况下cacti每5分钟收集一次数据,因此至少需要等待几分钟时间。
至此,配置基本完成。之后就可以根据实际情况,做各种定制化的监控方案。

N、错误处理

Apache日志中提示:[Fri Mar 23 09:30:16 2012] [error] [client 10.0.10.199] PHP Warning: strtotime(): It is not safe to rely on the system¨s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ¨Asia/Chongqing¨ for ¨CST/8.0/no DST¨ instead in /data/www/cacti/include/global_constants.php on line 165

修改/data/www/cacti/include/global_constants.php文件,增加一行:date_default_timezone_set (¨Asia/Shanghai¨);

Apache日志中提示:[error] [client 10.0.10.199] File does not exist: /data/www/favicon.ico手动创建一个该文件即可:# cat /dev/null > /data/www/favicon.ico
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: