设为首页 收藏本站
查看: 1760|回复: 0

[经验分享] CACTI :使用模板监控本地或其他服务器上的mysql

[复制链接]

尚未签到

发表于 2015-11-22 14:53:03 | 显示全部楼层 |阅读模式
  


  mysql 的模板,网上都在使用的这个地址http://mysql-cacti-templates.googlecode.com 已经访问不到了
  


  Google找到这个网址:
  介绍篇:
http://www.percona.com/doc/percona-monitoring-plugins/1.0/cacti/mysql-templates.html


  下载页:http://www.percona.com/downloads/percona-monitoring-plugins/


  


  为了方便大家下载,上传到csdn可供下载: http://download.iyunv.com/detail/kk185800961/8651279
  


  当前下载的文件:percona-cacti-templates-1.1.4-1.noarch.rpm
  


  


  


  本地服务器监控本地mysql:
  


  进入到cacti所在目录
  

cd /var/www/html

将压缩文件移到当前目录(放那都行):  
  

mv percona-cacti-templates-1.1.4-1.noarch.rpm .

解压文件:  
  

rpm2cpio percona-cacti-templates-1.1.4-1.noarch.rpm | cpio -div

在当前目录下将生产以下目录及文件:
  
  

./usr/share/cacti/resource/percona
./usr/share/cacti/resource/percona/bin
./usr/share/cacti/resource/percona/bin/pmp-cacti-extract-template
./usr/share/cacti/resource/percona/bin/pmp-cacti-graph-defs
./usr/share/cacti/resource/percona/bin/pmp-cacti-make-hashes
./usr/share/cacti/resource/percona/bin/pmp-cacti-template
./usr/share/cacti/resource/percona/definitions
./usr/share/cacti/resource/percona/definitions/apache.def
./usr/share/cacti/resource/percona/definitions/galera.def
./usr/share/cacti/resource/percona/definitions/gnu_linux.def
./usr/share/cacti/resource/percona/definitions/jmx.def
./usr/share/cacti/resource/percona/definitions/memcached.def
./usr/share/cacti/resource/percona/definitions/mongodb.def
./usr/share/cacti/resource/percona/definitions/mysql.def
./usr/share/cacti/resource/percona/definitions/nginx.def
./usr/share/cacti/resource/percona/definitions/openvz.def
./usr/share/cacti/resource/percona/definitions/rds.def
./usr/share/cacti/resource/percona/definitions/redis.def
./usr/share/cacti/resource/percona/misc
./usr/share/cacti/resource/percona/misc/jmx-monitor.xml
./usr/share/cacti/resource/percona/templates
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_apache_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_galera_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_gnu_linux_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_jmx_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_memcached_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mongodb_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_nginx_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_openvz_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_rds_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_redis_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/scripts/ss_get_by_ssh.php
./usr/share/cacti/scripts/ss_get_mysql_stats.php
./usr/share/cacti/scripts/ss_get_rds_stats.py


  
  现在只要mysql的两个文件:
  

ss_get_mysql_stats.php
cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.1.4.xml

拷贝ss_get_mysql_stats.php到cacti目录中:  
  

cp ./usr/share/cacti/scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/

编辑文件,确认用户名和密码正确:  
  

vi /var/www/html/cacti/scripts/ss_get_mysql_stats.php$mysql_user = 'cacti';
$mysql_pass = 'cacti';



导入模板:打开cactiy页面——>Console——>Import Templates——>浏览添加  
DSC0000.jpg


  


  导入结果:
  

Import Results
Cacti has imported the following items:
CDEF
[success] Percona Turn Into Bits CDEF [new]
[success] Percona Negate CDEF [new]
GPRINT Preset
[success] Percona MySQL Server Checksum 523e4d8178a000df8df3a9825c4e7e1e [new]
[success] Percona MySQL Server Version t1.1.4:s1.1.4 [new]
[success] Percona Normal [new]
Data Input Method
[success] Percona Get MySQL Stats/MyISAM Indexes IM [new]
[success] Percona Get MySQL Stats/MyISAM Key Cache IM [new]
[success] Percona Get MySQL Stats/InnoDB Buffer Pool IM [new]
[success] Percona Get MySQL Stats/InnoDB I/O IM [new]
[success] Percona Get MySQL Stats/InnoDB Insert Buffer IM [new]
[success] Percona Get MySQL Stats/InnoDB Insert Buffer Usage IM [new]
[success] Percona Get MySQL Stats/InnoDB Semaphores IM [new]
[success] Percona Get MySQL Stats/InnoDB Row Operations IM [new]
[success] Percona Get MySQL Stats/MySQL Table Locks IM [new]
[success] Percona Get MySQL Stats/MySQL Connections IM [new]
[success] Percona Get MySQL Stats/MySQL Replication IM [new]
[success] Percona Get MySQL Stats/MySQL Query Cache IM [new]
[success] Percona Get MySQL Stats/MySQL Query Cache Memory IM [new]
[success] Percona Get MySQL Stats/MySQL Command Counters IM [new]
[success] Percona Get MySQL Stats/MySQL Select Types IM [new]
[success] Percona Get MySQL Stats/MySQL Sorts IM [new]
[success] Percona Get MySQL Stats/MySQL Temporary Objects IM [new]
[success] Percona Get MySQL Stats/MySQL Network Traffic IM [new]
[success] Percona Get MySQL Stats/InnoDB Buffer Pool Activity IM [new]
[success] Percona Get MySQL Stats/InnoDB I/O Pending IM [new]
[success] Percona Get MySQL Stats/InnoDB Log IM [new]
[success] Percona Get MySQL Stats/MySQL Binary/Relay Logs IM [new]
[success] Percona Get MySQL Stats/InnoDB Transactions IM [new]
[success] Percona Get MySQL Stats/InnoDB Transactions Active/Locked IM [new]
[success] Percona Get MySQL Stats/MySQL Files and Tables IM [new]
[success] Percona Get MySQL Stats/MySQL Threads IM [new]
[success] Percona Get MySQL Stats/InnoDB Memory Allocation IM [new]
[success] Percona Get MySQL Stats/InnoDB Adaptive Hash Index IM [new]
[success] Percona Get MySQL Stats/InnoDB Internal Hash Memory Usage IM [new]
[success] Percona Get MySQL Stats/InnoDB Tables In Use IM [new]
[success] Percona Get MySQL Stats/InnoDB Current Lock Waits IM [new]
[success] Percona Get MySQL Stats/InnoDB Lock Structures IM [new]
[success] Percona Get MySQL Stats/InnoDB Checkpoint Age IM [new]
[success] Percona Get MySQL Stats/InnoDB Row Lock Time IM [new]
[success] Percona Get MySQL Stats/InnoDB Row Lock Waits IM [new]
[success] Percona Get MySQL Stats/InnoDB Semaphore Waits IM [new]
[success] Percona Get MySQL Stats/InnoDB Semaphore Wait Time IM [new]
[success] Percona Get MySQL Stats/MySQL Processlist IM [new]
[success] Percona Get MySQL Stats/MySQL Transaction Handler IM [new]
[success] Percona Get MySQL Stats/MySQL Handlers IM [new]
[success] Percona Get MySQL Stats/MySQL Query Time Histogram (Count) IM [new]
[success] Percona Get MySQL Stats/MySQL Query Response Time (Microseconds) IM [new]
[success] Percona Get MySQL Stats/InnoDB Buffer Pool Efficiency IM [new]
Data Template
[success] Percona MyISAM Indexes DT [new]
[success] Percona MyISAM Key Cache DT [new]
[success] Percona InnoDB Buffer Pool DT [new]
[success] Percona InnoDB I/O DT [new]
[success] Percona InnoDB Insert Buffer DT [new]
[success] Percona InnoDB Insert Buffer Usage DT [new]
[success] Percona InnoDB Semaphores DT [new]
[success] Percona InnoDB Row Operations DT [new]
[success] Percona MySQL Table Locks DT [new]
[success] Percona MySQL Connections DT [new]
[success] Percona MySQL Replication DT [new]
[success] Percona MySQL Query Cache DT [new]
[success] Percona MySQL Query Cache Memory DT [new]
[success] Percona MySQL Command Counters DT [new]
[success] Percona MySQL Select Types DT [new]
[success] Percona MySQL Sorts DT [new]
[success] Percona MySQL Temporary Objects DT [new]
[success] Percona MySQL Network Traffic DT [new]
[success] Percona InnoDB Buffer Pool Activity DT [new]
[success] Percona InnoDB I/O Pending DT [new]
[success] Percona InnoDB Log DT [new]
[success] Percona MySQL Binary/Relay Logs DT [new]
[success] Percona InnoDB Transactions DT [new]
[success] Percona InnoDB Transactions Active/Locked DT [new]
[success] Percona MySQL Files and Tables DT [new]
[success] Percona MySQL Threads DT [new]
[success] Percona InnoDB Memory Allocation DT [new]
[success] Percona InnoDB Adaptive Hash Index DT [new]
[success] Percona InnoDB Internal Hash Memory Usage DT [new]
[success] Percona InnoDB Tables In Use DT [new]
[success] Percona InnoDB Current Lock Waits DT [new]
[success] Percona InnoDB Lock Structures DT [new]
[success] Percona InnoDB Checkpoint Age DT [new]
[success] Percona InnoDB Row Lock Time DT [new]
[success] Percona InnoDB Row Lock Waits DT [new]
[success] Percona InnoDB Semaphore Waits DT [new]
[success] Percona InnoDB Semaphore Wait Time DT [new]
[success] Percona MySQL Processlist DT [new]
[success] Percona MySQL Transaction Handler DT [new]
[success] Percona MySQL Handlers DT [new]
[success] Percona MySQL Query Time Histogram (Count) DT [new]
[success] Percona MySQL Query Response Time (Microseconds) DT [new]
[success] Percona InnoDB Buffer Pool Efficiency DT [new]
Graph Template
[success] Percona MyISAM Indexes GT [new]
[success] Percona MyISAM Key Cache GT [new]
[success] Percona InnoDB Buffer Pool GT [new]
[success] Percona InnoDB I/O GT [new]
[success] Percona InnoDB Insert Buffer GT [new]
[success] Percona InnoDB Insert Buffer Usage GT [new]
[success] Percona InnoDB Semaphores GT [new]
[success] Percona InnoDB Row Operations GT [new]
[success] Percona MySQL Table Locks GT [new]
[success] Percona MySQL Connections GT [new]
[success] Percona MySQL Replication GT [new]
[success] Percona MySQL Query Cache GT [new]
[success] Percona MySQL Query Cache Memory GT [new]
[success] Percona MySQL Command Counters GT [new]
[success] Percona MySQL Select Types GT [new]
[success] Percona MySQL Sorts GT [new]
[success] Percona MySQL Temporary Objects GT [new]
[success] Percona MySQL Network Traffic GT [new]
[success] Percona InnoDB Buffer Pool Activity GT [new]
[success] Percona InnoDB I/O Pending GT [new]
[success] Percona InnoDB Log GT [new]
[success] Percona MySQL Binary/Relay Logs GT [new]
[success] Percona InnoDB Transactions GT [new]
[success] Percona InnoDB Transactions Active/Locked GT [new]
[success] Percona MySQL Files and Tables GT [new]
[success] Percona MySQL Threads GT [new]
[success] Percona InnoDB Memory Allocation GT [new]
[success] Percona InnoDB Adaptive Hash Index GT [new]
[success] Percona InnoDB Internal Hash Memory Usage GT [new]
[success] Percona InnoDB Tables In Use GT [new]
[success] Percona InnoDB Current Lock Waits GT [new]
[success] Percona InnoDB Lock Structures GT [new]
[success] Percona InnoDB Checkpoint Age GT [new]
[success] Percona InnoDB Row Lock Time GT [new]
[success] Percona InnoDB Row Lock Waits GT [new]
[success] Percona InnoDB Semaphore Waits GT [new]
[success] Percona InnoDB Semaphore Wait Time GT [new]
[success] Percona MySQL Processlist GT [new]
[success] Percona MySQL Transaction Handler GT [new]
[success] Percona MySQL Handlers GT [new]
[success] Percona MySQL Query Time Histogram (Count) GT [new]
[success] Percona MySQL Query Response Time (Microseconds) GT [new]
[success] Percona InnoDB Buffer Pool Efficiency GT [new]
Host Template
[success] Percona MySQL Server HT [new]


  
  打开Devices——>选择主机(没有则创建)——>下拉到底部


  选择相应的图像模板添加到主机:
  当前测试添加了3个:
  Percona InnoDB Log GT

Percona MySQL Connections GT

Percona MySQL Threads GT


DSC0001.jpg


  


  上拉到页面顶部,点击“为主机创建图像(Create Graphs for this Host)”,选择刚才的3个图像模板,创建。
DSC0002.jpg


  


  创建目录树并添加图像到树中:
  点击 “图像树(Graph Trees)”——>选择 “默认树(Default Tree)”——>添加子树(Mysql_local)
DSC0003.jpg


  点击树Mysql_local旁边的“添加(Add)”,子树类型为“图像(Graph)”,将mysql的3个监控图像放在该目录结构中显示:
DSC0004.jpg


  


  几分钟后查看。图像出现!
DSC0005.jpg


  


  


  


  


  跨服务器监控centos中的mysql :
  


  cacti监控服务器:192.168.1.151
  被监控的客户端:192.168.1.152
  


  互相ping一下,确认网络畅通。
  


  在客户端152中安装snmp:


  

yum -y install net-snmp net-snmp-utils


  
  #更改配置文件以下信息:第41行,第62行,第85行


  

vi /etc/snmp/snmpd.conf#com2sec notConfigUser  default       public
com2sec notConfigUser  192.168.1.151       public

#access  notConfigGroup ""      any       noauth    exact  systemview none none
access  notConfigGroup ""      any       noauth    exact  all none none

#将 #view all included .1 80 前面的 # 注释去掉
view all    included  .1 80




最后启动或重启客户端snmp服务:
  
  

service snmpd restart


  
  在客户端152的mysql添加cacti用户允许151访问:


  

grant process,super on *.* to 'cacti'@'192.168.1.151' identified by 'cacti';
flush privileges;
  


  在服务端151执行,测试152的snmp是否启用成功:
  

snmpwalk -c public -v 2c 192.168.1.152


  
  主要防火墙问题,把客户端snmp服务也添加到自启动中:ntsysv
  


  


  点击:设备(Devices)——>add(右上角)
DSC0006.jpg


  


  其他添加的步骤和方法,和本机使用的一样。
  


  没有图像是,注意cacti目录下是否有权限:
  

ll /var/www/html/cacti/rra

很快图像数据距出现了:  
DSC0007.jpg


  


  


  


  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-142215-1-1.html 上篇帖子: Cacti 监控华为5700交换机总流量 下篇帖子: Cacti完全使用手册
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表