zoukankan      html  css  js  c++  java
  • zabbix脚本监控mysql

    Zabbix监控mysql

    1.1 客户端配置

    1.1.1 安装客户端包

    yum -y install unixODBC 
    
    rpm -ivh zabbix-agent-3.0.3-1.el6.x86_64.rpm

    1.1.2 编辑配置文件

    注释所有添加以下内容
    
    vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
    
    UserParameter=mysql.version,mysql -V
    UserParameter=mysql.status[*],/etc/zabbix/scripts/chk_mysql.sh $1
    UserParameter=mysql.ping,mysqladmin -uzabbix -p123456 -P3306 -h192.168.1.77  ping | grep -c alive

    1.1.3 创建mysql监控脚本文件

    mkdir /etc/zabbix/scripts/
    touch /etc/zabbix/scripts/chk_mysql.sh
    chmod u+x /etc/zabbix/scripts/chk_mysql.sh
    chown -R zabbix.zabbix /etc/zabbix/scripts/chk_mysql.sh
    
    
     vim  /etc/zabbix/scripts/chk_mysql.sh
    
    #!/bin/sh
    # -------------------------------------------------------------------------------
    MYSQL_SOCK="/tmp/mysql.sock"
    MYSQL_USER='zabbix'
    MYSQL_PWD='123456'
    MYSQL_HOST='127.0.0.1'
    MYSQL_PORT='3306'
    ARGS=1
    if [ $# -ne "$ARGS" ];then
        echo "Please input one arguement:"
    fi
    case $1 in
        Uptime)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status|cut -f
    2 -d":"|cut -f1 -d"T"`
                echo $result
                ;;
            Com_update)
                result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-
    status |grep -w "Com_update"|cut -d"|" -f3`
                echo $result
                ;;
            Slow_queries)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status |cut -
    f5 -d":"|cut -f1 -d"O"`

    1.1.4 修改zabbix客户端指向服务端IP

    sed -i 's#ServerActive=127.0.0.1#ServerActive=192.168.1.72#g' /etc/zabbix/zabbix_agentd.conf 
    sed -i 's#Server=127.0.0.1#Server=192.168.1.72#g' /etc/zabbix/zabbix_agentd.conf   
    
    /etc/init.d/zabbix-agent restart

    1.1.5 Web端操作

  • 相关阅读:
    Javascript 返回上一页
    html中link和import方式导入CSS文件的区别
    Leecode no.76 最小覆盖子串
    Leecode no.344 反转字符串
    Leecode no.167 两数之和 II 输入有序数组
    Leecode no.567 字符串的排列
    遍历目录和文件信息
    JAVASCRIPT显示农历的日历
    asp.net上传图片加水印(c#)
    asp.net XML操作类
  • 原文地址:https://www.cnblogs.com/Carr/p/7395674.html
Copyright © 2011-2022 走看看