• Cacti 监控 MySQL



    1. 安装监控插件
    wget http://mysql-cacti-templates.googlecode.com/files/mysql-cacti-templates-1.1.2.tar.gz
    tar -xzvf mysql-cacti-templates-1.1.2.tar.gz
    cp mysql-cacti-templates-1.1.2/ss_get_mysql_stats.php /var/www/html/cacti/scripts/
    chown -R cacti.cacti /var/www/html/cacti/scripts
    chmod -R 755 /var/www/html/cacti/scripts

    使用 http 访问 cacti主机 导入 mysql-cacti-templates-1.1.2/cacti_host_template_x_db_server_ht_0.8.6i.xml
    http://192.168.18.131:8000/cacti
    默认CactiEZ 账户和密码分别是 admin admin
    控制台 - 导入导出 - 模板导入 - 浏览
    选中 cacti_host_template_x_db_server_ht_0.8.6i.xml
    保存

    2. 配置cacti的mysql插件
    修改 ss_get_mysql_stats.php
    vi /var/www/html/scripts/ss_get_mysql_stats.php
    $mysql_user = 'cacti';
    $mysql_pass = 'cacti';

    这个账户和密码是 被监控端主机 给 Cacti主机 授权的 账户和密码
    Cacti需要这个账户和密码去连接 被监控机 查询状态


    3. 配置被监控端的mysql 给 cacti 主机授权
    mysql -uroot -p
    grant process,super on *.* to 'cacti'@'192.168.0.3' identified by 'cacti';
    flush privileges;
    grant process,super on *.* to '账户'@'Cacti主机IP地址' identified by '密码';
    此命令 意义
    只允许IP为 192.168.0.3 的主机 以 账户 cacti 密码 cacti 去访问 本机数据

    4. 在Cacti主机上 监控Mysql

    4.1 为主机添加mysql模块
    控制台 - 管理 - 设备 - 选中之前创建好的主机
    然后移到最下面的 添加图形模版 选中 Mysql相关模块 然后保存

    4.2 为mysql模块创建图形
    控制台 - 创建 - 创建图形 - 选中该主机 - 选中mysql模块 - 创建

    4.3 插件mysql性能数据
    监视器 - 选中该主机 - 查阅对应的mysql

    完毕


    注意:这个获取数据的php程序有bug,将SQL部分需要做特殊处理,会出现如下报错:

    点击(此处)折叠或打开

    1. Error executing 'SELECT CONCAT('', ((1 << 32) + 0)) AS innodb_transactions, CONCAT('', (((1 << 32) + 0) - ((1 << 32) + 0))) AS unpurged_txns, CONCAT('', ((5 << 32) + 1)) AS log_bytes_written, CONCAT('', ((5 << 32) + 1)) AS log_bytes_flushed, CONCAT('', (((5 << 32) + 1) - ((5 << 32) + 1))) AS unflushed_log, CONCAT('', 219133+13703) AS spin_waits, CONCAT('', 450719) AS spin_rounds, CONCAT('', 7353++) AS os_waits': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS os_waits' at line 1

    我将sql部分的代码改了一下,加了个trim函数处理结尾的+号。更改成如下解决问题:

    点击(此处)折叠或打开

    1. $sql = "SELECT CONCAT('', $txn) AS innodb_transactions, "
    2. . "CONCAT('', ($txn - $prg)) AS unpurged_txns, "
    3. . "CONCAT('', $lsn) AS log_bytes_written, "
    4. . "CONCAT('', $flu) AS log_bytes_flushed, "
    5. . "CONCAT('', ($lsn - $flu)) AS unflushed_log, "
    6. . "CONCAT('', " . trim(implode('+', $spin_waits),'+'). ") AS spin_waits, "
    7. . "CONCAT('', " . implode('+', $spin_rounds) . ") AS spin_rounds, "
    8. . "CONCAT('', " . trim(implode('+', $os_waits),'+') . ") AS os_waits";



  • 相关阅读:
    Android Api 检查參数状态Api
    【Jquery】prop与attr的差别
    【CODEFORCES】 A. Dreamoon and Sums
    使用&lt;jsp:include&gt;,不想写死URL,动态生成URL的解决的方法
    android.app.Activity 的介绍
    字符变换
    android之获取屏幕的宽度和高度
    2015跑过的路
    hdu5418--Victor and World(floyd+状压dp)
    解决PL/SQL Developer 连接oracle 11g 64位中的问题
  • 原文地址:https://www.cnblogs.com/feihongwuhen/p/7170315.html
Copyright © 2020-2023  润新知