zoukankan      html  css  js  c++  java
  • 使用Percona监控插件监控MySQL

     1.使用Percona监控插件监控MySQL

    yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

    https://www.percona.com/doc/percona-monitoring-plugins/1.1/zabbix/index.html#installation-instructions

    yum install percona-zabbix-templates php php-mysql

     1.php脚本用来数据采集   2.shell  调用这个php   3.zabbix配置文件   4.zabbix模板文件      创建zabbix监控专用用户。

    Percona Monitoring Plugins for Zabbix
    These templates are mainly adopted from the existing Cacti ones. Currently, only MySQL template is available.
    
    There are a few major differences between Cacti and Zabbix templates:
    
    Zabbix does not support negative Y axis, that’s why you can see the negative values on some graphs to work out that - consider them the same as positive ones.
    Zabbix does not support stacked graph items with mixed draw styles, that’s why some graphs may not look so nice like in Cacti as the stacks are replaced with lines.
    Other Zabbix specific points:
    
    The items are populated by polling Zabbix agent.
    There are predefined triggers available to use.
    There is a screen as a placeholder for all graphs.
    300 sec. polling interval - like with Cacti, the existing PHP script is used to retrive and cache MySQL metrics except some trigger-specific items. Due to the caching of results, PHP script runs only once per period.
    System Requirements
    Zabbix version 2.0.x. The actual testing has been done on the version 2.0.9.
    Zabbix agent, php, php-mysql packages on monitored node.
    Installation Instructions
    Configure Zabbix Agent
    Install the package from Percona Software Repositories:
    
    yum install percona-zabbix-templates
    or:
    
    apt-get install percona-zabbix-templates
    It will place files under /var/lib/zabbix/percona/. Alternatively, you can grab the tarball and copy folders zabbix/scripts/ and zabbix/templates/ into /var/lib/zabbix/percona/. See below for the URL.
    Copy Zabbix Agent config:
    
    mkdir -p /etc/zabbix_agentd.conf.d/
    cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix_agentd.conf.d/userparameter_percona_mysql.conf
    Ensure /etc/zabbix_agentd.conf contains the line: Include=/etc/zabbix_agentd.conf.d/
    Restart Agent:
    
    service zabbix-agent restart
    Configure MySQL connectivity on Agent
    On this step we need to configure and verify MySQL connectivity with localhost on the Agent node.
    
    Create .cnf file /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf as described at configuration file
    
    Example:
    
    <?php
    $mysql_user = 'root';
    $mysql_pass = 's3cret';
    Test the script:
    
    [root@centos6 main]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
    405647
    Should return any number. If the password is wrong in .cnf file, you will get something like:
    
    [root@centos6 ~]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
    ERROR: run the command manually to investigate the problem: /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
    [root@centos6 ~]# /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
    ERROR: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[root@centos6 ~]#
    Configure ~zabbix/.my.cnf
    
    Example:
    
    [client]
    user = root
    password = s3cret
    Test the script:
    
    [root@centos6 ~]# sudo -u zabbix -H /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
    0
    Should return 0 or 1 but not the “Access denied” error.
    Configure Zabbix Server
    Grab the latest tarball from the Percona Software Downloads directory to your desktop.
    Unpack it to get zabbix/templates/ folder.
    Import the XML template using Zabbix UI (Configuration -> Templates -> Import) by additionally choosing “Screens”.
    Create/edit hosts by assigning them “Percona Templates” group and linking the template “Percona MySQL Server Template” (Templates tab).
    You are done.
    Support Options
    If you have questions, comments, or need help with the plugins, there are several options to consider.
    
    You can get self-service help via Percona’s forums, or the Percona mailing list.
    
    You can report bugs and submit patches to the Launchpad project.
    
  • 相关阅读:
    String ,StringBuilder, StringBuffer
    apt-get方式删除软件
    curl命令的使用
    maven自动部署测试Web应用
    几个重要的maven命令
    linux中默认jdk的配置
    登录注册的页面制作
    运用php做投票题,例题
    复选框式查询 例题租房子
    会话用法 和留言板例题
  • 原文地址:https://www.cnblogs.com/gaoyuechen/p/8287459.html
Copyright © 2011-2022 走看看