• zabbix监控mysql脚本(仅供参考)


    mysql客户端添加

    /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 -h10.0.0.6  ping | grep -c alive

    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
    /etc/zabbix/scripts/chk_mysql.sh
    
    #!/bin/sh
    # -------------------------------------------------------------------------------
    # Author:      kk
    # Email:       hao1cheng@163.com
    MYSQL_PWD='123456'
    MYSQL_HOST='127.0.0.1'
    MYSQL_PORT='3306'
        echo "Please input one arguement:"
    fi
    case $1 in
                echo $result
                ;;
            Com_update)
                echo $result
                ;;
            Slow_queries)
                    ;;
        Com_select)
                    echo $result
                    ;;
        Com_rollback)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_rollbac
    k"|cut -d"|" -f3`
                    echo $result
                    ;;
        Questions)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status|cut -f4 -d":"|cut -f1 -d"S"`
                    echo $result
                    ;;
        Com_insert)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_insert"
    |cut -d"|" -f3`
                    echo $result
                    ;;
        Com_delete)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_delete"
    |cut -d"|" -f3`
                    echo $result
                    ;;
        Com_commit)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_commit"
    |cut -d"|" -f3`
                    echo $result
                    ;;
        Bytes_sent)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Bytes_sent"
     |cut -d"|" -f3`
                    echo $result
                    ;;
        Bytes_received)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Bytes_recei
    ved" |cut -d"|" -f3`
                    echo $result
                    ;;
        Com_begin)
            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_begin"|
    cut -d"|" -f3`
                    echo $result
                    ;;
    
            *)
            echo "Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions)"
            ;;
    esac
                   


    mysql压力测试命令

    mysqlslap -a -i 10000 -uroot -p123.asd
    

    服务端执行获取客户端主机名

    /application/zabbix/bin/zabbix_get -s 10.0.0.6 -p 10050 -k "system.hostname"
    

    服务端执行获取客户端key值

    /application/zabbix/bin/zabbix_get -s 10.0.0.6 -p 10050 -k "system.cpu.load[all,avg15]"
    

      

    服务端执行获取客户端key值

    /application/zabbix/bin/zabbix_get -s 10.0.0.6 -p 10050 -k "mysql.status[Uptime]"
    

      

     

  • 相关阅读:
    .net中AjaxPro的简单使用
    关于 Activity 中 startActivityForResult 和 onActivityResult
    产品经理值得读的12本书
    存储过程中使用事务与try catch
    扁平化数据解构转化成树形结构
    JavaScript编程精解
    泛型
    OATS:Orthogonal Array Testing Strategy
    等价类划分
    C# homework
  • 原文地址:https://www.cnblogs.com/Carr/p/7395684.html
Copyright © 2020-2023  润新知