码迷,mamicode.com
首页 > 其他好文 > 详细

percona_template_for_cacti监控图像增加对redis多实例监控的支持

时间:2014-07-24 11:31:41      阅读:385      评论:0      收藏:0      [点我收藏+]

标签:mamicode

percona的cacti模板还是挺帅气的,但是对于redis、memercache等多实例而言,只能监控默认6379,或者一个其他端口(总之不能监控所有实例),这还是很可惜的,要实现监控一切可以监控的对象,就必须自定义模板,经过了半天的摸索,终于实现了,先来看一下帅气的截图:

bubuko.com,布布扣


步骤:

1、下载percona模板,解压,因之前用的时1.0.1版本的,所以还是在原版本的基础上修改

wget http://www.percona.com/redir/downloads/percona-monitoring-plugins/1.0.1/percona-monitoring-plugins-1.0.1.tar.gz


2、在redis的默认模板配置文件的基础上增加选项port2,用户在新建redis监控图像时要求填写redis端口号,不填的话就是默认的6379,ss_get_by_ssh.php脚本通过port2选项连接指定端口的redis实例:

cd percona-monitoring-plugins-1.0.1/cacti/bin

?  bin  ./pmp-cacti-template \
> --script ../scripts/ss_get_by_ssh.php ../definitions/redis.def \
> --mpds port2 >../templates/cacti_host_template_percona_redis_server_ht_for_multi_instance.xml


创建模板脚本的使用说明

?  bin  ./pmp-cacti-template --help
pmp-cacti-template generates a Cacti template from a definition file.  For more
details, please use the --help option, or try ‘perldoc pmp-cacti-template‘ for
complete documentation.


Usage: pmp-cacti-template <options> FILE


Options:
  --cactiver       Create templates for this Cacti version
  --graph_height   Height of generated graphs (default 120)
  --graph_width    Width of generated graphs (default 500)
  --help           Show this help message
  --lint_check     Complain about unused data found in the script
  --mpds           Comma-separated list of input method options to make
                   per-data-source
  --name_prefix    Template name prefix (default Percona)
  --poll_interval  Polling interval (default 300)
  --script         Command-line script to use (required)
  --smallint       Create templates for 32-bit MySQL
  --version        Output version information and exit


Options and values after processing arguments:
  --cactiver       (No value)
  --graph_height   120
  --graph_width    500
  --help           TRUE
  --lint_check     FALSE
  --mpds
  --name_prefix    Percona
  --poll_interval  300
  --script         (No value)
  --smallint       FALSE
  --version        FALSE
?  bin


3、在cacti的web管理页面导入新创建的redis模板cacti_host_template_percona_redis_server_ht_for_multi_instance.xml

console->Import/Export->Import Templates->choose file->import


4、修改redis模板中图像的title,以便区分图像属于那个实例,本例使用用户在创建图像时输入的端口号区分,在cacti中变量使用||引用

console->Templates->Graph Templates->search ‘redis‘ and select a redis template->in Graph Template title->|host_description| - Redis Commands - |input_port2|->save

bubuko.com,布布扣


5、新建redis的监控图像,记得填写端口号

bubuko.com,布布扣



6、如果在导入新模板之前已经有对redis 6379的监控,这时图像显示名字会不正常,如192.168.0.19_Redis19 - Redis Unsaved Changes - |input_port2|,而非192.168.0.19_Redis19 - Redis Unsaved Changes - 6382

需要修改之前的datasource

console->Create->Data Sources->search ‘redis‘ and select a data source->in the Custom Data,let port2=6379->save

bubuko.com,布布扣


7、脚本刷新图像显示名字

在cacti服务器的脚本目录下:

[root@admin200 cli]# pwd
/var/www/cacti/cacti/cli
[root@admin200 cli]# php -q poller_graphs_reapply_names.php  -id=All -d -s=Redis
WARNING: Do not interrupt this script.  Interrupting during rename can cause issues
DEBUG: There are ‘142‘ Graphs to rename
DEBUG: Graph Name ‘192.168.0.19_Redis19 - Redis Commands - 6379‘ starting
DEBUG: Graph Rename Done for Graph ‘192.168.0.19_Redis19 - Redis Commands - 6379‘
DEBUG: Graph Name ‘192.168.0.19_Redis19 - Redis Connections - 6379‘ starting
DEBUG: Graph Rename Done for Graph ‘192.168.0.19_Redis19 - Redis Connections - 6379‘
DEBUG: Graph Name ‘192.168.0.19_Redis19 - Redis Memory - 6379‘ starting
DEBUG: Graph Rename Done for Graph ‘192.168.0.19_Redis19 - Redis Memory - 6379‘


8、ok,刷新web图像就显示正常,见本文开头截图。









percona_template_for_cacti监控图像增加对redis多实例监控的支持

标签:mamicode

原文地址:http://blog.csdn.net/xuyaqun/article/details/38080975

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!